@dmitryvim/form-builder 0.2.8 → 0.2.9
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/browser/formbuilder.min.js +74 -56
- package/dist/browser/formbuilder.v0.2.9.min.js +322 -0
- package/dist/cjs/index.cjs +69 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +69 -27
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +74 -56
- package/package.json +1 -1
- package/dist/browser/formbuilder.v0.2.8.min.js +0 -304
package/dist/esm/index.js
CHANGED
|
@@ -410,7 +410,7 @@ function renderMultipleTextElement(element, ctx, wrapper, pathKey) {
|
|
|
410
410
|
font-size: var(--fb-font-size);
|
|
411
411
|
transition: all var(--fb-transition-duration);
|
|
412
412
|
`;
|
|
413
|
-
addBtn.textContent =
|
|
413
|
+
addBtn.textContent = "+";
|
|
414
414
|
addBtn.addEventListener("mouseenter", () => {
|
|
415
415
|
addBtn.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
416
416
|
});
|
|
@@ -659,7 +659,7 @@ function renderMultipleTextareaElement(element, ctx, wrapper, pathKey) {
|
|
|
659
659
|
removeBtn = document.createElement("button");
|
|
660
660
|
removeBtn.type = "button";
|
|
661
661
|
removeBtn.className = "remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm";
|
|
662
|
-
removeBtn.innerHTML = "\u2715
|
|
662
|
+
removeBtn.innerHTML = "\u2715";
|
|
663
663
|
removeBtn.onclick = () => {
|
|
664
664
|
const currentIndex = Array.from(container.children).indexOf(
|
|
665
665
|
item
|
|
@@ -687,7 +687,7 @@ function renderMultipleTextareaElement(element, ctx, wrapper, pathKey) {
|
|
|
687
687
|
const addBtn = document.createElement("button");
|
|
688
688
|
addBtn.type = "button";
|
|
689
689
|
addBtn.className = "add-textarea-btn mt-2 px-3 py-1 text-blue-600 border border-blue-300 rounded hover:bg-blue-50 text-sm";
|
|
690
|
-
addBtn.textContent =
|
|
690
|
+
addBtn.textContent = "+";
|
|
691
691
|
addBtn.onclick = () => {
|
|
692
692
|
values.push(element.default || "");
|
|
693
693
|
addTextareaItem(element.default || "");
|
|
@@ -829,7 +829,7 @@ function renderMultipleNumberElement(element, ctx, wrapper, pathKey) {
|
|
|
829
829
|
const addBtn = document.createElement("button");
|
|
830
830
|
addBtn.type = "button";
|
|
831
831
|
addBtn.className = "add-number-btn mt-2 px-3 py-1 text-blue-600 border border-blue-300 rounded hover:bg-blue-50 text-sm";
|
|
832
|
-
addBtn.textContent =
|
|
832
|
+
addBtn.textContent = "+";
|
|
833
833
|
addBtn.onclick = () => {
|
|
834
834
|
values.push(element.default || "");
|
|
835
835
|
addNumberItem(element.default || "");
|
|
@@ -1111,7 +1111,7 @@ function renderMultipleSelectElement(element, ctx, wrapper, pathKey) {
|
|
|
1111
1111
|
const addBtn = document.createElement("button");
|
|
1112
1112
|
addBtn.type = "button";
|
|
1113
1113
|
addBtn.className = "add-select-btn mt-2 px-3 py-1 text-blue-600 border border-blue-300 rounded hover:bg-blue-50 text-sm";
|
|
1114
|
-
addBtn.textContent =
|
|
1114
|
+
addBtn.textContent = "+";
|
|
1115
1115
|
addBtn.onclick = () => {
|
|
1116
1116
|
const defaultValue = element.default || element.options?.[0]?.value || "";
|
|
1117
1117
|
values.push(defaultValue);
|
|
@@ -2621,7 +2621,7 @@ function renderMultipleColourElement(element, ctx, wrapper, pathKey) {
|
|
|
2621
2621
|
font-size: var(--fb-font-size);
|
|
2622
2622
|
transition: all var(--fb-transition-duration);
|
|
2623
2623
|
`;
|
|
2624
|
-
addBtn.textContent =
|
|
2624
|
+
addBtn.textContent = "+";
|
|
2625
2625
|
addBtn.addEventListener("mouseenter", () => {
|
|
2626
2626
|
addBtn.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
2627
2627
|
});
|
|
@@ -3080,7 +3080,7 @@ function renderMultipleSliderElement(element, ctx, wrapper, pathKey) {
|
|
|
3080
3080
|
font-size: var(--fb-font-size);
|
|
3081
3081
|
transition: all var(--fb-transition-duration);
|
|
3082
3082
|
`;
|
|
3083
|
-
addBtn.textContent =
|
|
3083
|
+
addBtn.textContent = "+";
|
|
3084
3084
|
addBtn.addEventListener("mouseenter", () => {
|
|
3085
3085
|
addBtn.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
3086
3086
|
});
|
|
@@ -3392,15 +3392,10 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3392
3392
|
header.className = "flex justify-between items-center mb-4";
|
|
3393
3393
|
const left = document.createElement("div");
|
|
3394
3394
|
left.className = "flex-1";
|
|
3395
|
-
const right = document.createElement("div");
|
|
3396
|
-
right.className = "flex gap-2";
|
|
3397
3395
|
const itemsWrap = document.createElement("div");
|
|
3398
3396
|
itemsWrap.className = "space-y-4";
|
|
3399
3397
|
containerWrap.appendChild(header);
|
|
3400
3398
|
header.appendChild(left);
|
|
3401
|
-
if (!state.config.readonly) {
|
|
3402
|
-
header.appendChild(right);
|
|
3403
|
-
}
|
|
3404
3399
|
if (!ctx.state.config.readonly) {
|
|
3405
3400
|
const hintsElement = createPrefillHints(element, element.key);
|
|
3406
3401
|
if (hintsElement) {
|
|
@@ -3414,8 +3409,21 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3414
3409
|
const createAddButton = () => {
|
|
3415
3410
|
const add = document.createElement("button");
|
|
3416
3411
|
add.type = "button";
|
|
3417
|
-
add.className = "
|
|
3418
|
-
add.
|
|
3412
|
+
add.className = "add-container-btn mt-2 px-3 py-1 rounded";
|
|
3413
|
+
add.style.cssText = `
|
|
3414
|
+
color: var(--fb-primary-color);
|
|
3415
|
+
border: var(--fb-border-width) solid var(--fb-primary-color);
|
|
3416
|
+
background-color: transparent;
|
|
3417
|
+
font-size: var(--fb-font-size);
|
|
3418
|
+
transition: all var(--fb-transition-duration);
|
|
3419
|
+
`;
|
|
3420
|
+
add.textContent = "+";
|
|
3421
|
+
add.addEventListener("mouseenter", () => {
|
|
3422
|
+
add.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
3423
|
+
});
|
|
3424
|
+
add.addEventListener("mouseleave", () => {
|
|
3425
|
+
add.style.backgroundColor = "transparent";
|
|
3426
|
+
});
|
|
3419
3427
|
add.onclick = () => {
|
|
3420
3428
|
if (countItems() < max) {
|
|
3421
3429
|
const idx = countItems();
|
|
@@ -3445,8 +3453,19 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3445
3453
|
if (!state.config.readonly) {
|
|
3446
3454
|
const rem = document.createElement("button");
|
|
3447
3455
|
rem.type = "button";
|
|
3448
|
-
rem.className = "absolute top-2 right-2
|
|
3449
|
-
rem.
|
|
3456
|
+
rem.className = "absolute top-2 right-2 px-2 py-1 rounded";
|
|
3457
|
+
rem.style.cssText = `
|
|
3458
|
+
color: var(--fb-error-color);
|
|
3459
|
+
background-color: transparent;
|
|
3460
|
+
transition: background-color var(--fb-transition-duration);
|
|
3461
|
+
`;
|
|
3462
|
+
rem.textContent = "\u2715";
|
|
3463
|
+
rem.addEventListener("mouseenter", () => {
|
|
3464
|
+
rem.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
3465
|
+
});
|
|
3466
|
+
rem.addEventListener("mouseleave", () => {
|
|
3467
|
+
rem.style.backgroundColor = "transparent";
|
|
3468
|
+
});
|
|
3450
3469
|
rem.onclick = () => {
|
|
3451
3470
|
item.remove();
|
|
3452
3471
|
updateAddButton();
|
|
@@ -3462,16 +3481,14 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3462
3481
|
};
|
|
3463
3482
|
const updateAddButton = () => {
|
|
3464
3483
|
const currentCount = countItems();
|
|
3465
|
-
const
|
|
3466
|
-
if (
|
|
3467
|
-
|
|
3468
|
-
|
|
3484
|
+
const existingAddBtn = containerWrap.querySelector(".add-container-btn");
|
|
3485
|
+
if (existingAddBtn) {
|
|
3486
|
+
existingAddBtn.disabled = currentCount >= max;
|
|
3487
|
+
existingAddBtn.style.opacity = currentCount >= max ? "0.5" : "1";
|
|
3488
|
+
existingAddBtn.style.pointerEvents = currentCount >= max ? "none" : "auto";
|
|
3469
3489
|
}
|
|
3470
3490
|
left.innerHTML = `<span>${element.label || element.key}</span> <span class="text-sm text-gray-500">(${currentCount}/${max === Infinity ? "\u221E" : max})</span>`;
|
|
3471
3491
|
};
|
|
3472
|
-
if (!state.config.readonly) {
|
|
3473
|
-
right.appendChild(createAddButton());
|
|
3474
|
-
}
|
|
3475
3492
|
if (pre && Array.isArray(pre)) {
|
|
3476
3493
|
pre.forEach((prefillObj, idx) => {
|
|
3477
3494
|
const subCtx = {
|
|
@@ -3500,8 +3517,19 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3500
3517
|
if (!state.config.readonly) {
|
|
3501
3518
|
const rem = document.createElement("button");
|
|
3502
3519
|
rem.type = "button";
|
|
3503
|
-
rem.className = "absolute top-2 right-2
|
|
3504
|
-
rem.
|
|
3520
|
+
rem.className = "absolute top-2 right-2 px-2 py-1 rounded";
|
|
3521
|
+
rem.style.cssText = `
|
|
3522
|
+
color: var(--fb-error-color);
|
|
3523
|
+
background-color: transparent;
|
|
3524
|
+
transition: background-color var(--fb-transition-duration);
|
|
3525
|
+
`;
|
|
3526
|
+
rem.textContent = "\u2715";
|
|
3527
|
+
rem.addEventListener("mouseenter", () => {
|
|
3528
|
+
rem.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
3529
|
+
});
|
|
3530
|
+
rem.addEventListener("mouseleave", () => {
|
|
3531
|
+
rem.style.backgroundColor = "transparent";
|
|
3532
|
+
});
|
|
3505
3533
|
rem.onclick = () => {
|
|
3506
3534
|
item.remove();
|
|
3507
3535
|
updateAddButton();
|
|
@@ -3540,8 +3568,19 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3540
3568
|
item.appendChild(childWrapper);
|
|
3541
3569
|
const rem = document.createElement("button");
|
|
3542
3570
|
rem.type = "button";
|
|
3543
|
-
rem.className = "absolute top-2 right-2
|
|
3544
|
-
rem.
|
|
3571
|
+
rem.className = "absolute top-2 right-2 px-2 py-1 rounded";
|
|
3572
|
+
rem.style.cssText = `
|
|
3573
|
+
color: var(--fb-error-color);
|
|
3574
|
+
background-color: transparent;
|
|
3575
|
+
transition: background-color var(--fb-transition-duration);
|
|
3576
|
+
`;
|
|
3577
|
+
rem.textContent = "\u2715";
|
|
3578
|
+
rem.addEventListener("mouseenter", () => {
|
|
3579
|
+
rem.style.backgroundColor = "var(--fb-background-hover-color)";
|
|
3580
|
+
});
|
|
3581
|
+
rem.addEventListener("mouseleave", () => {
|
|
3582
|
+
rem.style.backgroundColor = "transparent";
|
|
3583
|
+
});
|
|
3545
3584
|
rem.onclick = () => {
|
|
3546
3585
|
if (countItems() > min) {
|
|
3547
3586
|
item.remove();
|
|
@@ -3554,6 +3593,9 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
3554
3593
|
}
|
|
3555
3594
|
}
|
|
3556
3595
|
containerWrap.appendChild(itemsWrap);
|
|
3596
|
+
if (!state.config.readonly) {
|
|
3597
|
+
containerWrap.appendChild(createAddButton());
|
|
3598
|
+
}
|
|
3557
3599
|
updateAddButton();
|
|
3558
3600
|
wrapper.appendChild(containerWrap);
|
|
3559
3601
|
}
|