@universe-platform/ui 0.1.0-beta.55 → 0.1.0-beta.56
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/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +175 -33
- package/dist/index.mjs +175 -33
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -800,6 +800,11 @@ interface StyledFormBlockProps {
|
|
|
800
800
|
height?: number;
|
|
801
801
|
reset?: boolean;
|
|
802
802
|
}) => void;
|
|
803
|
+
/** ערכים התחלתיים לשדות (למשל נתונים שמולאו בטופס הראשון) */
|
|
804
|
+
initialValues?: Record<string, any>;
|
|
805
|
+
/** create (ברירת מחדל): יוצר רשומה חדשה. update: מעדכן את הרשומה recordId (CREATE_RECORD לא נשלח) */
|
|
806
|
+
submitMode?: 'create' | 'update';
|
|
807
|
+
recordId?: string;
|
|
803
808
|
}
|
|
804
809
|
|
|
805
810
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -800,6 +800,11 @@ interface StyledFormBlockProps {
|
|
|
800
800
|
height?: number;
|
|
801
801
|
reset?: boolean;
|
|
802
802
|
}) => void;
|
|
803
|
+
/** ערכים התחלתיים לשדות (למשל נתונים שמולאו בטופס הראשון) */
|
|
804
|
+
initialValues?: Record<string, any>;
|
|
805
|
+
/** create (ברירת מחדל): יוצר רשומה חדשה. update: מעדכן את הרשומה recordId (CREATE_RECORD לא נשלח) */
|
|
806
|
+
submitMode?: 'create' | 'update';
|
|
807
|
+
recordId?: string;
|
|
803
808
|
}
|
|
804
809
|
|
|
805
810
|
/**
|
package/dist/index.js
CHANGED
|
@@ -15471,6 +15471,19 @@ var import_react29 = require("react");
|
|
|
15471
15471
|
var import_lucide_react19 = require("lucide-react");
|
|
15472
15472
|
|
|
15473
15473
|
// src/components/FormBlock/formDesign.ts
|
|
15474
|
+
function isFieldRequired(col, design) {
|
|
15475
|
+
var _a, _b;
|
|
15476
|
+
const override = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.required;
|
|
15477
|
+
return typeof override === "boolean" ? override : !!col.isRequired;
|
|
15478
|
+
}
|
|
15479
|
+
function isFieldHidden(col, design) {
|
|
15480
|
+
var _a, _b;
|
|
15481
|
+
return !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.hidden);
|
|
15482
|
+
}
|
|
15483
|
+
function isFieldLocked(col, design) {
|
|
15484
|
+
var _a, _b;
|
|
15485
|
+
return !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.locked);
|
|
15486
|
+
}
|
|
15474
15487
|
var FORM_PRESETS = {
|
|
15475
15488
|
classic: {
|
|
15476
15489
|
label: "\u05E7\u05DC\u05D0\u05E1\u05D9",
|
|
@@ -15563,6 +15576,13 @@ var ALWAYS_FULL_TYPES = /* @__PURE__ */ new Set(["GOOGLE_DRIVE_FILE", "SUB_TABLE
|
|
|
15563
15576
|
function isFormPresetId(v) {
|
|
15564
15577
|
return typeof v === "string" && v in FORM_PRESETS;
|
|
15565
15578
|
}
|
|
15579
|
+
function safeLogoUrl(url) {
|
|
15580
|
+
const u = (url || "").trim();
|
|
15581
|
+
if (!u) return void 0;
|
|
15582
|
+
if (/^https?:\/\//i.test(u)) return u;
|
|
15583
|
+
if (/^data:image\/(png|jpe?g|webp|gif);base64,[a-z0-9+/=]+$/i.test(u)) return u;
|
|
15584
|
+
return void 0;
|
|
15585
|
+
}
|
|
15566
15586
|
function resolveFormDesign(design) {
|
|
15567
15587
|
var _a, _b;
|
|
15568
15588
|
const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
|
|
@@ -15579,9 +15599,64 @@ function resolveFormDesign(design) {
|
|
|
15579
15599
|
buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
|
|
15580
15600
|
buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
|
|
15581
15601
|
subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
|
|
15582
|
-
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns
|
|
15602
|
+
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns,
|
|
15603
|
+
titleColor: (design == null ? void 0 : design.titleColor) || void 0,
|
|
15604
|
+
logoUrl: safeLogoUrl(design == null ? void 0 : design.logoUrl),
|
|
15605
|
+
logoHeight: Math.min(200, Math.max(24, Number(design == null ? void 0 : design.logoHeight) || 56)),
|
|
15606
|
+
logoAlign: (design == null ? void 0 : design.logoAlign) || "start"
|
|
15583
15607
|
};
|
|
15584
15608
|
}
|
|
15609
|
+
var TODAY_DEFAULT_TOKEN = "@today";
|
|
15610
|
+
function todayIsoDate() {
|
|
15611
|
+
try {
|
|
15612
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
15613
|
+
timeZone: "Asia/Jerusalem",
|
|
15614
|
+
year: "numeric",
|
|
15615
|
+
month: "2-digit",
|
|
15616
|
+
day: "2-digit"
|
|
15617
|
+
}).format(/* @__PURE__ */ new Date());
|
|
15618
|
+
} catch (e) {
|
|
15619
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
function parseColumnDefault(col) {
|
|
15623
|
+
const raw = col.defaultValue;
|
|
15624
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
15625
|
+
const type = (col.type || "").toUpperCase();
|
|
15626
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
15627
|
+
if (first === void 0 || first === null || first === "") return void 0;
|
|
15628
|
+
switch (type) {
|
|
15629
|
+
case "NUMBER":
|
|
15630
|
+
case "CURRENCY": {
|
|
15631
|
+
const n = Number(first);
|
|
15632
|
+
return isNaN(n) ? void 0 : n;
|
|
15633
|
+
}
|
|
15634
|
+
case "BOOLEAN":
|
|
15635
|
+
return first === true || first === "true";
|
|
15636
|
+
case "DATE":
|
|
15637
|
+
return first === TODAY_DEFAULT_TOKEN ? todayIsoDate() : String(first);
|
|
15638
|
+
case "RELATION":
|
|
15639
|
+
return Array.isArray(raw) ? raw.map(String) : [String(first)];
|
|
15640
|
+
case "SUB_TABLE":
|
|
15641
|
+
case "SUBTABLE":
|
|
15642
|
+
case "LINK":
|
|
15643
|
+
case "GOOGLE_DRIVE_FILE":
|
|
15644
|
+
case "GOOGLE_CONTACT":
|
|
15645
|
+
case "FORMULA":
|
|
15646
|
+
case "SEQUENCE":
|
|
15647
|
+
return void 0;
|
|
15648
|
+
default:
|
|
15649
|
+
return String(first);
|
|
15650
|
+
}
|
|
15651
|
+
}
|
|
15652
|
+
function buildDefaultValues(cols) {
|
|
15653
|
+
const out = {};
|
|
15654
|
+
for (const c of cols || []) {
|
|
15655
|
+
const v = parseColumnDefault(c);
|
|
15656
|
+
if (v !== void 0) out[c.name] = v;
|
|
15657
|
+
}
|
|
15658
|
+
return out;
|
|
15659
|
+
}
|
|
15585
15660
|
function resolveFieldWidth(colName, colType, design, columnsDefault) {
|
|
15586
15661
|
var _a, _b;
|
|
15587
15662
|
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
|
|
@@ -15618,14 +15693,17 @@ function StyledFormBlock({
|
|
|
15618
15693
|
onSuccess,
|
|
15619
15694
|
previewMode = false,
|
|
15620
15695
|
onReorder,
|
|
15621
|
-
onFieldResize
|
|
15696
|
+
onFieldResize,
|
|
15697
|
+
initialValues,
|
|
15698
|
+
submitMode = "create",
|
|
15699
|
+
recordId
|
|
15622
15700
|
}) {
|
|
15623
15701
|
const { showError, addToast } = useToast();
|
|
15624
15702
|
const uid = "fdz" + (0, import_react29.useId)().replace(/[^a-zA-Z0-9]/g, "");
|
|
15625
15703
|
const design = schema == null ? void 0 : schema.design;
|
|
15626
15704
|
const d = resolveFormDesign(design);
|
|
15627
15705
|
const t = d.tokens;
|
|
15628
|
-
const [formData, setFormData] = (0, import_react29.useState)({});
|
|
15706
|
+
const [formData, setFormData] = (0, import_react29.useState)(initialValues || {});
|
|
15629
15707
|
const [isSubmitting, setIsSubmitting] = (0, import_react29.useState)(false);
|
|
15630
15708
|
const [isSubmitted, setIsSubmitted] = (0, import_react29.useState)(false);
|
|
15631
15709
|
const [columns, setColumns] = (0, import_react29.useState)((schema == null ? void 0 : schema.columns) || []);
|
|
@@ -15635,6 +15713,9 @@ function StyledFormBlock({
|
|
|
15635
15713
|
const [resizing, setResizing] = (0, import_react29.useState)(null);
|
|
15636
15714
|
const resizeRef = (0, import_react29.useRef)(null);
|
|
15637
15715
|
const gridRef = (0, import_react29.useRef)(null);
|
|
15716
|
+
const relationDictRef = (0, import_react29.useRef)({});
|
|
15717
|
+
const relationRequestedRef = (0, import_react29.useRef)(/* @__PURE__ */ new Set());
|
|
15718
|
+
const [, bumpRelationLabels] = (0, import_react29.useState)(0);
|
|
15638
15719
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
15639
15720
|
(0, import_react29.useEffect)(() => {
|
|
15640
15721
|
let isMounted = true;
|
|
@@ -15655,14 +15736,47 @@ function StyledFormBlock({
|
|
|
15655
15736
|
isMounted = false;
|
|
15656
15737
|
};
|
|
15657
15738
|
}, [schema == null ? void 0 : schema.columns, targetTableId]);
|
|
15739
|
+
(0, import_react29.useEffect)(() => {
|
|
15740
|
+
if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
|
|
15741
|
+
const defaults = buildDefaultValues(columns);
|
|
15742
|
+
if (Object.keys(defaults).length === 0) return;
|
|
15743
|
+
setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
|
|
15744
|
+
}, [columns, submitMode, previewMode]);
|
|
15745
|
+
(0, import_react29.useEffect)(() => {
|
|
15746
|
+
if (previewMode || !executeAction || !columns) return;
|
|
15747
|
+
for (const col of columns) {
|
|
15748
|
+
if ((col.type || "").toUpperCase() !== "RELATION") continue;
|
|
15749
|
+
const cfg = col.config || {};
|
|
15750
|
+
if (!cfg.referencedTableId) continue;
|
|
15751
|
+
const need = normalizeRelationValue(formData[col.name]).filter(
|
|
15752
|
+
(id) => {
|
|
15753
|
+
var _a;
|
|
15754
|
+
return !((_a = relationDictRef.current[col.name]) == null ? void 0 : _a.has(id)) && !relationRequestedRef.current.has(`${col.name}:${id}`);
|
|
15755
|
+
}
|
|
15756
|
+
);
|
|
15757
|
+
if (need.length === 0) continue;
|
|
15758
|
+
need.forEach((id) => relationRequestedRef.current.add(`${col.name}:${id}`));
|
|
15759
|
+
executeAction("FETCH_RELATION", {
|
|
15760
|
+
referencedTableId: cfg.referencedTableId,
|
|
15761
|
+
displayField: cfg.displayField,
|
|
15762
|
+
recordIds: need,
|
|
15763
|
+
take: need.length,
|
|
15764
|
+
limit: need.length
|
|
15765
|
+
}).then((res) => {
|
|
15766
|
+
const rows = Array.isArray(res) ? res : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
|
|
15767
|
+
if (rows.length === 0) return;
|
|
15768
|
+
const map = relationDictRef.current[col.name] || /* @__PURE__ */ new Map();
|
|
15769
|
+
rows.forEach((r) => map.set(String(r.id), r));
|
|
15770
|
+
relationDictRef.current[col.name] = map;
|
|
15771
|
+
bumpRelationLabels((n) => n + 1);
|
|
15772
|
+
}).catch((err) => console.warn("[StyledFormBlock] relation label fetch failed:", err));
|
|
15773
|
+
}
|
|
15774
|
+
}, [columns, formData, previewMode, executeAction]);
|
|
15658
15775
|
const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
|
|
15659
15776
|
var _a, _b;
|
|
15660
15777
|
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
15661
15778
|
});
|
|
15662
|
-
const isDesignHidden = (col) =>
|
|
15663
|
-
var _a, _b;
|
|
15664
|
-
return !col.isRequired && !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.hidden);
|
|
15665
|
-
};
|
|
15779
|
+
const isDesignHidden = (col) => isFieldHidden(col, design);
|
|
15666
15780
|
const orderedColumns = applyFieldOrder(baseColumns, design);
|
|
15667
15781
|
const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
|
|
15668
15782
|
const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
|
|
@@ -15808,8 +15922,12 @@ function StyledFormBlock({
|
|
|
15808
15922
|
showError("\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E9\u05DE\u05D5\u05E8: \u05DE\u05D6\u05D4\u05D4 \u05D4\u05D8\u05D1\u05DC\u05D4 \u05D7\u05E1\u05E8", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15809
15923
|
return;
|
|
15810
15924
|
}
|
|
15925
|
+
if (submitMode === "update" && !recordId) {
|
|
15926
|
+
showError("\u05D4\u05E7\u05D9\u05E9\u05D5\u05E8 \u05D0\u05D9\u05E0\u05D5 \u05DE\u05E7\u05D5\u05E9\u05E8 \u05DC\u05E8\u05E9\u05D5\u05DE\u05D4 \u05E7\u05D9\u05D9\u05DE\u05EA", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15927
|
+
return;
|
|
15928
|
+
}
|
|
15811
15929
|
const missingFields = formColumns.filter(
|
|
15812
|
-
(col) => col
|
|
15930
|
+
(col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && (formData[col.name] === void 0 || formData[col.name] === null || formData[col.name] === "")
|
|
15813
15931
|
);
|
|
15814
15932
|
if (missingFields.length > 0) {
|
|
15815
15933
|
showError(`\u05D9\u05E9 \u05DC\u05DE\u05DC\u05D0 \u05D0\u05EA \u05D4\u05E9\u05D3\u05D5\u05EA \u05D4\u05D1\u05D0\u05D9\u05DD: ${missingFields.map((c) => c.name).join(", ")}`, "\u05E9\u05D2\u05D9\u05D0\u05EA \u05D5\u05DC\u05D9\u05D3\u05E6\u05D9\u05D4");
|
|
@@ -15820,24 +15938,40 @@ function StyledFormBlock({
|
|
|
15820
15938
|
const payload = {};
|
|
15821
15939
|
formColumns.forEach((col) => {
|
|
15822
15940
|
var _a;
|
|
15941
|
+
if (isFieldLocked(col, design)) {
|
|
15942
|
+
const lockedDefault = parseColumnDefault(col);
|
|
15943
|
+
if (submitMode !== "update" && lockedDefault !== void 0) payload[col.name] = lockedDefault;
|
|
15944
|
+
return;
|
|
15945
|
+
}
|
|
15823
15946
|
let val = formData[col.name];
|
|
15824
15947
|
if (val !== void 0 && val !== null) {
|
|
15825
15948
|
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
|
|
15826
15949
|
payload[col.name] = val;
|
|
15827
|
-
} else if (
|
|
15828
|
-
|
|
15950
|
+
} else if (submitMode !== "update") {
|
|
15951
|
+
const dv = parseColumnDefault(col);
|
|
15952
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15829
15953
|
}
|
|
15830
15954
|
});
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
}
|
|
15955
|
+
if (submitMode === "update") {
|
|
15956
|
+
await executeAction("UPDATE_RECORD", {
|
|
15957
|
+
tableId: targetTableId,
|
|
15958
|
+
tableMetaId: targetTableId,
|
|
15959
|
+
recordId,
|
|
15960
|
+
data: payload
|
|
15961
|
+
});
|
|
15962
|
+
} else {
|
|
15963
|
+
hiddenColumns.forEach((col) => {
|
|
15964
|
+
const dv = parseColumnDefault(col);
|
|
15965
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15966
|
+
});
|
|
15967
|
+
await executeAction("CREATE_RECORD", {
|
|
15968
|
+
tableId: targetTableId,
|
|
15969
|
+
tableMetaId: targetTableId,
|
|
15970
|
+
records: [payload]
|
|
15971
|
+
});
|
|
15972
|
+
}
|
|
15839
15973
|
addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
|
|
15840
|
-
setFormData(
|
|
15974
|
+
if (submitMode !== "update") setFormData(buildDefaultValues(columns));
|
|
15841
15975
|
setIsSubmitted(true);
|
|
15842
15976
|
if (onSuccess) onSuccess();
|
|
15843
15977
|
} catch (err) {
|
|
@@ -15866,13 +16000,16 @@ function StyledFormBlock({
|
|
|
15866
16000
|
position: "relative"
|
|
15867
16001
|
};
|
|
15868
16002
|
const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
|
|
15869
|
-
minHeight: 0,
|
|
15870
16003
|
width: "fit-content",
|
|
15871
|
-
|
|
16004
|
+
minWidth: 40,
|
|
16005
|
+
alignSelf: "flex-start",
|
|
16006
|
+
display: "flex",
|
|
16007
|
+
alignItems: "center",
|
|
16008
|
+
justifyContent: "center"
|
|
15872
16009
|
});
|
|
15873
16010
|
const css = `
|
|
15874
16011
|
.${uid}{container-type:inline-size}
|
|
15875
|
-
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-
|
|
16012
|
+
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
|
|
15876
16013
|
.${uid} .fdz-f{--n:6;flex:0 0 auto;box-sizing:border-box;min-width:0;display:flex;flex-direction:column;gap:6px;width:calc((100% - ${t.gap * 5}px) / 6 * var(--n) + ${t.gap}px * (var(--n) - 1) - 0.5px)}
|
|
15877
16014
|
.${uid} .fdz-s1{--n:2}
|
|
15878
16015
|
.${uid} .fdz-b{width:fit-content;max-width:140px;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
|
|
@@ -15889,12 +16026,14 @@ function StyledFormBlock({
|
|
|
15889
16026
|
if (!formColumns || formColumns.length === 0) {
|
|
15890
16027
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "p-4 text-center text-slate-500", children: "\u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8\u05D5 \u05E9\u05D3\u05D5\u05EA \u05DC\u05D8\u05D5\u05E4\u05E1 \u05D6\u05D4." });
|
|
15891
16028
|
}
|
|
15892
|
-
const
|
|
16029
|
+
const logoJustify = d.logoAlign === "center" ? "center" : d.logoAlign === "end" ? "flex-end" : "flex-start";
|
|
16030
|
+
const headerBlock = (schema == null ? void 0 : schema.title) || d.subtitle || d.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
15893
16031
|
"div",
|
|
15894
16032
|
{
|
|
15895
16033
|
style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
|
|
15896
16034
|
children: [
|
|
15897
|
-
(schema == null ? void 0 : schema.title)
|
|
16035
|
+
d.logoUrl && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: { display: "flex", justifyContent: logoJustify, marginBottom: (schema == null ? void 0 : schema.title) || d.subtitle ? 12 : 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("img", { src: d.logoUrl, alt: "", style: { height: d.logoHeight, maxWidth: "100%", objectFit: "contain", display: "block" } }) }),
|
|
16036
|
+
(schema == null ? void 0 : schema.title) && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("h2", { style: __spreadValues({ fontSize: t.titleSize, fontWeight: 800, margin: 0 }, d.titleColor ? { color: d.titleColor } : {}), children: schema.title }),
|
|
15898
16037
|
d.subtitle && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { style: { fontSize: 14, margin: "6px 0 0", color: t.headerBand ? "rgba(255,255,255,0.9)" : muted }, children: d.subtitle })
|
|
15899
16038
|
]
|
|
15900
16039
|
}
|
|
@@ -15921,7 +16060,7 @@ function StyledFormBlock({
|
|
|
15921
16060
|
),
|
|
15922
16061
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("h3", { style: { fontSize: 24, fontWeight: 800, margin: "0 0 8px" }, children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
|
|
15923
16062
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { style: { fontSize: 16, color: muted, maxWidth: 420, margin: "0 auto", whiteSpace: "pre-wrap" }, children: customMessage }),
|
|
15924
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
16063
|
+
submitMode !== "update" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
15925
16064
|
"button",
|
|
15926
16065
|
{
|
|
15927
16066
|
type: "button",
|
|
@@ -15950,9 +16089,11 @@ function StyledFormBlock({
|
|
|
15950
16089
|
const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
|
|
15951
16090
|
const span = spanOf(col);
|
|
15952
16091
|
const isBoolean = colType === "BOOLEAN";
|
|
15953
|
-
const
|
|
16092
|
+
const locked = isFieldLocked(col, design);
|
|
16093
|
+
const shownValue = (_c = formData[col.name]) != null ? _c : locked && submitMode !== "update" ? (_b = parseColumnDefault(col)) != null ? _b : "" : "";
|
|
16094
|
+
const fieldHeight = resizing && resizing.name === col.name ? resizing.height : (_e = (_d = design == null ? void 0 : design.fields) == null ? void 0 : _d[col.name]) == null ? void 0 : _e.height;
|
|
15954
16095
|
const useTextarea = !!fieldHeight && fieldHeight > 56 && InputComponent === FORM_INPUTS.DEFAULT;
|
|
15955
|
-
const boxStyle = __spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {});
|
|
16096
|
+
const boxStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {}), locked ? { background: t.inputStyle === "underline" ? "transparent" : "#f1f5f9", opacity: 0.85, cursor: "not-allowed" } : {});
|
|
15956
16097
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
15957
16098
|
"div",
|
|
15958
16099
|
{
|
|
@@ -15980,14 +16121,15 @@ function StyledFormBlock({
|
|
|
15980
16121
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
|
|
15981
16122
|
col.name,
|
|
15982
16123
|
" ",
|
|
15983
|
-
col
|
|
16124
|
+
isFieldRequired(col, design) && !locked && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { style: { color: t.invertText ? "#fecdd3" : "#f43f5e" }, children: "*" }),
|
|
16125
|
+
locked && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { style: { fontSize: 11, fontWeight: 400, opacity: 0.7 }, children: "(\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E2\u05E8\u05D9\u05DB\u05D4)" })
|
|
15984
16126
|
] }),
|
|
15985
16127
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
15986
16128
|
"textarea",
|
|
15987
16129
|
{
|
|
15988
|
-
value:
|
|
16130
|
+
value: shownValue,
|
|
15989
16131
|
onChange: (e) => handleFieldChange(col.name, e.target.value),
|
|
15990
|
-
readOnly: previewMode,
|
|
16132
|
+
readOnly: previewMode || locked,
|
|
15991
16133
|
style: {
|
|
15992
16134
|
width: "100%",
|
|
15993
16135
|
height: "100%",
|
|
@@ -16007,10 +16149,10 @@ function StyledFormBlock({
|
|
|
16007
16149
|
{
|
|
16008
16150
|
column: col,
|
|
16009
16151
|
rowId: "new_form_record",
|
|
16010
|
-
value:
|
|
16152
|
+
value: shownValue,
|
|
16011
16153
|
onChange: (val) => handleFieldChange(col.name, val),
|
|
16012
|
-
readOnly: previewMode,
|
|
16013
|
-
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId }
|
|
16154
|
+
readOnly: previewMode || locked,
|
|
16155
|
+
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
|
|
16014
16156
|
}
|
|
16015
16157
|
) }),
|
|
16016
16158
|
canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
package/dist/index.mjs
CHANGED
|
@@ -15376,6 +15376,19 @@ import { useState as useState22, useEffect as useEffect20, useId, useRef as useR
|
|
|
15376
15376
|
import { Loader2 as Loader210, CheckCircle2 as CheckCircle26 } from "lucide-react";
|
|
15377
15377
|
|
|
15378
15378
|
// src/components/FormBlock/formDesign.ts
|
|
15379
|
+
function isFieldRequired(col, design) {
|
|
15380
|
+
var _a, _b;
|
|
15381
|
+
const override = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.required;
|
|
15382
|
+
return typeof override === "boolean" ? override : !!col.isRequired;
|
|
15383
|
+
}
|
|
15384
|
+
function isFieldHidden(col, design) {
|
|
15385
|
+
var _a, _b;
|
|
15386
|
+
return !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.hidden);
|
|
15387
|
+
}
|
|
15388
|
+
function isFieldLocked(col, design) {
|
|
15389
|
+
var _a, _b;
|
|
15390
|
+
return !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.locked);
|
|
15391
|
+
}
|
|
15379
15392
|
var FORM_PRESETS = {
|
|
15380
15393
|
classic: {
|
|
15381
15394
|
label: "\u05E7\u05DC\u05D0\u05E1\u05D9",
|
|
@@ -15468,6 +15481,13 @@ var ALWAYS_FULL_TYPES = /* @__PURE__ */ new Set(["GOOGLE_DRIVE_FILE", "SUB_TABLE
|
|
|
15468
15481
|
function isFormPresetId(v) {
|
|
15469
15482
|
return typeof v === "string" && v in FORM_PRESETS;
|
|
15470
15483
|
}
|
|
15484
|
+
function safeLogoUrl(url) {
|
|
15485
|
+
const u = (url || "").trim();
|
|
15486
|
+
if (!u) return void 0;
|
|
15487
|
+
if (/^https?:\/\//i.test(u)) return u;
|
|
15488
|
+
if (/^data:image\/(png|jpe?g|webp|gif);base64,[a-z0-9+/=]+$/i.test(u)) return u;
|
|
15489
|
+
return void 0;
|
|
15490
|
+
}
|
|
15471
15491
|
function resolveFormDesign(design) {
|
|
15472
15492
|
var _a, _b;
|
|
15473
15493
|
const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
|
|
@@ -15484,9 +15504,64 @@ function resolveFormDesign(design) {
|
|
|
15484
15504
|
buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
|
|
15485
15505
|
buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
|
|
15486
15506
|
subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
|
|
15487
|
-
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns
|
|
15507
|
+
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns,
|
|
15508
|
+
titleColor: (design == null ? void 0 : design.titleColor) || void 0,
|
|
15509
|
+
logoUrl: safeLogoUrl(design == null ? void 0 : design.logoUrl),
|
|
15510
|
+
logoHeight: Math.min(200, Math.max(24, Number(design == null ? void 0 : design.logoHeight) || 56)),
|
|
15511
|
+
logoAlign: (design == null ? void 0 : design.logoAlign) || "start"
|
|
15488
15512
|
};
|
|
15489
15513
|
}
|
|
15514
|
+
var TODAY_DEFAULT_TOKEN = "@today";
|
|
15515
|
+
function todayIsoDate() {
|
|
15516
|
+
try {
|
|
15517
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
15518
|
+
timeZone: "Asia/Jerusalem",
|
|
15519
|
+
year: "numeric",
|
|
15520
|
+
month: "2-digit",
|
|
15521
|
+
day: "2-digit"
|
|
15522
|
+
}).format(/* @__PURE__ */ new Date());
|
|
15523
|
+
} catch (e) {
|
|
15524
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15525
|
+
}
|
|
15526
|
+
}
|
|
15527
|
+
function parseColumnDefault(col) {
|
|
15528
|
+
const raw = col.defaultValue;
|
|
15529
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
15530
|
+
const type = (col.type || "").toUpperCase();
|
|
15531
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
15532
|
+
if (first === void 0 || first === null || first === "") return void 0;
|
|
15533
|
+
switch (type) {
|
|
15534
|
+
case "NUMBER":
|
|
15535
|
+
case "CURRENCY": {
|
|
15536
|
+
const n = Number(first);
|
|
15537
|
+
return isNaN(n) ? void 0 : n;
|
|
15538
|
+
}
|
|
15539
|
+
case "BOOLEAN":
|
|
15540
|
+
return first === true || first === "true";
|
|
15541
|
+
case "DATE":
|
|
15542
|
+
return first === TODAY_DEFAULT_TOKEN ? todayIsoDate() : String(first);
|
|
15543
|
+
case "RELATION":
|
|
15544
|
+
return Array.isArray(raw) ? raw.map(String) : [String(first)];
|
|
15545
|
+
case "SUB_TABLE":
|
|
15546
|
+
case "SUBTABLE":
|
|
15547
|
+
case "LINK":
|
|
15548
|
+
case "GOOGLE_DRIVE_FILE":
|
|
15549
|
+
case "GOOGLE_CONTACT":
|
|
15550
|
+
case "FORMULA":
|
|
15551
|
+
case "SEQUENCE":
|
|
15552
|
+
return void 0;
|
|
15553
|
+
default:
|
|
15554
|
+
return String(first);
|
|
15555
|
+
}
|
|
15556
|
+
}
|
|
15557
|
+
function buildDefaultValues(cols) {
|
|
15558
|
+
const out = {};
|
|
15559
|
+
for (const c of cols || []) {
|
|
15560
|
+
const v = parseColumnDefault(c);
|
|
15561
|
+
if (v !== void 0) out[c.name] = v;
|
|
15562
|
+
}
|
|
15563
|
+
return out;
|
|
15564
|
+
}
|
|
15490
15565
|
function resolveFieldWidth(colName, colType, design, columnsDefault) {
|
|
15491
15566
|
var _a, _b;
|
|
15492
15567
|
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
|
|
@@ -15523,14 +15598,17 @@ function StyledFormBlock({
|
|
|
15523
15598
|
onSuccess,
|
|
15524
15599
|
previewMode = false,
|
|
15525
15600
|
onReorder,
|
|
15526
|
-
onFieldResize
|
|
15601
|
+
onFieldResize,
|
|
15602
|
+
initialValues,
|
|
15603
|
+
submitMode = "create",
|
|
15604
|
+
recordId
|
|
15527
15605
|
}) {
|
|
15528
15606
|
const { showError, addToast } = useToast();
|
|
15529
15607
|
const uid = "fdz" + useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
15530
15608
|
const design = schema == null ? void 0 : schema.design;
|
|
15531
15609
|
const d = resolveFormDesign(design);
|
|
15532
15610
|
const t = d.tokens;
|
|
15533
|
-
const [formData, setFormData] = useState22({});
|
|
15611
|
+
const [formData, setFormData] = useState22(initialValues || {});
|
|
15534
15612
|
const [isSubmitting, setIsSubmitting] = useState22(false);
|
|
15535
15613
|
const [isSubmitted, setIsSubmitted] = useState22(false);
|
|
15536
15614
|
const [columns, setColumns] = useState22((schema == null ? void 0 : schema.columns) || []);
|
|
@@ -15540,6 +15618,9 @@ function StyledFormBlock({
|
|
|
15540
15618
|
const [resizing, setResizing] = useState22(null);
|
|
15541
15619
|
const resizeRef = useRef20(null);
|
|
15542
15620
|
const gridRef = useRef20(null);
|
|
15621
|
+
const relationDictRef = useRef20({});
|
|
15622
|
+
const relationRequestedRef = useRef20(/* @__PURE__ */ new Set());
|
|
15623
|
+
const [, bumpRelationLabels] = useState22(0);
|
|
15543
15624
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
15544
15625
|
useEffect20(() => {
|
|
15545
15626
|
let isMounted = true;
|
|
@@ -15560,14 +15641,47 @@ function StyledFormBlock({
|
|
|
15560
15641
|
isMounted = false;
|
|
15561
15642
|
};
|
|
15562
15643
|
}, [schema == null ? void 0 : schema.columns, targetTableId]);
|
|
15644
|
+
useEffect20(() => {
|
|
15645
|
+
if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
|
|
15646
|
+
const defaults = buildDefaultValues(columns);
|
|
15647
|
+
if (Object.keys(defaults).length === 0) return;
|
|
15648
|
+
setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
|
|
15649
|
+
}, [columns, submitMode, previewMode]);
|
|
15650
|
+
useEffect20(() => {
|
|
15651
|
+
if (previewMode || !executeAction || !columns) return;
|
|
15652
|
+
for (const col of columns) {
|
|
15653
|
+
if ((col.type || "").toUpperCase() !== "RELATION") continue;
|
|
15654
|
+
const cfg = col.config || {};
|
|
15655
|
+
if (!cfg.referencedTableId) continue;
|
|
15656
|
+
const need = normalizeRelationValue(formData[col.name]).filter(
|
|
15657
|
+
(id) => {
|
|
15658
|
+
var _a;
|
|
15659
|
+
return !((_a = relationDictRef.current[col.name]) == null ? void 0 : _a.has(id)) && !relationRequestedRef.current.has(`${col.name}:${id}`);
|
|
15660
|
+
}
|
|
15661
|
+
);
|
|
15662
|
+
if (need.length === 0) continue;
|
|
15663
|
+
need.forEach((id) => relationRequestedRef.current.add(`${col.name}:${id}`));
|
|
15664
|
+
executeAction("FETCH_RELATION", {
|
|
15665
|
+
referencedTableId: cfg.referencedTableId,
|
|
15666
|
+
displayField: cfg.displayField,
|
|
15667
|
+
recordIds: need,
|
|
15668
|
+
take: need.length,
|
|
15669
|
+
limit: need.length
|
|
15670
|
+
}).then((res) => {
|
|
15671
|
+
const rows = Array.isArray(res) ? res : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
|
|
15672
|
+
if (rows.length === 0) return;
|
|
15673
|
+
const map = relationDictRef.current[col.name] || /* @__PURE__ */ new Map();
|
|
15674
|
+
rows.forEach((r) => map.set(String(r.id), r));
|
|
15675
|
+
relationDictRef.current[col.name] = map;
|
|
15676
|
+
bumpRelationLabels((n) => n + 1);
|
|
15677
|
+
}).catch((err) => console.warn("[StyledFormBlock] relation label fetch failed:", err));
|
|
15678
|
+
}
|
|
15679
|
+
}, [columns, formData, previewMode, executeAction]);
|
|
15563
15680
|
const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
|
|
15564
15681
|
var _a, _b;
|
|
15565
15682
|
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
15566
15683
|
});
|
|
15567
|
-
const isDesignHidden = (col) =>
|
|
15568
|
-
var _a, _b;
|
|
15569
|
-
return !col.isRequired && !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[col.name]) == null ? void 0 : _b.hidden);
|
|
15570
|
-
};
|
|
15684
|
+
const isDesignHidden = (col) => isFieldHidden(col, design);
|
|
15571
15685
|
const orderedColumns = applyFieldOrder(baseColumns, design);
|
|
15572
15686
|
const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
|
|
15573
15687
|
const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
|
|
@@ -15713,8 +15827,12 @@ function StyledFormBlock({
|
|
|
15713
15827
|
showError("\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E9\u05DE\u05D5\u05E8: \u05DE\u05D6\u05D4\u05D4 \u05D4\u05D8\u05D1\u05DC\u05D4 \u05D7\u05E1\u05E8", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15714
15828
|
return;
|
|
15715
15829
|
}
|
|
15830
|
+
if (submitMode === "update" && !recordId) {
|
|
15831
|
+
showError("\u05D4\u05E7\u05D9\u05E9\u05D5\u05E8 \u05D0\u05D9\u05E0\u05D5 \u05DE\u05E7\u05D5\u05E9\u05E8 \u05DC\u05E8\u05E9\u05D5\u05DE\u05D4 \u05E7\u05D9\u05D9\u05DE\u05EA", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15832
|
+
return;
|
|
15833
|
+
}
|
|
15716
15834
|
const missingFields = formColumns.filter(
|
|
15717
|
-
(col) => col
|
|
15835
|
+
(col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && (formData[col.name] === void 0 || formData[col.name] === null || formData[col.name] === "")
|
|
15718
15836
|
);
|
|
15719
15837
|
if (missingFields.length > 0) {
|
|
15720
15838
|
showError(`\u05D9\u05E9 \u05DC\u05DE\u05DC\u05D0 \u05D0\u05EA \u05D4\u05E9\u05D3\u05D5\u05EA \u05D4\u05D1\u05D0\u05D9\u05DD: ${missingFields.map((c) => c.name).join(", ")}`, "\u05E9\u05D2\u05D9\u05D0\u05EA \u05D5\u05DC\u05D9\u05D3\u05E6\u05D9\u05D4");
|
|
@@ -15725,24 +15843,40 @@ function StyledFormBlock({
|
|
|
15725
15843
|
const payload = {};
|
|
15726
15844
|
formColumns.forEach((col) => {
|
|
15727
15845
|
var _a;
|
|
15846
|
+
if (isFieldLocked(col, design)) {
|
|
15847
|
+
const lockedDefault = parseColumnDefault(col);
|
|
15848
|
+
if (submitMode !== "update" && lockedDefault !== void 0) payload[col.name] = lockedDefault;
|
|
15849
|
+
return;
|
|
15850
|
+
}
|
|
15728
15851
|
let val = formData[col.name];
|
|
15729
15852
|
if (val !== void 0 && val !== null) {
|
|
15730
15853
|
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
|
|
15731
15854
|
payload[col.name] = val;
|
|
15732
|
-
} else if (
|
|
15733
|
-
|
|
15855
|
+
} else if (submitMode !== "update") {
|
|
15856
|
+
const dv = parseColumnDefault(col);
|
|
15857
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15734
15858
|
}
|
|
15735
15859
|
});
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
}
|
|
15860
|
+
if (submitMode === "update") {
|
|
15861
|
+
await executeAction("UPDATE_RECORD", {
|
|
15862
|
+
tableId: targetTableId,
|
|
15863
|
+
tableMetaId: targetTableId,
|
|
15864
|
+
recordId,
|
|
15865
|
+
data: payload
|
|
15866
|
+
});
|
|
15867
|
+
} else {
|
|
15868
|
+
hiddenColumns.forEach((col) => {
|
|
15869
|
+
const dv = parseColumnDefault(col);
|
|
15870
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15871
|
+
});
|
|
15872
|
+
await executeAction("CREATE_RECORD", {
|
|
15873
|
+
tableId: targetTableId,
|
|
15874
|
+
tableMetaId: targetTableId,
|
|
15875
|
+
records: [payload]
|
|
15876
|
+
});
|
|
15877
|
+
}
|
|
15744
15878
|
addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
|
|
15745
|
-
setFormData(
|
|
15879
|
+
if (submitMode !== "update") setFormData(buildDefaultValues(columns));
|
|
15746
15880
|
setIsSubmitted(true);
|
|
15747
15881
|
if (onSuccess) onSuccess();
|
|
15748
15882
|
} catch (err) {
|
|
@@ -15771,13 +15905,16 @@ function StyledFormBlock({
|
|
|
15771
15905
|
position: "relative"
|
|
15772
15906
|
};
|
|
15773
15907
|
const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
|
|
15774
|
-
minHeight: 0,
|
|
15775
15908
|
width: "fit-content",
|
|
15776
|
-
|
|
15909
|
+
minWidth: 40,
|
|
15910
|
+
alignSelf: "flex-start",
|
|
15911
|
+
display: "flex",
|
|
15912
|
+
alignItems: "center",
|
|
15913
|
+
justifyContent: "center"
|
|
15777
15914
|
});
|
|
15778
15915
|
const css = `
|
|
15779
15916
|
.${uid}{container-type:inline-size}
|
|
15780
|
-
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-
|
|
15917
|
+
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
|
|
15781
15918
|
.${uid} .fdz-f{--n:6;flex:0 0 auto;box-sizing:border-box;min-width:0;display:flex;flex-direction:column;gap:6px;width:calc((100% - ${t.gap * 5}px) / 6 * var(--n) + ${t.gap}px * (var(--n) - 1) - 0.5px)}
|
|
15782
15919
|
.${uid} .fdz-s1{--n:2}
|
|
15783
15920
|
.${uid} .fdz-b{width:fit-content;max-width:140px;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
|
|
@@ -15794,12 +15931,14 @@ function StyledFormBlock({
|
|
|
15794
15931
|
if (!formColumns || formColumns.length === 0) {
|
|
15795
15932
|
return /* @__PURE__ */ jsx30("div", { className: "p-4 text-center text-slate-500", children: "\u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8\u05D5 \u05E9\u05D3\u05D5\u05EA \u05DC\u05D8\u05D5\u05E4\u05E1 \u05D6\u05D4." });
|
|
15796
15933
|
}
|
|
15797
|
-
const
|
|
15934
|
+
const logoJustify = d.logoAlign === "center" ? "center" : d.logoAlign === "end" ? "flex-end" : "flex-start";
|
|
15935
|
+
const headerBlock = (schema == null ? void 0 : schema.title) || d.subtitle || d.logoUrl ? /* @__PURE__ */ jsxs26(
|
|
15798
15936
|
"div",
|
|
15799
15937
|
{
|
|
15800
15938
|
style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
|
|
15801
15939
|
children: [
|
|
15802
|
-
(schema == null ? void 0 : schema.title)
|
|
15940
|
+
d.logoUrl && /* @__PURE__ */ jsx30("div", { style: { display: "flex", justifyContent: logoJustify, marginBottom: (schema == null ? void 0 : schema.title) || d.subtitle ? 12 : 0 }, children: /* @__PURE__ */ jsx30("img", { src: d.logoUrl, alt: "", style: { height: d.logoHeight, maxWidth: "100%", objectFit: "contain", display: "block" } }) }),
|
|
15941
|
+
(schema == null ? void 0 : schema.title) && /* @__PURE__ */ jsx30("h2", { style: __spreadValues({ fontSize: t.titleSize, fontWeight: 800, margin: 0 }, d.titleColor ? { color: d.titleColor } : {}), children: schema.title }),
|
|
15803
15942
|
d.subtitle && /* @__PURE__ */ jsx30("p", { style: { fontSize: 14, margin: "6px 0 0", color: t.headerBand ? "rgba(255,255,255,0.9)" : muted }, children: d.subtitle })
|
|
15804
15943
|
]
|
|
15805
15944
|
}
|
|
@@ -15826,7 +15965,7 @@ function StyledFormBlock({
|
|
|
15826
15965
|
),
|
|
15827
15966
|
/* @__PURE__ */ jsx30("h3", { style: { fontSize: 24, fontWeight: 800, margin: "0 0 8px" }, children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
|
|
15828
15967
|
/* @__PURE__ */ jsx30("p", { style: { fontSize: 16, color: muted, maxWidth: 420, margin: "0 auto", whiteSpace: "pre-wrap" }, children: customMessage }),
|
|
15829
|
-
/* @__PURE__ */ jsx30(
|
|
15968
|
+
submitMode !== "update" && /* @__PURE__ */ jsx30(
|
|
15830
15969
|
"button",
|
|
15831
15970
|
{
|
|
15832
15971
|
type: "button",
|
|
@@ -15855,9 +15994,11 @@ function StyledFormBlock({
|
|
|
15855
15994
|
const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
|
|
15856
15995
|
const span = spanOf(col);
|
|
15857
15996
|
const isBoolean = colType === "BOOLEAN";
|
|
15858
|
-
const
|
|
15997
|
+
const locked = isFieldLocked(col, design);
|
|
15998
|
+
const shownValue = (_c = formData[col.name]) != null ? _c : locked && submitMode !== "update" ? (_b = parseColumnDefault(col)) != null ? _b : "" : "";
|
|
15999
|
+
const fieldHeight = resizing && resizing.name === col.name ? resizing.height : (_e = (_d = design == null ? void 0 : design.fields) == null ? void 0 : _d[col.name]) == null ? void 0 : _e.height;
|
|
15859
16000
|
const useTextarea = !!fieldHeight && fieldHeight > 56 && InputComponent === FORM_INPUTS.DEFAULT;
|
|
15860
|
-
const boxStyle = __spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {});
|
|
16001
|
+
const boxStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {}), locked ? { background: t.inputStyle === "underline" ? "transparent" : "#f1f5f9", opacity: 0.85, cursor: "not-allowed" } : {});
|
|
15861
16002
|
return /* @__PURE__ */ jsxs26(
|
|
15862
16003
|
"div",
|
|
15863
16004
|
{
|
|
@@ -15885,14 +16026,15 @@ function StyledFormBlock({
|
|
|
15885
16026
|
/* @__PURE__ */ jsxs26("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
|
|
15886
16027
|
col.name,
|
|
15887
16028
|
" ",
|
|
15888
|
-
col
|
|
16029
|
+
isFieldRequired(col, design) && !locked && /* @__PURE__ */ jsx30("span", { style: { color: t.invertText ? "#fecdd3" : "#f43f5e" }, children: "*" }),
|
|
16030
|
+
locked && /* @__PURE__ */ jsx30("span", { style: { fontSize: 11, fontWeight: 400, opacity: 0.7 }, children: "(\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E2\u05E8\u05D9\u05DB\u05D4)" })
|
|
15889
16031
|
] }),
|
|
15890
16032
|
/* @__PURE__ */ jsx30("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ jsx30(
|
|
15891
16033
|
"textarea",
|
|
15892
16034
|
{
|
|
15893
|
-
value:
|
|
16035
|
+
value: shownValue,
|
|
15894
16036
|
onChange: (e) => handleFieldChange(col.name, e.target.value),
|
|
15895
|
-
readOnly: previewMode,
|
|
16037
|
+
readOnly: previewMode || locked,
|
|
15896
16038
|
style: {
|
|
15897
16039
|
width: "100%",
|
|
15898
16040
|
height: "100%",
|
|
@@ -15912,10 +16054,10 @@ function StyledFormBlock({
|
|
|
15912
16054
|
{
|
|
15913
16055
|
column: col,
|
|
15914
16056
|
rowId: "new_form_record",
|
|
15915
|
-
value:
|
|
16057
|
+
value: shownValue,
|
|
15916
16058
|
onChange: (val) => handleFieldChange(col.name, val),
|
|
15917
|
-
readOnly: previewMode,
|
|
15918
|
-
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId }
|
|
16059
|
+
readOnly: previewMode || locked,
|
|
16060
|
+
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
|
|
15919
16061
|
}
|
|
15920
16062
|
) }),
|
|
15921
16063
|
canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ jsx30(
|