@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/esm/index.js CHANGED
@@ -891,10 +891,10 @@ function updateTextareaField(element, fieldPath, value, context) {
891
891
  }
892
892
 
893
893
  // src/components/number.ts
894
- function createNumberCounter(element, input) {
895
- const counter = document.createElement("span");
896
- counter.className = "number-counter";
897
- counter.style.cssText = `
894
+ function createNumberRangeHint(element, input) {
895
+ const hint = document.createElement("span");
896
+ hint.className = "number-range-hint";
897
+ hint.style.cssText = `
898
898
  position: absolute;
899
899
  top: 50%;
900
900
  transform: translateY(-50%);
@@ -905,38 +905,30 @@ function createNumberCounter(element, input) {
905
905
  background: var(--fb-background-color);
906
906
  padding: 0 4px;
907
907
  `;
908
- const updateCounter = () => {
908
+ const min = element.min;
909
+ const max = element.max;
910
+ let rangeText = "";
911
+ if (min != null && max != null) {
912
+ rangeText = `${min} \u2013 ${max}`;
913
+ } else if (max != null) {
914
+ rangeText = `\u2264${max}`;
915
+ } else if (min != null) {
916
+ rangeText = `\u2265${min}`;
917
+ }
918
+ hint.textContent = rangeText;
919
+ const updateColor = () => {
909
920
  const val = input.value ? parseFloat(input.value) : null;
910
- const min = element.min;
911
- const max = element.max;
912
- if (min == null && max == null) {
913
- counter.textContent = "";
914
- return;
915
- }
916
- if (val == null || min != null && val < min) {
917
- if (min != null && max != null) {
918
- counter.textContent = `${min}-${max}`;
919
- } else if (max != null) {
920
- counter.textContent = `\u2264${max}`;
921
- } else if (min != null) {
922
- counter.textContent = `\u2265${min}`;
923
- }
924
- counter.style.color = "var(--fb-text-secondary-color)";
925
- } else if (max != null && val > max) {
926
- counter.textContent = `${val}/${max}`;
927
- counter.style.color = "var(--fb-error-color)";
921
+ if (val != null) {
922
+ const belowMin = min != null && val < min;
923
+ const aboveMax = max != null && val > max;
924
+ hint.style.color = belowMin || aboveMax ? "var(--fb-error-color)" : "var(--fb-text-secondary-color)";
928
925
  } else {
929
- if (max != null) {
930
- counter.textContent = `${val}/${max}`;
931
- } else {
932
- counter.textContent = `${val}`;
933
- }
934
- counter.style.color = "var(--fb-text-secondary-color)";
926
+ hint.style.color = "var(--fb-text-secondary-color)";
935
927
  }
936
928
  };
937
- input.addEventListener("input", updateCounter);
938
- updateCounter();
939
- return counter;
929
+ input.addEventListener("input", updateColor);
930
+ updateColor();
931
+ return hint;
940
932
  }
941
933
  function renderNumberElement(element, ctx, wrapper, pathKey) {
942
934
  const state = ctx.state;
@@ -963,7 +955,7 @@ function renderNumberElement(element, ctx, wrapper, pathKey) {
963
955
  }
964
956
  inputWrapper.appendChild(numberInput);
965
957
  if (!state.config.readonly && (element.min != null || element.max != null)) {
966
- const counter = createNumberCounter(element, numberInput);
958
+ const counter = createNumberRangeHint(element, numberInput);
967
959
  inputWrapper.appendChild(counter);
968
960
  }
969
961
  wrapper.appendChild(inputWrapper);
@@ -1014,7 +1006,7 @@ function renderMultipleNumberElement(element, ctx, wrapper, pathKey) {
1014
1006
  }
1015
1007
  inputContainer.appendChild(numberInput);
1016
1008
  if (!state.config.readonly && (element.min != null || element.max != null)) {
1017
- const counter = createNumberCounter(element, numberInput);
1009
+ const counter = createNumberRangeHint(element, numberInput);
1018
1010
  inputContainer.appendChild(counter);
1019
1011
  }
1020
1012
  itemWrapper.appendChild(inputContainer);
@@ -1575,8 +1567,7 @@ function renderLocalVideoPreview(container, file, videoType, resourceId, state,
1575
1567
  }
1576
1568
  newContainer.innerHTML = `
1577
1569
  <div class="relative group h-full">
1578
- <video class="w-full h-full object-contain" controls preload="auto" muted>
1579
- <source src="${videoUrl}" type="${videoType}">
1570
+ <video class="w-full h-full object-contain" controls preload="auto" muted src="${videoUrl}">
1580
1571
  ${escapeHtml(t("videoNotSupported", state))}
1581
1572
  </video>
1582
1573
  <div class="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity z-10 flex gap-1">
@@ -1637,16 +1628,13 @@ function handleVideoDelete(container, resourceId, state, deps) {
1637
1628
  </div>
1638
1629
  `;
1639
1630
  }
1640
- function renderUploadedVideoPreview(container, thumbnailUrl, videoType, state) {
1631
+ function renderUploadedVideoPreview(container, thumbnailUrl, _videoType, state) {
1641
1632
  const video = document.createElement("video");
1642
1633
  video.className = "w-full h-full object-contain";
1643
1634
  video.controls = true;
1644
1635
  video.preload = "metadata";
1645
1636
  video.muted = true;
1646
- const source = document.createElement("source");
1647
- source.src = thumbnailUrl;
1648
- source.type = videoType;
1649
- video.appendChild(source);
1637
+ video.src = thumbnailUrl;
1650
1638
  video.appendChild(
1651
1639
  document.createTextNode(t("videoNotSupported", state))
1652
1640
  );
@@ -1796,8 +1784,7 @@ async function renderFilePreviewReadonly(resourceId, state, fileName) {
1796
1784
  if (videoUrl) {
1797
1785
  previewContainer.innerHTML = `
1798
1786
  <div class="relative group">
1799
- <video class="w-full h-auto" controls preload="auto" muted>
1800
- <source src="${videoUrl}" type="${meta?.type || "video/mp4"}">
1787
+ <video class="w-full h-auto" controls preload="auto" muted src="${videoUrl}">
1801
1788
  ${escapeHtml(t("videoNotSupported", state))}
1802
1789
  </video>
1803
1790
  <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">
@@ -2019,8 +2006,7 @@ async function renderThumbnailForResource(slot, rid, meta, state) {
2019
2006
  const videoUrl = URL.createObjectURL(meta.file);
2020
2007
  slot.innerHTML = `
2021
2008
  <div class="relative group h-full w-full">
2022
- <video class="w-full h-full object-contain" preload="metadata" muted>
2023
- <source src="${videoUrl}" type="${meta.type}">
2009
+ <video class="w-full h-full object-contain" preload="metadata" muted src="${videoUrl}">
2024
2010
  </video>
2025
2011
  <div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
2026
2012
  <div class="bg-white bg-opacity-90 rounded-full p-1">
@@ -2037,8 +2023,7 @@ async function renderThumbnailForResource(slot, rid, meta, state) {
2037
2023
  if (videoUrl) {
2038
2024
  slot.innerHTML = `
2039
2025
  <div class="relative group h-full w-full">
2040
- <video class="w-full h-full object-contain" preload="metadata" muted>
2041
- <source src="${videoUrl}" type="${meta.type}">
2026
+ <video class="w-full h-full object-contain" preload="metadata" muted src="${videoUrl}">
2042
2027
  </video>
2043
2028
  <div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
2044
2029
  <div class="bg-white bg-opacity-90 rounded-full p-1">