@dmitryvim/form-builder 0.1.39 → 0.1.41
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/form-builder.js +48 -17
- package/package.json +1 -1
package/dist/form-builder.js
CHANGED
|
@@ -1661,7 +1661,7 @@ function validateForm(skipValidation = false) {
|
|
|
1661
1661
|
if (child.hidden) {
|
|
1662
1662
|
// For hidden child elements, use their default value
|
|
1663
1663
|
itemData[child.key] =
|
|
1664
|
-
child.default !== undefined ? child.default :
|
|
1664
|
+
child.default !== undefined ? child.default : null;
|
|
1665
1665
|
} else {
|
|
1666
1666
|
const childKey = `${fullKey}[${actualIndex}].${child.key}`;
|
|
1667
1667
|
itemData[child.key] = validateElement(
|
|
@@ -1683,7 +1683,7 @@ function validateForm(skipValidation = false) {
|
|
|
1683
1683
|
if (child.hidden) {
|
|
1684
1684
|
// For hidden child elements, use their default value
|
|
1685
1685
|
groupData[child.key] =
|
|
1686
|
-
child.default !== undefined ? child.default :
|
|
1686
|
+
child.default !== undefined ? child.default : null;
|
|
1687
1687
|
} else {
|
|
1688
1688
|
const childKey = `${key}.${child.key}`;
|
|
1689
1689
|
groupData[child.key] = validateElement(
|
|
@@ -1716,7 +1716,7 @@ function validateForm(skipValidation = false) {
|
|
|
1716
1716
|
if (child.hidden) {
|
|
1717
1717
|
// For hidden child elements, use their default value
|
|
1718
1718
|
itemData[child.key] =
|
|
1719
|
-
child.default !== undefined ? child.default :
|
|
1719
|
+
child.default !== undefined ? child.default : null;
|
|
1720
1720
|
} else {
|
|
1721
1721
|
const childKey = `${key}[${i}].${child.key}`;
|
|
1722
1722
|
itemData[child.key] = validateElement(
|
|
@@ -1755,7 +1755,7 @@ function validateForm(skipValidation = false) {
|
|
|
1755
1755
|
if (child.hidden) {
|
|
1756
1756
|
// For hidden child elements, use their default value
|
|
1757
1757
|
containerData[child.key] =
|
|
1758
|
-
child.default !== undefined ? child.default :
|
|
1758
|
+
child.default !== undefined ? child.default : null;
|
|
1759
1759
|
} else {
|
|
1760
1760
|
const childKey = `${key}.${child.key}`;
|
|
1761
1761
|
containerData[child.key] = validateElement(
|
|
@@ -1776,7 +1776,9 @@ function validateForm(skipValidation = false) {
|
|
|
1776
1776
|
state.schema.elements.forEach((element) => {
|
|
1777
1777
|
// Handle hidden elements - use their default value instead of reading from DOM
|
|
1778
1778
|
if (element.hidden) {
|
|
1779
|
-
|
|
1779
|
+
// Use null as default for consistency with empty field behavior
|
|
1780
|
+
// File fields, number fields, and other non-text fields return null when empty
|
|
1781
|
+
data[element.key] = element.default !== undefined ? element.default : null;
|
|
1780
1782
|
} else {
|
|
1781
1783
|
data[element.key] = validateElement(element, { path: "" });
|
|
1782
1784
|
}
|
|
@@ -2658,7 +2660,7 @@ function addPrefillFilesToIndex(initialFiles) {
|
|
|
2658
2660
|
if (!state.resourceIndex.has(resourceId)) {
|
|
2659
2661
|
// Extract filename from URL/path
|
|
2660
2662
|
const filename = resourceId.split("/").pop() || "file";
|
|
2661
|
-
// Determine file type from extension
|
|
2663
|
+
// Determine file type from extension (excluding PSD from image types)
|
|
2662
2664
|
const extension = filename.split(".").pop()?.toLowerCase();
|
|
2663
2665
|
const fileType =
|
|
2664
2666
|
extension && ["jpg", "jpeg", "png", "gif", "webp"].includes(extension)
|
|
@@ -3079,19 +3081,31 @@ function renderFilePreviewReadonly(resourceId, fileName) {
|
|
|
3079
3081
|
const actualFileName =
|
|
3080
3082
|
fileName || meta?.name || resourceId.split("/").pop() || "file";
|
|
3081
3083
|
|
|
3084
|
+
// Determine if this looks like a PSD file (should be treated as download, not preview)
|
|
3085
|
+
const isPSD = actualFileName.toLowerCase().match(/\.psd$/);
|
|
3086
|
+
|
|
3082
3087
|
// Individual file result container
|
|
3083
3088
|
const fileResult = document.createElement("div");
|
|
3084
|
-
fileResult.className = "space-y-3";
|
|
3089
|
+
fileResult.className = isPSD ? "space-y-2" : "space-y-3";
|
|
3085
3090
|
|
|
3086
|
-
//
|
|
3091
|
+
// Preview container - compact for PSD files, large for others
|
|
3087
3092
|
const previewContainer = document.createElement("div");
|
|
3088
|
-
|
|
3089
|
-
|
|
3093
|
+
if (isPSD) {
|
|
3094
|
+
// Compact container for PSD files
|
|
3095
|
+
previewContainer.className =
|
|
3096
|
+
"bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity flex items-center p-3 max-w-sm";
|
|
3097
|
+
} else {
|
|
3098
|
+
// Large container for images/videos
|
|
3099
|
+
previewContainer.className =
|
|
3100
|
+
"bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity";
|
|
3101
|
+
}
|
|
3090
3102
|
|
|
3091
|
-
// Determine if this looks like an image file
|
|
3103
|
+
// Determine if this looks like an image file (excluding PSD files)
|
|
3092
3104
|
const isImage =
|
|
3093
|
-
|
|
3094
|
-
|
|
3105
|
+
!isPSD && (
|
|
3106
|
+
meta?.type?.startsWith("image/") ||
|
|
3107
|
+
actualFileName.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)
|
|
3108
|
+
);
|
|
3095
3109
|
|
|
3096
3110
|
// Determine if this looks like a video file
|
|
3097
3111
|
const isVideo =
|
|
@@ -3148,13 +3162,30 @@ function renderFilePreviewReadonly(resourceId, fileName) {
|
|
|
3148
3162
|
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🎥</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
3149
3163
|
}
|
|
3150
3164
|
} else {
|
|
3151
|
-
// Other file types
|
|
3152
|
-
|
|
3165
|
+
// Other file types - special handling for PSD files
|
|
3166
|
+
const fileIcon = isPSD ? "🎨" : "📁";
|
|
3167
|
+
const fileDescription = isPSD ? "PSD File" : "Document";
|
|
3168
|
+
|
|
3169
|
+
if (isPSD) {
|
|
3170
|
+
// Compact horizontal layout for PSD files
|
|
3171
|
+
previewContainer.innerHTML = `
|
|
3172
|
+
<div class="flex items-center space-x-3">
|
|
3173
|
+
<div class="text-3xl text-gray-400">${fileIcon}</div>
|
|
3174
|
+
<div class="flex-1 min-w-0">
|
|
3175
|
+
<div class="text-sm font-medium text-gray-900 truncate">${actualFileName}</div>
|
|
3176
|
+
<div class="text-xs text-gray-500">${fileDescription}</div>
|
|
3177
|
+
</div>
|
|
3178
|
+
</div>
|
|
3179
|
+
`;
|
|
3180
|
+
} else {
|
|
3181
|
+
// Large centered layout for other documents
|
|
3182
|
+
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">${fileIcon}</div><div class="text-sm">${actualFileName}</div><div class="text-xs text-gray-500 mt-1">${fileDescription}</div></div></div>`;
|
|
3183
|
+
}
|
|
3153
3184
|
}
|
|
3154
3185
|
|
|
3155
|
-
// File name
|
|
3186
|
+
// File name (only show for non-PSD files since PSD files show name inline)
|
|
3156
3187
|
const fileNameElement = document.createElement("p");
|
|
3157
|
-
fileNameElement.className = "text-sm font-medium text-gray-900 text-center";
|
|
3188
|
+
fileNameElement.className = isPSD ? "hidden" : "text-sm font-medium text-gray-900 text-center";
|
|
3158
3189
|
fileNameElement.textContent = actualFileName;
|
|
3159
3190
|
|
|
3160
3191
|
// Download button
|