@dmitryvim/form-builder 0.4.0 → 0.5.1
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 +106 -114
- package/dist/browser/{formbuilder.v0.4.0.min.js → formbuilder.v0.5.1.min.js} +106 -114
- package/dist/cjs/index.cjs +46 -125
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +46 -125
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +106 -114
- package/dist/types/components/file/render-edit.d.ts +0 -4
- package/dist/types/types/config.d.ts +6 -3
- package/dist/types/types/schema.d.ts +9 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -419,6 +419,20 @@ function ensureThemingHooks(doc) {
|
|
|
419
419
|
min-height: var(--fb-slide-card-min-height);
|
|
420
420
|
padding: var(--fb-slide-card-padding);
|
|
421
421
|
}
|
|
422
|
+
/* Slides-mode outer grid. Responsive by design \u2014 column count derives from
|
|
423
|
+
container width and --fb-slide-min-width, not from a schema "columns" prop.
|
|
424
|
+
min(100%, ...) prevents the card from overflowing a narrow container.
|
|
425
|
+
Override per-form: set --fb-slide-min-width / --fb-slides-gap on any
|
|
426
|
+
ancestor (theme, host CSS, or the form root). */
|
|
427
|
+
.fb-container-slides {
|
|
428
|
+
display: grid;
|
|
429
|
+
gap: var(--fb-slides-gap, 14px);
|
|
430
|
+
align-items: stretch;
|
|
431
|
+
grid-template-columns: repeat(
|
|
432
|
+
auto-fit,
|
|
433
|
+
minmax(min(100%, var(--fb-slide-min-width, 280px)), 1fr)
|
|
434
|
+
);
|
|
435
|
+
}
|
|
422
436
|
[data-fb-label-row] > label {
|
|
423
437
|
font-size: var(--fb-label-section-font-size);
|
|
424
438
|
letter-spacing: var(--fb-label-section-letter-spacing);
|
|
@@ -3029,34 +3043,12 @@ function ensureFileStyles() {
|
|
|
3029
3043
|
padding: 6px;
|
|
3030
3044
|
}
|
|
3031
3045
|
|
|
3032
|
-
/* \u2500\u2500\u2500
|
|
3033
|
-
.fb-
|
|
3046
|
+
/* \u2500\u2500\u2500 Clear-all row below multi grid \u2500\u2500\u2500 */
|
|
3047
|
+
.fb-clear-all-row {
|
|
3034
3048
|
margin-top: 10px;
|
|
3035
3049
|
display: flex;
|
|
3036
3050
|
align-items: center;
|
|
3037
|
-
justify-content:
|
|
3038
|
-
gap: 8px;
|
|
3039
|
-
flex-wrap: wrap;
|
|
3040
|
-
}
|
|
3041
|
-
.fb-meta-text {
|
|
3042
|
-
font-size: 12px;
|
|
3043
|
-
color: #94a3b8;
|
|
3044
|
-
display: flex;
|
|
3045
|
-
align-items: center;
|
|
3046
|
-
gap: 8px;
|
|
3047
|
-
flex-wrap: wrap;
|
|
3048
|
-
}
|
|
3049
|
-
.fb-meta-dot {
|
|
3050
|
-
width: 4px;
|
|
3051
|
-
height: 4px;
|
|
3052
|
-
border-radius: 50%;
|
|
3053
|
-
background: #cbd5e1;
|
|
3054
|
-
flex-shrink: 0;
|
|
3055
|
-
}
|
|
3056
|
-
.fb-meta-mono {
|
|
3057
|
-
font-family: ui-monospace, 'JetBrains Mono', monospace;
|
|
3058
|
-
font-size: 11px;
|
|
3059
|
-
letter-spacing: -0.02em;
|
|
3051
|
+
justify-content: flex-end;
|
|
3060
3052
|
}
|
|
3061
3053
|
.fb-clear-all-btn {
|
|
3062
3054
|
font-size: 12px;
|
|
@@ -4846,58 +4838,22 @@ function buildPlaceholderTile(isDragOver = false) {
|
|
|
4846
4838
|
div.className = `fb-multi-placeholder fb-checker${isDragOver ? " fb-drag-over" : ""}`;
|
|
4847
4839
|
return div;
|
|
4848
4840
|
}
|
|
4849
|
-
function
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
fmtSpan.className = "fb-meta-mono";
|
|
4866
|
-
fmtSpan.textContent = exts.map((e) => e.toUpperCase()).join(", ");
|
|
4867
|
-
metaText.appendChild(fmtSpan);
|
|
4868
|
-
metaText.appendChild(buildMetaDot());
|
|
4869
|
-
}
|
|
4870
|
-
const countSpan = document.createElement("span");
|
|
4871
|
-
if (maxCount < Infinity) {
|
|
4872
|
-
countSpan.textContent = t("fileCountWithMax", state, {
|
|
4873
|
-
count: ridCount,
|
|
4874
|
-
max: maxCount
|
|
4875
|
-
});
|
|
4876
|
-
} else {
|
|
4877
|
-
const countKey = ridCount === 1 ? "fileCountSingle" : "fileCountPlural";
|
|
4878
|
-
countSpan.textContent = t(countKey, state, { count: ridCount });
|
|
4879
|
-
}
|
|
4880
|
-
metaText.appendChild(countSpan);
|
|
4881
|
-
line.appendChild(metaText);
|
|
4882
|
-
if (canClearAll && ridCount > 1) {
|
|
4883
|
-
const clearBtn = document.createElement("button");
|
|
4884
|
-
clearBtn.type = "button";
|
|
4885
|
-
clearBtn.className = "fb-clear-all-btn";
|
|
4886
|
-
clearBtn.textContent = t("clearAll", state);
|
|
4887
|
-
clearBtn.onclick = (e) => {
|
|
4888
|
-
e.stopPropagation();
|
|
4889
|
-
if (window.confirm(t("clearAll", state) + "?")) {
|
|
4890
|
-
onClearAll();
|
|
4891
|
-
}
|
|
4892
|
-
};
|
|
4893
|
-
line.appendChild(clearBtn);
|
|
4894
|
-
}
|
|
4895
|
-
return line;
|
|
4896
|
-
}
|
|
4897
|
-
function buildMetaDot() {
|
|
4898
|
-
const dot = document.createElement("span");
|
|
4899
|
-
dot.className = "fb-meta-dot";
|
|
4900
|
-
return dot;
|
|
4841
|
+
function buildClearAllRow(state, ridCount, onClearAll) {
|
|
4842
|
+
if (ridCount <= 1) return null;
|
|
4843
|
+
const row = document.createElement("div");
|
|
4844
|
+
row.className = "fb-clear-all-row";
|
|
4845
|
+
const clearBtn = document.createElement("button");
|
|
4846
|
+
clearBtn.type = "button";
|
|
4847
|
+
clearBtn.className = "fb-clear-all-btn";
|
|
4848
|
+
clearBtn.textContent = t("clearAll", state);
|
|
4849
|
+
clearBtn.onclick = (e) => {
|
|
4850
|
+
e.stopPropagation();
|
|
4851
|
+
if (window.confirm(t("clearAll", state) + "?")) {
|
|
4852
|
+
onClearAll();
|
|
4853
|
+
}
|
|
4854
|
+
};
|
|
4855
|
+
row.appendChild(clearBtn);
|
|
4856
|
+
return row;
|
|
4901
4857
|
}
|
|
4902
4858
|
var gridResizeObservers = /* @__PURE__ */ new WeakMap();
|
|
4903
4859
|
function disposePlaceholdersForUpload(container) {
|
|
@@ -4917,7 +4873,6 @@ function renderResourcePills(opts) {
|
|
|
4917
4873
|
maxCount,
|
|
4918
4874
|
isReadonly = false,
|
|
4919
4875
|
onLibraryPick,
|
|
4920
|
-
element,
|
|
4921
4876
|
onClearAll,
|
|
4922
4877
|
openPicker: openPickerProp
|
|
4923
4878
|
} = opts;
|
|
@@ -5061,17 +5016,9 @@ function renderResourcePills(opts) {
|
|
|
5061
5016
|
}
|
|
5062
5017
|
}
|
|
5063
5018
|
});
|
|
5064
|
-
if (
|
|
5065
|
-
const
|
|
5066
|
-
|
|
5067
|
-
element,
|
|
5068
|
-
ridList.length,
|
|
5069
|
-
effectiveMax,
|
|
5070
|
-
Boolean(onClearAll),
|
|
5071
|
-
onClearAll ?? (() => {
|
|
5072
|
-
})
|
|
5073
|
-
);
|
|
5074
|
-
container.appendChild(metaLine);
|
|
5019
|
+
if (onClearAll) {
|
|
5020
|
+
const row = buildClearAllRow(state, ridList.length, onClearAll);
|
|
5021
|
+
if (row) container.appendChild(row);
|
|
5075
5022
|
}
|
|
5076
5023
|
}
|
|
5077
5024
|
function renderFileElementEdit(element, ctx, wrapper, pathKey) {
|
|
@@ -5295,7 +5242,6 @@ function setupMultiFileEditMode(element, ctx, wrapper, pathKey, maxFiles) {
|
|
|
5295
5242
|
maxCount: maxFiles < Infinity ? maxFiles : void 0,
|
|
5296
5243
|
isReadonly: currentlyReadonly,
|
|
5297
5244
|
onLibraryPick: currentlyReadonly ? null : onLibraryPick,
|
|
5298
|
-
element,
|
|
5299
5245
|
onClearAll: currentlyReadonly ? void 0 : () => {
|
|
5300
5246
|
for (const rid of initialFiles) {
|
|
5301
5247
|
releaseLocalFileUrl(state.resourceIndex.get(rid)?.file);
|
|
@@ -6790,10 +6736,7 @@ function renderSingleContainerElement(element, ctx, wrapper, pathKey) {
|
|
|
6790
6736
|
containerWrap.appendChild(itemsWrap);
|
|
6791
6737
|
wrapper.appendChild(containerWrap);
|
|
6792
6738
|
}
|
|
6793
|
-
function getChildWrapperClass(
|
|
6794
|
-
if (isSlides) {
|
|
6795
|
-
return "fb-row";
|
|
6796
|
-
}
|
|
6739
|
+
function getChildWrapperClass(columns) {
|
|
6797
6740
|
const cols = columns || 1;
|
|
6798
6741
|
return cols === 1 ? "fb-row" : `grid grid-cols-${cols} gap-2`;
|
|
6799
6742
|
}
|
|
@@ -6838,9 +6781,6 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
6838
6781
|
const isSlides = element.displayMode === "slides";
|
|
6839
6782
|
if (isSlides) {
|
|
6840
6783
|
itemsWrap.className = "fb-container-slides";
|
|
6841
|
-
const slideCols = element.columns;
|
|
6842
|
-
const gridTemplateColumns = typeof slideCols === "number" && slideCols > 0 ? `repeat(${slideCols}, 1fr)` : "repeat(auto-fit, minmax(280px, 1fr))";
|
|
6843
|
-
itemsWrap.style.cssText = `display:grid;grid-template-columns:${gridTemplateColumns};gap:var(--fb-slides-gap, 14px);align-items:start;`;
|
|
6844
6784
|
} else {
|
|
6845
6785
|
itemsWrap.className = "fb-row";
|
|
6846
6786
|
}
|
|
@@ -6876,7 +6816,9 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
6876
6816
|
item.setAttribute("data-fb-slide-card", "");
|
|
6877
6817
|
}
|
|
6878
6818
|
const childWrapper = document.createElement("div");
|
|
6879
|
-
childWrapper.className = getChildWrapperClass(
|
|
6819
|
+
childWrapper.className = getChildWrapperClass(
|
|
6820
|
+
isSlides ? void 0 : element.columns
|
|
6821
|
+
);
|
|
6880
6822
|
element.elements.forEach((child) => {
|
|
6881
6823
|
if (child.type !== "markdown" && (child.hidden || child.type === "hidden")) {
|
|
6882
6824
|
childWrapper.appendChild(
|
|
@@ -6942,16 +6884,9 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
6942
6884
|
item.setAttribute("data-fb-slide-card", "");
|
|
6943
6885
|
}
|
|
6944
6886
|
const childWrapper = document.createElement("div");
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
const columns = element.columns || 1;
|
|
6949
|
-
if (columns === 1) {
|
|
6950
|
-
childWrapper.className = "fb-row";
|
|
6951
|
-
} else {
|
|
6952
|
-
childWrapper.className = `grid grid-cols-${columns} gap-2`;
|
|
6953
|
-
}
|
|
6954
|
-
}
|
|
6887
|
+
childWrapper.className = getChildWrapperClass(
|
|
6888
|
+
isSlides ? void 0 : element.columns
|
|
6889
|
+
);
|
|
6955
6890
|
element.elements.forEach((child) => {
|
|
6956
6891
|
if (child.type !== "markdown" && (child.hidden || child.type === "hidden")) {
|
|
6957
6892
|
const prefillVal = prefillObj?.[child.key] ?? ("default" in child ? child.default : null) ?? null;
|
|
@@ -6989,16 +6924,9 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
6989
6924
|
item.setAttribute("data-fb-slide-card", "");
|
|
6990
6925
|
}
|
|
6991
6926
|
const childWrapper = document.createElement("div");
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
const columns = element.columns || 1;
|
|
6996
|
-
if (columns === 1) {
|
|
6997
|
-
childWrapper.className = "fb-row";
|
|
6998
|
-
} else {
|
|
6999
|
-
childWrapper.className = `grid grid-cols-${columns} gap-2`;
|
|
7000
|
-
}
|
|
7001
|
-
}
|
|
6927
|
+
childWrapper.className = getChildWrapperClass(
|
|
6928
|
+
isSlides ? void 0 : element.columns
|
|
6929
|
+
);
|
|
7002
6930
|
element.elements.forEach((child) => {
|
|
7003
6931
|
if (child.type !== "markdown" && (child.hidden || child.type === "hidden")) {
|
|
7004
6932
|
childWrapper.appendChild(
|
|
@@ -7027,7 +6955,6 @@ function renderMultipleContainerElement(element, ctx, wrapper, _pathKey) {
|
|
|
7027
6955
|
containerWrap.appendChild(itemsWrap);
|
|
7028
6956
|
if (!containerIsReadonly) {
|
|
7029
6957
|
if (isSlides) {
|
|
7030
|
-
itemsWrap.style.alignItems = "stretch";
|
|
7031
6958
|
const handle = createSlideAddTile(handleAddItem, {
|
|
7032
6959
|
label: element.addLabel
|
|
7033
6960
|
});
|
|
@@ -10742,9 +10669,6 @@ var defaultConfig = {
|
|
|
10742
10669
|
hintRequired: "Required",
|
|
10743
10670
|
hintOptional: "Optional",
|
|
10744
10671
|
hintPattern: "Format: {pattern}",
|
|
10745
|
-
fileCountSingle: "{count} file",
|
|
10746
|
-
fileCountPlural: "{count} files",
|
|
10747
|
-
fileCountWithMax: "{count} / {max} files",
|
|
10748
10672
|
fileCountRange: "({min}-{max})",
|
|
10749
10673
|
uploadingFile: "Uploading\u2026",
|
|
10750
10674
|
filesCounter: "{count}/{max}",
|
|
@@ -10818,9 +10742,6 @@ var defaultConfig = {
|
|
|
10818
10742
|
hintRequired: "\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",
|
|
10819
10743
|
hintOptional: "\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",
|
|
10820
10744
|
hintPattern: "\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",
|
|
10821
|
-
fileCountSingle: "{count} \u0444\u0430\u0439\u043B",
|
|
10822
|
-
fileCountPlural: "{count} \u0444\u0430\u0439\u043B\u043E\u0432",
|
|
10823
|
-
fileCountWithMax: "{count} / {max} \u0444\u0430\u0439\u043B\u043E\u0432",
|
|
10824
10745
|
fileCountRange: "({min}-{max})",
|
|
10825
10746
|
uploadingFile: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",
|
|
10826
10747
|
filesCounter: "{count}/{max}",
|