@dmitryvim/form-builder 0.2.13 → 0.2.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/browser/formbuilder.min.js +34 -38
- package/dist/browser/{formbuilder.v0.2.13.min.js → formbuilder.v0.2.15.min.js} +34 -38
- package/dist/cjs/index.cjs +32 -47
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +32 -47
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +34 -38
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -902,10 +902,10 @@ function updateTextareaField(element, fieldPath, value, context) {
|
|
|
902
902
|
}
|
|
903
903
|
|
|
904
904
|
// src/components/number.ts
|
|
905
|
-
function
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
|
|
905
|
+
function createNumberRangeHint(element, input) {
|
|
906
|
+
const hint = document.createElement("span");
|
|
907
|
+
hint.className = "number-range-hint";
|
|
908
|
+
hint.style.cssText = `
|
|
909
909
|
position: absolute;
|
|
910
910
|
top: 50%;
|
|
911
911
|
transform: translateY(-50%);
|
|
@@ -916,38 +916,30 @@ function createNumberCounter(element, input) {
|
|
|
916
916
|
background: var(--fb-background-color);
|
|
917
917
|
padding: 0 4px;
|
|
918
918
|
`;
|
|
919
|
-
const
|
|
919
|
+
const min = element.min;
|
|
920
|
+
const max = element.max;
|
|
921
|
+
let rangeText = "";
|
|
922
|
+
if (min != null && max != null) {
|
|
923
|
+
rangeText = `${min} \u2013 ${max}`;
|
|
924
|
+
} else if (max != null) {
|
|
925
|
+
rangeText = `\u2264${max}`;
|
|
926
|
+
} else if (min != null) {
|
|
927
|
+
rangeText = `\u2265${min}`;
|
|
928
|
+
}
|
|
929
|
+
hint.textContent = rangeText;
|
|
930
|
+
const updateColor = () => {
|
|
920
931
|
const val = input.value ? parseFloat(input.value) : null;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
|
-
if (val == null || min != null && val < min) {
|
|
928
|
-
if (min != null && max != null) {
|
|
929
|
-
counter.textContent = `${min}-${max}`;
|
|
930
|
-
} else if (max != null) {
|
|
931
|
-
counter.textContent = `\u2264${max}`;
|
|
932
|
-
} else if (min != null) {
|
|
933
|
-
counter.textContent = `\u2265${min}`;
|
|
934
|
-
}
|
|
935
|
-
counter.style.color = "var(--fb-text-secondary-color)";
|
|
936
|
-
} else if (max != null && val > max) {
|
|
937
|
-
counter.textContent = `${val}/${max}`;
|
|
938
|
-
counter.style.color = "var(--fb-error-color)";
|
|
932
|
+
if (val != null) {
|
|
933
|
+
const belowMin = min != null && val < min;
|
|
934
|
+
const aboveMax = max != null && val > max;
|
|
935
|
+
hint.style.color = belowMin || aboveMax ? "var(--fb-error-color)" : "var(--fb-text-secondary-color)";
|
|
939
936
|
} else {
|
|
940
|
-
|
|
941
|
-
counter.textContent = `${val}/${max}`;
|
|
942
|
-
} else {
|
|
943
|
-
counter.textContent = `${val}`;
|
|
944
|
-
}
|
|
945
|
-
counter.style.color = "var(--fb-text-secondary-color)";
|
|
937
|
+
hint.style.color = "var(--fb-text-secondary-color)";
|
|
946
938
|
}
|
|
947
939
|
};
|
|
948
|
-
input.addEventListener("input",
|
|
949
|
-
|
|
950
|
-
return
|
|
940
|
+
input.addEventListener("input", updateColor);
|
|
941
|
+
updateColor();
|
|
942
|
+
return hint;
|
|
951
943
|
}
|
|
952
944
|
function renderNumberElement(element, ctx, wrapper, pathKey) {
|
|
953
945
|
const state = ctx.state;
|
|
@@ -974,7 +966,7 @@ function renderNumberElement(element, ctx, wrapper, pathKey) {
|
|
|
974
966
|
}
|
|
975
967
|
inputWrapper.appendChild(numberInput);
|
|
976
968
|
if (!state.config.readonly && (element.min != null || element.max != null)) {
|
|
977
|
-
const counter =
|
|
969
|
+
const counter = createNumberRangeHint(element, numberInput);
|
|
978
970
|
inputWrapper.appendChild(counter);
|
|
979
971
|
}
|
|
980
972
|
wrapper.appendChild(inputWrapper);
|
|
@@ -1026,7 +1018,7 @@ function renderMultipleNumberElement(element, ctx, wrapper, pathKey) {
|
|
|
1026
1018
|
}
|
|
1027
1019
|
inputContainer.appendChild(numberInput);
|
|
1028
1020
|
if (!state.config.readonly && (element.min != null || element.max != null)) {
|
|
1029
|
-
const counter =
|
|
1021
|
+
const counter = createNumberRangeHint(element, numberInput);
|
|
1030
1022
|
inputContainer.appendChild(counter);
|
|
1031
1023
|
}
|
|
1032
1024
|
itemWrapper.appendChild(inputContainer);
|
|
@@ -1597,8 +1589,7 @@ function renderLocalVideoPreview(container, file, videoType, resourceId, state,
|
|
|
1597
1589
|
}
|
|
1598
1590
|
newContainer.innerHTML = `
|
|
1599
1591
|
<div class="relative group h-full">
|
|
1600
|
-
<video class="w-full h-full object-contain" controls preload="auto" muted>
|
|
1601
|
-
<source src="${videoUrl}" type="${videoType}">
|
|
1592
|
+
<video class="w-full h-full object-contain" controls preload="auto" muted src="${videoUrl}">
|
|
1602
1593
|
${escapeHtml(t("videoNotSupported", state))}
|
|
1603
1594
|
</video>
|
|
1604
1595
|
<div class="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity z-10 flex gap-1">
|
|
@@ -1660,16 +1651,13 @@ function handleVideoDelete(container, resourceId, state, deps) {
|
|
|
1660
1651
|
</div>
|
|
1661
1652
|
`;
|
|
1662
1653
|
}
|
|
1663
|
-
function renderUploadedVideoPreview(container, thumbnailUrl,
|
|
1654
|
+
function renderUploadedVideoPreview(container, thumbnailUrl, _videoType, state) {
|
|
1664
1655
|
const video = document.createElement("video");
|
|
1665
1656
|
video.className = "w-full h-full object-contain";
|
|
1666
1657
|
video.controls = true;
|
|
1667
1658
|
video.preload = "metadata";
|
|
1668
1659
|
video.muted = true;
|
|
1669
|
-
|
|
1670
|
-
source.src = thumbnailUrl;
|
|
1671
|
-
source.type = videoType;
|
|
1672
|
-
video.appendChild(source);
|
|
1660
|
+
video.src = thumbnailUrl;
|
|
1673
1661
|
video.appendChild(
|
|
1674
1662
|
document.createTextNode(t("videoNotSupported", state))
|
|
1675
1663
|
);
|
|
@@ -1821,8 +1809,7 @@ async function renderFilePreviewReadonly(resourceId, state, fileName) {
|
|
|
1821
1809
|
if (videoUrl) {
|
|
1822
1810
|
previewContainer.innerHTML = `
|
|
1823
1811
|
<div class="relative group">
|
|
1824
|
-
<video class="w-full h-auto" controls preload="auto" muted>
|
|
1825
|
-
<source src="${videoUrl}" type="${(meta == null ? void 0 : meta.type) || "video/mp4"}">
|
|
1812
|
+
<video class="w-full h-auto" controls preload="auto" muted src="${videoUrl}">
|
|
1826
1813
|
${escapeHtml(t("videoNotSupported", state))}
|
|
1827
1814
|
</video>
|
|
1828
1815
|
<div class="absolute inset-0 bg-black bg-opacity-20 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none">
|
|
@@ -2046,8 +2033,7 @@ async function renderThumbnailForResource(slot, rid, meta, state) {
|
|
|
2046
2033
|
const videoUrl = URL.createObjectURL(meta.file);
|
|
2047
2034
|
slot.innerHTML = `
|
|
2048
2035
|
<div class="relative group h-full w-full">
|
|
2049
|
-
<video class="w-full h-full object-contain" preload="metadata" muted>
|
|
2050
|
-
<source src="${videoUrl}" type="${meta.type}">
|
|
2036
|
+
<video class="w-full h-full object-contain" preload="metadata" muted src="${videoUrl}">
|
|
2051
2037
|
</video>
|
|
2052
2038
|
<div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
|
|
2053
2039
|
<div class="bg-white bg-opacity-90 rounded-full p-1">
|
|
@@ -2064,8 +2050,7 @@ async function renderThumbnailForResource(slot, rid, meta, state) {
|
|
|
2064
2050
|
if (videoUrl) {
|
|
2065
2051
|
slot.innerHTML = `
|
|
2066
2052
|
<div class="relative group h-full w-full">
|
|
2067
|
-
<video class="w-full h-full object-contain" preload="metadata" muted>
|
|
2068
|
-
<source src="${videoUrl}" type="${meta.type}">
|
|
2053
|
+
<video class="w-full h-full object-contain" preload="metadata" muted src="${videoUrl}">
|
|
2069
2054
|
</video>
|
|
2070
2055
|
<div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
|
|
2071
2056
|
<div class="bg-white bg-opacity-90 rounded-full p-1">
|