@universe-platform/ui 0.1.0-beta.55 → 0.1.0-beta.57
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 +260 -39
- package/dist/index.mjs +260 -39
- 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,38 @@ 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
|
+
var FRAME_STYLES = ["none", "soft", "solid", "double"];
|
|
15580
|
+
function isFormFrameStyle(v) {
|
|
15581
|
+
return typeof v === "string" && FRAME_STYLES.includes(v);
|
|
15582
|
+
}
|
|
15583
|
+
function withAlpha(color, alpha) {
|
|
15584
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((color || "").trim());
|
|
15585
|
+
if (!m) return color;
|
|
15586
|
+
let h = m[1];
|
|
15587
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
15588
|
+
const n = parseInt(h, 16);
|
|
15589
|
+
return `rgba(${n >> 16 & 255}, ${n >> 8 & 255}, ${n & 255}, ${alpha})`;
|
|
15590
|
+
}
|
|
15591
|
+
function frameToCss(frame) {
|
|
15592
|
+
if (!frame) return null;
|
|
15593
|
+
if (frame === "none") return { border: "none" };
|
|
15594
|
+
const c = frame.color;
|
|
15595
|
+
switch (frame.style) {
|
|
15596
|
+
case "soft":
|
|
15597
|
+
return { border: `1.5px solid ${withAlpha(c, 0.4)}`, boxShadow: `0 0 0 5px ${withAlpha(c, 0.08)}` };
|
|
15598
|
+
case "solid":
|
|
15599
|
+
return { border: `2px solid ${c}` };
|
|
15600
|
+
case "double":
|
|
15601
|
+
return { border: `1.5px solid ${c}`, outline: `1px solid ${withAlpha(c, 0.55)}`, outlineOffset: -7 };
|
|
15602
|
+
}
|
|
15603
|
+
}
|
|
15604
|
+
function safeLogoUrl(url) {
|
|
15605
|
+
const u = (url || "").trim();
|
|
15606
|
+
if (!u) return void 0;
|
|
15607
|
+
if (/^https?:\/\//i.test(u)) return u;
|
|
15608
|
+
if (/^data:image\/(png|jpe?g|webp|gif);base64,[a-z0-9+/=]+$/i.test(u)) return u;
|
|
15609
|
+
return void 0;
|
|
15610
|
+
}
|
|
15566
15611
|
function resolveFormDesign(design) {
|
|
15567
15612
|
var _a, _b;
|
|
15568
15613
|
const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
|
|
@@ -15579,9 +15624,65 @@ function resolveFormDesign(design) {
|
|
|
15579
15624
|
buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
|
|
15580
15625
|
buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
|
|
15581
15626
|
subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
|
|
15582
|
-
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns
|
|
15627
|
+
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns,
|
|
15628
|
+
titleColor: (design == null ? void 0 : design.titleColor) || void 0,
|
|
15629
|
+
logoUrl: safeLogoUrl(design == null ? void 0 : design.logoUrl),
|
|
15630
|
+
logoHeight: Math.min(200, Math.max(24, Number(design == null ? void 0 : design.logoHeight) || 56)),
|
|
15631
|
+
logoAlign: (design == null ? void 0 : design.logoAlign) || "start",
|
|
15632
|
+
frame: isFormFrameStyle(design == null ? void 0 : design.frameStyle) ? design.frameStyle === "none" ? "none" : { style: design.frameStyle, color: (design == null ? void 0 : design.frameColor) || primary } : void 0
|
|
15583
15633
|
};
|
|
15584
15634
|
}
|
|
15635
|
+
var TODAY_DEFAULT_TOKEN = "@today";
|
|
15636
|
+
function todayIsoDate() {
|
|
15637
|
+
try {
|
|
15638
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
15639
|
+
timeZone: "Asia/Jerusalem",
|
|
15640
|
+
year: "numeric",
|
|
15641
|
+
month: "2-digit",
|
|
15642
|
+
day: "2-digit"
|
|
15643
|
+
}).format(/* @__PURE__ */ new Date());
|
|
15644
|
+
} catch (e) {
|
|
15645
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15646
|
+
}
|
|
15647
|
+
}
|
|
15648
|
+
function parseColumnDefault(col) {
|
|
15649
|
+
const raw = col.defaultValue;
|
|
15650
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
15651
|
+
const type = (col.type || "").toUpperCase();
|
|
15652
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
15653
|
+
if (first === void 0 || first === null || first === "") return void 0;
|
|
15654
|
+
switch (type) {
|
|
15655
|
+
case "NUMBER":
|
|
15656
|
+
case "CURRENCY": {
|
|
15657
|
+
const n = Number(first);
|
|
15658
|
+
return isNaN(n) ? void 0 : n;
|
|
15659
|
+
}
|
|
15660
|
+
case "BOOLEAN":
|
|
15661
|
+
return first === true || first === "true";
|
|
15662
|
+
case "DATE":
|
|
15663
|
+
return first === TODAY_DEFAULT_TOKEN ? todayIsoDate() : String(first);
|
|
15664
|
+
case "RELATION":
|
|
15665
|
+
return Array.isArray(raw) ? raw.map(String) : [String(first)];
|
|
15666
|
+
case "SUB_TABLE":
|
|
15667
|
+
case "SUBTABLE":
|
|
15668
|
+
case "LINK":
|
|
15669
|
+
case "GOOGLE_DRIVE_FILE":
|
|
15670
|
+
case "GOOGLE_CONTACT":
|
|
15671
|
+
case "FORMULA":
|
|
15672
|
+
case "SEQUENCE":
|
|
15673
|
+
return void 0;
|
|
15674
|
+
default:
|
|
15675
|
+
return String(first);
|
|
15676
|
+
}
|
|
15677
|
+
}
|
|
15678
|
+
function buildDefaultValues(cols) {
|
|
15679
|
+
const out = {};
|
|
15680
|
+
for (const c of cols || []) {
|
|
15681
|
+
const v = parseColumnDefault(c);
|
|
15682
|
+
if (v !== void 0) out[c.name] = v;
|
|
15683
|
+
}
|
|
15684
|
+
return out;
|
|
15685
|
+
}
|
|
15585
15686
|
function resolveFieldWidth(colName, colType, design, columnsDefault) {
|
|
15586
15687
|
var _a, _b;
|
|
15587
15688
|
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
|
|
@@ -15618,16 +15719,22 @@ function StyledFormBlock({
|
|
|
15618
15719
|
onSuccess,
|
|
15619
15720
|
previewMode = false,
|
|
15620
15721
|
onReorder,
|
|
15621
|
-
onFieldResize
|
|
15722
|
+
onFieldResize,
|
|
15723
|
+
initialValues,
|
|
15724
|
+
submitMode = "create",
|
|
15725
|
+
recordId
|
|
15622
15726
|
}) {
|
|
15623
15727
|
const { showError, addToast } = useToast();
|
|
15624
15728
|
const uid = "fdz" + (0, import_react29.useId)().replace(/[^a-zA-Z0-9]/g, "");
|
|
15625
15729
|
const design = schema == null ? void 0 : schema.design;
|
|
15626
15730
|
const d = resolveFormDesign(design);
|
|
15627
15731
|
const t = d.tokens;
|
|
15628
|
-
const [formData, setFormData] = (0, import_react29.useState)({});
|
|
15732
|
+
const [formData, setFormData] = (0, import_react29.useState)(initialValues || {});
|
|
15629
15733
|
const [isSubmitting, setIsSubmitting] = (0, import_react29.useState)(false);
|
|
15630
15734
|
const [isSubmitted, setIsSubmitted] = (0, import_react29.useState)(false);
|
|
15735
|
+
const [formError, setFormError] = (0, import_react29.useState)(null);
|
|
15736
|
+
const [missingNames, setMissingNames] = (0, import_react29.useState)([]);
|
|
15737
|
+
const errorRef = (0, import_react29.useRef)(null);
|
|
15631
15738
|
const [columns, setColumns] = (0, import_react29.useState)((schema == null ? void 0 : schema.columns) || []);
|
|
15632
15739
|
const [isLoadingSchema, setIsLoadingSchema] = (0, import_react29.useState)(false);
|
|
15633
15740
|
const [dragName, setDragName] = (0, import_react29.useState)(null);
|
|
@@ -15635,6 +15742,9 @@ function StyledFormBlock({
|
|
|
15635
15742
|
const [resizing, setResizing] = (0, import_react29.useState)(null);
|
|
15636
15743
|
const resizeRef = (0, import_react29.useRef)(null);
|
|
15637
15744
|
const gridRef = (0, import_react29.useRef)(null);
|
|
15745
|
+
const relationDictRef = (0, import_react29.useRef)({});
|
|
15746
|
+
const relationRequestedRef = (0, import_react29.useRef)(/* @__PURE__ */ new Set());
|
|
15747
|
+
const [, bumpRelationLabels] = (0, import_react29.useState)(0);
|
|
15638
15748
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
15639
15749
|
(0, import_react29.useEffect)(() => {
|
|
15640
15750
|
let isMounted = true;
|
|
@@ -15655,19 +15765,57 @@ function StyledFormBlock({
|
|
|
15655
15765
|
isMounted = false;
|
|
15656
15766
|
};
|
|
15657
15767
|
}, [schema == null ? void 0 : schema.columns, targetTableId]);
|
|
15768
|
+
(0, import_react29.useEffect)(() => {
|
|
15769
|
+
if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
|
|
15770
|
+
const defaults = buildDefaultValues(columns);
|
|
15771
|
+
if (Object.keys(defaults).length === 0) return;
|
|
15772
|
+
setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
|
|
15773
|
+
}, [columns, submitMode, previewMode]);
|
|
15774
|
+
(0, import_react29.useEffect)(() => {
|
|
15775
|
+
if (previewMode || !executeAction || !columns) return;
|
|
15776
|
+
for (const col of columns) {
|
|
15777
|
+
if ((col.type || "").toUpperCase() !== "RELATION") continue;
|
|
15778
|
+
const cfg = col.config || {};
|
|
15779
|
+
if (!cfg.referencedTableId) continue;
|
|
15780
|
+
const need = normalizeRelationValue(formData[col.name]).filter(
|
|
15781
|
+
(id) => {
|
|
15782
|
+
var _a;
|
|
15783
|
+
return !((_a = relationDictRef.current[col.name]) == null ? void 0 : _a.has(id)) && !relationRequestedRef.current.has(`${col.name}:${id}`);
|
|
15784
|
+
}
|
|
15785
|
+
);
|
|
15786
|
+
if (need.length === 0) continue;
|
|
15787
|
+
need.forEach((id) => relationRequestedRef.current.add(`${col.name}:${id}`));
|
|
15788
|
+
executeAction("FETCH_RELATION", {
|
|
15789
|
+
referencedTableId: cfg.referencedTableId,
|
|
15790
|
+
displayField: cfg.displayField,
|
|
15791
|
+
recordIds: need,
|
|
15792
|
+
take: need.length,
|
|
15793
|
+
limit: need.length
|
|
15794
|
+
}).then((res) => {
|
|
15795
|
+
const rows = Array.isArray(res) ? res : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
|
|
15796
|
+
if (rows.length === 0) return;
|
|
15797
|
+
const map = relationDictRef.current[col.name] || /* @__PURE__ */ new Map();
|
|
15798
|
+
rows.forEach((r) => map.set(String(r.id), r));
|
|
15799
|
+
relationDictRef.current[col.name] = map;
|
|
15800
|
+
bumpRelationLabels((n) => n + 1);
|
|
15801
|
+
}).catch((err) => console.warn("[StyledFormBlock] relation label fetch failed:", err));
|
|
15802
|
+
}
|
|
15803
|
+
}, [columns, formData, previewMode, executeAction]);
|
|
15658
15804
|
const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
|
|
15659
15805
|
var _a, _b;
|
|
15660
15806
|
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
15661
15807
|
});
|
|
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
|
-
};
|
|
15808
|
+
const isDesignHidden = (col) => isFieldHidden(col, design);
|
|
15666
15809
|
const orderedColumns = applyFieldOrder(baseColumns, design);
|
|
15667
15810
|
const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
|
|
15668
15811
|
const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
|
|
15669
15812
|
const handleFieldChange = (colName, value) => {
|
|
15670
15813
|
setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: value }));
|
|
15814
|
+
if (missingNames.includes(colName)) {
|
|
15815
|
+
const left = missingNames.filter((n) => n !== colName);
|
|
15816
|
+
setMissingNames(left);
|
|
15817
|
+
if (left.length === 0) setFormError(null);
|
|
15818
|
+
}
|
|
15671
15819
|
};
|
|
15672
15820
|
const canReorder = !!onReorder;
|
|
15673
15821
|
const reorderFields = (fromName, toName, side) => {
|
|
@@ -15808,55 +15956,99 @@ function StyledFormBlock({
|
|
|
15808
15956
|
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
15957
|
return;
|
|
15810
15958
|
}
|
|
15959
|
+
if (submitMode === "update" && !recordId) {
|
|
15960
|
+
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");
|
|
15961
|
+
return;
|
|
15962
|
+
}
|
|
15963
|
+
const isEmptyValue = (col) => {
|
|
15964
|
+
var _a;
|
|
15965
|
+
const v = formData[col.name];
|
|
15966
|
+
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "BOOLEAN") return v !== true;
|
|
15967
|
+
return v === void 0 || v === null || v === "" || Array.isArray(v) && v.length === 0 || typeof v === "string" && v.trim() === "";
|
|
15968
|
+
};
|
|
15811
15969
|
const missingFields = formColumns.filter(
|
|
15812
|
-
(col) => col
|
|
15970
|
+
(col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && isEmptyValue(col)
|
|
15813
15971
|
);
|
|
15814
15972
|
if (missingFields.length > 0) {
|
|
15815
|
-
|
|
15973
|
+
const names = missingFields.map((c) => c.name);
|
|
15974
|
+
setMissingNames(names);
|
|
15975
|
+
setFormError(
|
|
15976
|
+
names.length === 1 ? `\u05E0\u05E8\u05D0\u05D4 \u05E9\u05E9\u05DB\u05D7\u05EA\u05DD \u05DC\u05DE\u05DC\u05D0 \u05D0\u05EA \u05D4\u05E9\u05D3\u05D4 "${names[0]}". \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05E9\u05DC\u05D9\u05DE\u05D5 \u05D0\u05D5\u05EA\u05D5 \u05D5\u05EA\u05E9\u05DC\u05D7\u05D5 \u05E9\u05D5\u05D1. \u05EA\u05D5\u05D3\u05D4!` : `\u05E0\u05E8\u05D0\u05D4 \u05E9\u05E9\u05DB\u05D7\u05EA\u05DD \u05DC\u05DE\u05DC\u05D0 \u05DB\u05DE\u05D4 \u05E9\u05D3\u05D5\u05EA \u05D7\u05D5\u05D1\u05D4: ${names.map((n) => `"${n}"`).join(", ")}. \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05E9\u05DC\u05D9\u05DE\u05D5 \u05D0\u05D5\u05EA\u05DD \u05D5\u05EA\u05E9\u05DC\u05D7\u05D5 \u05E9\u05D5\u05D1. \u05EA\u05D5\u05D3\u05D4!`
|
|
15977
|
+
);
|
|
15978
|
+
setTimeout(() => {
|
|
15979
|
+
var _a;
|
|
15980
|
+
return (_a = errorRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
15981
|
+
}, 0);
|
|
15816
15982
|
return;
|
|
15817
15983
|
}
|
|
15984
|
+
setFormError(null);
|
|
15985
|
+
setMissingNames([]);
|
|
15818
15986
|
setIsSubmitting(true);
|
|
15819
15987
|
try {
|
|
15820
15988
|
const payload = {};
|
|
15821
15989
|
formColumns.forEach((col) => {
|
|
15822
15990
|
var _a;
|
|
15991
|
+
if (isFieldLocked(col, design)) {
|
|
15992
|
+
const lockedDefault = parseColumnDefault(col);
|
|
15993
|
+
if (submitMode !== "update" && lockedDefault !== void 0) payload[col.name] = lockedDefault;
|
|
15994
|
+
return;
|
|
15995
|
+
}
|
|
15823
15996
|
let val = formData[col.name];
|
|
15824
15997
|
if (val !== void 0 && val !== null) {
|
|
15825
15998
|
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
|
|
15826
15999
|
payload[col.name] = val;
|
|
15827
|
-
} else if (
|
|
15828
|
-
|
|
16000
|
+
} else if (submitMode !== "update") {
|
|
16001
|
+
const dv = parseColumnDefault(col);
|
|
16002
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15829
16003
|
}
|
|
15830
16004
|
});
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
}
|
|
16005
|
+
if (submitMode === "update") {
|
|
16006
|
+
await executeAction("UPDATE_RECORD", {
|
|
16007
|
+
tableId: targetTableId,
|
|
16008
|
+
tableMetaId: targetTableId,
|
|
16009
|
+
recordId,
|
|
16010
|
+
data: payload
|
|
16011
|
+
});
|
|
16012
|
+
} else {
|
|
16013
|
+
hiddenColumns.forEach((col) => {
|
|
16014
|
+
const dv = parseColumnDefault(col);
|
|
16015
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
16016
|
+
});
|
|
16017
|
+
await executeAction("CREATE_RECORD", {
|
|
16018
|
+
tableId: targetTableId,
|
|
16019
|
+
tableMetaId: targetTableId,
|
|
16020
|
+
records: [payload]
|
|
16021
|
+
});
|
|
16022
|
+
}
|
|
15839
16023
|
addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
|
|
15840
|
-
setFormData(
|
|
16024
|
+
if (submitMode !== "update") setFormData(buildDefaultValues(columns));
|
|
15841
16025
|
setIsSubmitted(true);
|
|
15842
16026
|
if (onSuccess) onSuccess();
|
|
15843
16027
|
} catch (err) {
|
|
15844
16028
|
console.error("[StyledFormBlock] Submit error:", err);
|
|
15845
16029
|
showError((err == null ? void 0 : err.message) || String(err), "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05E9\u05DE\u05D9\u05E8\u05EA \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD");
|
|
16030
|
+
const raw = String((err == null ? void 0 : err.message) || "");
|
|
16031
|
+
setFormError(
|
|
16032
|
+
raw.startsWith("Validation Error") ? "\u05DC\u05D0 \u05D4\u05E6\u05DC\u05D7\u05E0\u05D5 \u05DC\u05E9\u05DE\u05D5\u05E8: \u05D7\u05DC\u05E7 \u05DE\u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D7\u05E1\u05E8\u05D9\u05DD \u05D0\u05D5 \u05D0\u05D9\u05E0\u05DD \u05EA\u05E7\u05D9\u05E0\u05D9\u05DD. \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05D1\u05D3\u05E7\u05D5 \u05D0\u05D5\u05EA\u05DD \u05D5\u05EA\u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1." : "\u05D0\u05D9\u05E8\u05E2\u05D4 \u05EA\u05E7\u05DC\u05D4 \u05D1\u05E9\u05DE\u05D9\u05E8\u05EA \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05D1\u05E2\u05D5\u05D3 \u05E8\u05D2\u05E2, \u05D5\u05D0\u05DD \u05D6\u05D4 \u05D7\u05D5\u05D6\u05E8 \u05E0\u05E9\u05DE\u05D7 \u05E9\u05EA\u05D9\u05E6\u05E8\u05D5 \u05D0\u05D9\u05EA\u05E0\u05D5 \u05E7\u05E9\u05E8."
|
|
16033
|
+
);
|
|
15846
16034
|
} finally {
|
|
15847
16035
|
setIsSubmitting(false);
|
|
15848
16036
|
}
|
|
15849
16037
|
};
|
|
15850
16038
|
const muted = t.invertText ? "rgba(255,255,255,0.85)" : "#64748b";
|
|
15851
|
-
const
|
|
16039
|
+
const frameCss = frameToCss(d.frame);
|
|
16040
|
+
const framed = !!d.frame && d.frame !== "none";
|
|
16041
|
+
const cardRadius = t.radius || (framed ? 12 : 0);
|
|
16042
|
+
const cardPadding = t.padding || (framed ? 24 : 0);
|
|
16043
|
+
const cardStyle = __spreadValues({
|
|
15852
16044
|
background: d.background,
|
|
15853
16045
|
color: d.text,
|
|
15854
|
-
borderRadius:
|
|
16046
|
+
borderRadius: cardRadius,
|
|
15855
16047
|
border: t.border,
|
|
15856
16048
|
boxShadow: t.shadow,
|
|
15857
|
-
padding: t.headerBand ? 0 :
|
|
16049
|
+
padding: t.headerBand ? 0 : cardPadding,
|
|
15858
16050
|
overflow: t.headerBand ? "hidden" : void 0
|
|
15859
|
-
};
|
|
16051
|
+
}, frameCss ? __spreadValues(__spreadValues(__spreadValues({}, frameCss.border !== void 0 ? { border: frameCss.border } : {}), frameCss.boxShadow ? { boxShadow: t.shadow && t.shadow !== "none" ? `${frameCss.boxShadow}, ${t.shadow}` : frameCss.boxShadow } : {}), frameCss.outline ? { outline: frameCss.outline, outlineOffset: frameCss.outlineOffset } : {}) : {});
|
|
15860
16052
|
const inputBoxStyle = t.inputStyle === "underline" ? { borderBottom: "1px solid #cbd5e1", borderRadius: 0, background: "transparent", minHeight: 40, position: "relative" } : {
|
|
15861
16053
|
border: "1px solid #e2e8f0",
|
|
15862
16054
|
borderRadius: Math.min(t.radius, 10) || 6,
|
|
@@ -15866,16 +16058,21 @@ function StyledFormBlock({
|
|
|
15866
16058
|
position: "relative"
|
|
15867
16059
|
};
|
|
15868
16060
|
const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
|
|
15869
|
-
minHeight: 0,
|
|
15870
16061
|
width: "fit-content",
|
|
15871
|
-
|
|
16062
|
+
minWidth: 40,
|
|
16063
|
+
alignSelf: "flex-start",
|
|
16064
|
+
display: "flex",
|
|
16065
|
+
alignItems: "center",
|
|
16066
|
+
justifyContent: "center"
|
|
15872
16067
|
});
|
|
15873
16068
|
const css = `
|
|
15874
16069
|
.${uid}{container-type:inline-size}
|
|
15875
|
-
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-
|
|
16070
|
+
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
|
|
15876
16071
|
.${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
16072
|
.${uid} .fdz-s1{--n:2}
|
|
15878
|
-
.${uid} .fdz-b{width:fit-content;max-width:
|
|
16073
|
+
.${uid} .fdz-b{width:fit-content;max-width:100%;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
|
|
16074
|
+
.${uid} .fdz-b label{white-space:nowrap}
|
|
16075
|
+
.${uid} [data-fdz-box] input:focus,.${uid} [data-fdz-box] input:focus-visible,.${uid} [data-fdz-box] select:focus,.${uid} [data-fdz-box] textarea:focus{outline:none!important;box-shadow:none!important;--tw-ring-shadow:0 0 #0000!important;--tw-ring-offset-shadow:0 0 #0000!important}
|
|
15879
16076
|
@container (min-width:480px){
|
|
15880
16077
|
.${uid} .fdz-f{--n:var(--span)}
|
|
15881
16078
|
}
|
|
@@ -15889,12 +16086,14 @@ function StyledFormBlock({
|
|
|
15889
16086
|
if (!formColumns || formColumns.length === 0) {
|
|
15890
16087
|
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
16088
|
}
|
|
15892
|
-
const
|
|
16089
|
+
const logoJustify = d.logoAlign === "center" ? "center" : d.logoAlign === "end" ? "flex-end" : "flex-start";
|
|
16090
|
+
const headerBlock = (schema == null ? void 0 : schema.title) || d.subtitle || d.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
15893
16091
|
"div",
|
|
15894
16092
|
{
|
|
15895
16093
|
style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
|
|
15896
16094
|
children: [
|
|
15897
|
-
(schema == null ? void 0 : schema.title)
|
|
16095
|
+
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" } }) }),
|
|
16096
|
+
(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
16097
|
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
16098
|
]
|
|
15900
16099
|
}
|
|
@@ -15921,7 +16120,7 @@ function StyledFormBlock({
|
|
|
15921
16120
|
),
|
|
15922
16121
|
/* @__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
16122
|
/* @__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)(
|
|
16123
|
+
submitMode !== "update" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
15925
16124
|
"button",
|
|
15926
16125
|
{
|
|
15927
16126
|
type: "button",
|
|
@@ -15950,9 +16149,11 @@ function StyledFormBlock({
|
|
|
15950
16149
|
const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
|
|
15951
16150
|
const span = spanOf(col);
|
|
15952
16151
|
const isBoolean = colType === "BOOLEAN";
|
|
15953
|
-
const
|
|
16152
|
+
const locked = isFieldLocked(col, design);
|
|
16153
|
+
const shownValue = (_c = formData[col.name]) != null ? _c : locked && submitMode !== "update" ? (_b = parseColumnDefault(col)) != null ? _b : "" : "";
|
|
16154
|
+
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
16155
|
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" } : {});
|
|
16156
|
+
const boxStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {}), missingNames.includes(col.name) ? t.inputStyle === "underline" ? { borderBottom: "2px solid #f43f5e" } : { border: "1px solid #f43f5e", boxShadow: "0 0 0 3px rgba(244,63,94,0.15)" } : {}), locked ? { background: t.inputStyle === "underline" ? "transparent" : "#f1f5f9", opacity: 0.85, cursor: "not-allowed" } : {});
|
|
15956
16157
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
15957
16158
|
"div",
|
|
15958
16159
|
{
|
|
@@ -15980,14 +16181,15 @@ function StyledFormBlock({
|
|
|
15980
16181
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
|
|
15981
16182
|
col.name,
|
|
15982
16183
|
" ",
|
|
15983
|
-
col
|
|
16184
|
+
isFieldRequired(col, design) && !locked && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { style: { color: t.invertText ? "#fecdd3" : "#f43f5e" }, children: "*" }),
|
|
16185
|
+
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
16186
|
] }),
|
|
15985
16187
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
15986
16188
|
"textarea",
|
|
15987
16189
|
{
|
|
15988
|
-
value:
|
|
16190
|
+
value: shownValue,
|
|
15989
16191
|
onChange: (e) => handleFieldChange(col.name, e.target.value),
|
|
15990
|
-
readOnly: previewMode,
|
|
16192
|
+
readOnly: previewMode || locked,
|
|
15991
16193
|
style: {
|
|
15992
16194
|
width: "100%",
|
|
15993
16195
|
height: "100%",
|
|
@@ -16007,10 +16209,10 @@ function StyledFormBlock({
|
|
|
16007
16209
|
{
|
|
16008
16210
|
column: col,
|
|
16009
16211
|
rowId: "new_form_record",
|
|
16010
|
-
value:
|
|
16212
|
+
value: shownValue,
|
|
16011
16213
|
onChange: (val) => handleFieldChange(col.name, val),
|
|
16012
|
-
readOnly: previewMode,
|
|
16013
|
-
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId }
|
|
16214
|
+
readOnly: previewMode || locked,
|
|
16215
|
+
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
|
|
16014
16216
|
}
|
|
16015
16217
|
) }),
|
|
16016
16218
|
canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
@@ -16058,6 +16260,25 @@ function StyledFormBlock({
|
|
|
16058
16260
|
};
|
|
16059
16261
|
return formColumns.map((col) => renderField(col));
|
|
16060
16262
|
})() }),
|
|
16263
|
+
formError && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
16264
|
+
"div",
|
|
16265
|
+
{
|
|
16266
|
+
ref: errorRef,
|
|
16267
|
+
role: "alert",
|
|
16268
|
+
"aria-live": "polite",
|
|
16269
|
+
style: {
|
|
16270
|
+
marginTop: t.gap + 8,
|
|
16271
|
+
padding: "10px 14px",
|
|
16272
|
+
borderRadius: Math.min(t.radius, 10) || 6,
|
|
16273
|
+
background: "#fff1f2",
|
|
16274
|
+
border: "1px solid #fda4af",
|
|
16275
|
+
color: "#9f1239",
|
|
16276
|
+
fontSize: 14,
|
|
16277
|
+
lineHeight: 1.5
|
|
16278
|
+
},
|
|
16279
|
+
children: formError
|
|
16280
|
+
}
|
|
16281
|
+
),
|
|
16061
16282
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
16062
16283
|
"div",
|
|
16063
16284
|
{
|
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,38 @@ 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
|
+
var FRAME_STYLES = ["none", "soft", "solid", "double"];
|
|
15485
|
+
function isFormFrameStyle(v) {
|
|
15486
|
+
return typeof v === "string" && FRAME_STYLES.includes(v);
|
|
15487
|
+
}
|
|
15488
|
+
function withAlpha(color, alpha) {
|
|
15489
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((color || "").trim());
|
|
15490
|
+
if (!m) return color;
|
|
15491
|
+
let h = m[1];
|
|
15492
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
15493
|
+
const n = parseInt(h, 16);
|
|
15494
|
+
return `rgba(${n >> 16 & 255}, ${n >> 8 & 255}, ${n & 255}, ${alpha})`;
|
|
15495
|
+
}
|
|
15496
|
+
function frameToCss(frame) {
|
|
15497
|
+
if (!frame) return null;
|
|
15498
|
+
if (frame === "none") return { border: "none" };
|
|
15499
|
+
const c = frame.color;
|
|
15500
|
+
switch (frame.style) {
|
|
15501
|
+
case "soft":
|
|
15502
|
+
return { border: `1.5px solid ${withAlpha(c, 0.4)}`, boxShadow: `0 0 0 5px ${withAlpha(c, 0.08)}` };
|
|
15503
|
+
case "solid":
|
|
15504
|
+
return { border: `2px solid ${c}` };
|
|
15505
|
+
case "double":
|
|
15506
|
+
return { border: `1.5px solid ${c}`, outline: `1px solid ${withAlpha(c, 0.55)}`, outlineOffset: -7 };
|
|
15507
|
+
}
|
|
15508
|
+
}
|
|
15509
|
+
function safeLogoUrl(url) {
|
|
15510
|
+
const u = (url || "").trim();
|
|
15511
|
+
if (!u) return void 0;
|
|
15512
|
+
if (/^https?:\/\//i.test(u)) return u;
|
|
15513
|
+
if (/^data:image\/(png|jpe?g|webp|gif);base64,[a-z0-9+/=]+$/i.test(u)) return u;
|
|
15514
|
+
return void 0;
|
|
15515
|
+
}
|
|
15471
15516
|
function resolveFormDesign(design) {
|
|
15472
15517
|
var _a, _b;
|
|
15473
15518
|
const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
|
|
@@ -15484,9 +15529,65 @@ function resolveFormDesign(design) {
|
|
|
15484
15529
|
buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
|
|
15485
15530
|
buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
|
|
15486
15531
|
subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
|
|
15487
|
-
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns
|
|
15532
|
+
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns,
|
|
15533
|
+
titleColor: (design == null ? void 0 : design.titleColor) || void 0,
|
|
15534
|
+
logoUrl: safeLogoUrl(design == null ? void 0 : design.logoUrl),
|
|
15535
|
+
logoHeight: Math.min(200, Math.max(24, Number(design == null ? void 0 : design.logoHeight) || 56)),
|
|
15536
|
+
logoAlign: (design == null ? void 0 : design.logoAlign) || "start",
|
|
15537
|
+
frame: isFormFrameStyle(design == null ? void 0 : design.frameStyle) ? design.frameStyle === "none" ? "none" : { style: design.frameStyle, color: (design == null ? void 0 : design.frameColor) || primary } : void 0
|
|
15488
15538
|
};
|
|
15489
15539
|
}
|
|
15540
|
+
var TODAY_DEFAULT_TOKEN = "@today";
|
|
15541
|
+
function todayIsoDate() {
|
|
15542
|
+
try {
|
|
15543
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
15544
|
+
timeZone: "Asia/Jerusalem",
|
|
15545
|
+
year: "numeric",
|
|
15546
|
+
month: "2-digit",
|
|
15547
|
+
day: "2-digit"
|
|
15548
|
+
}).format(/* @__PURE__ */ new Date());
|
|
15549
|
+
} catch (e) {
|
|
15550
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15551
|
+
}
|
|
15552
|
+
}
|
|
15553
|
+
function parseColumnDefault(col) {
|
|
15554
|
+
const raw = col.defaultValue;
|
|
15555
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
15556
|
+
const type = (col.type || "").toUpperCase();
|
|
15557
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
15558
|
+
if (first === void 0 || first === null || first === "") return void 0;
|
|
15559
|
+
switch (type) {
|
|
15560
|
+
case "NUMBER":
|
|
15561
|
+
case "CURRENCY": {
|
|
15562
|
+
const n = Number(first);
|
|
15563
|
+
return isNaN(n) ? void 0 : n;
|
|
15564
|
+
}
|
|
15565
|
+
case "BOOLEAN":
|
|
15566
|
+
return first === true || first === "true";
|
|
15567
|
+
case "DATE":
|
|
15568
|
+
return first === TODAY_DEFAULT_TOKEN ? todayIsoDate() : String(first);
|
|
15569
|
+
case "RELATION":
|
|
15570
|
+
return Array.isArray(raw) ? raw.map(String) : [String(first)];
|
|
15571
|
+
case "SUB_TABLE":
|
|
15572
|
+
case "SUBTABLE":
|
|
15573
|
+
case "LINK":
|
|
15574
|
+
case "GOOGLE_DRIVE_FILE":
|
|
15575
|
+
case "GOOGLE_CONTACT":
|
|
15576
|
+
case "FORMULA":
|
|
15577
|
+
case "SEQUENCE":
|
|
15578
|
+
return void 0;
|
|
15579
|
+
default:
|
|
15580
|
+
return String(first);
|
|
15581
|
+
}
|
|
15582
|
+
}
|
|
15583
|
+
function buildDefaultValues(cols) {
|
|
15584
|
+
const out = {};
|
|
15585
|
+
for (const c of cols || []) {
|
|
15586
|
+
const v = parseColumnDefault(c);
|
|
15587
|
+
if (v !== void 0) out[c.name] = v;
|
|
15588
|
+
}
|
|
15589
|
+
return out;
|
|
15590
|
+
}
|
|
15490
15591
|
function resolveFieldWidth(colName, colType, design, columnsDefault) {
|
|
15491
15592
|
var _a, _b;
|
|
15492
15593
|
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
|
|
@@ -15523,16 +15624,22 @@ function StyledFormBlock({
|
|
|
15523
15624
|
onSuccess,
|
|
15524
15625
|
previewMode = false,
|
|
15525
15626
|
onReorder,
|
|
15526
|
-
onFieldResize
|
|
15627
|
+
onFieldResize,
|
|
15628
|
+
initialValues,
|
|
15629
|
+
submitMode = "create",
|
|
15630
|
+
recordId
|
|
15527
15631
|
}) {
|
|
15528
15632
|
const { showError, addToast } = useToast();
|
|
15529
15633
|
const uid = "fdz" + useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
15530
15634
|
const design = schema == null ? void 0 : schema.design;
|
|
15531
15635
|
const d = resolveFormDesign(design);
|
|
15532
15636
|
const t = d.tokens;
|
|
15533
|
-
const [formData, setFormData] = useState22({});
|
|
15637
|
+
const [formData, setFormData] = useState22(initialValues || {});
|
|
15534
15638
|
const [isSubmitting, setIsSubmitting] = useState22(false);
|
|
15535
15639
|
const [isSubmitted, setIsSubmitted] = useState22(false);
|
|
15640
|
+
const [formError, setFormError] = useState22(null);
|
|
15641
|
+
const [missingNames, setMissingNames] = useState22([]);
|
|
15642
|
+
const errorRef = useRef20(null);
|
|
15536
15643
|
const [columns, setColumns] = useState22((schema == null ? void 0 : schema.columns) || []);
|
|
15537
15644
|
const [isLoadingSchema, setIsLoadingSchema] = useState22(false);
|
|
15538
15645
|
const [dragName, setDragName] = useState22(null);
|
|
@@ -15540,6 +15647,9 @@ function StyledFormBlock({
|
|
|
15540
15647
|
const [resizing, setResizing] = useState22(null);
|
|
15541
15648
|
const resizeRef = useRef20(null);
|
|
15542
15649
|
const gridRef = useRef20(null);
|
|
15650
|
+
const relationDictRef = useRef20({});
|
|
15651
|
+
const relationRequestedRef = useRef20(/* @__PURE__ */ new Set());
|
|
15652
|
+
const [, bumpRelationLabels] = useState22(0);
|
|
15543
15653
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
15544
15654
|
useEffect20(() => {
|
|
15545
15655
|
let isMounted = true;
|
|
@@ -15560,19 +15670,57 @@ function StyledFormBlock({
|
|
|
15560
15670
|
isMounted = false;
|
|
15561
15671
|
};
|
|
15562
15672
|
}, [schema == null ? void 0 : schema.columns, targetTableId]);
|
|
15673
|
+
useEffect20(() => {
|
|
15674
|
+
if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
|
|
15675
|
+
const defaults = buildDefaultValues(columns);
|
|
15676
|
+
if (Object.keys(defaults).length === 0) return;
|
|
15677
|
+
setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
|
|
15678
|
+
}, [columns, submitMode, previewMode]);
|
|
15679
|
+
useEffect20(() => {
|
|
15680
|
+
if (previewMode || !executeAction || !columns) return;
|
|
15681
|
+
for (const col of columns) {
|
|
15682
|
+
if ((col.type || "").toUpperCase() !== "RELATION") continue;
|
|
15683
|
+
const cfg = col.config || {};
|
|
15684
|
+
if (!cfg.referencedTableId) continue;
|
|
15685
|
+
const need = normalizeRelationValue(formData[col.name]).filter(
|
|
15686
|
+
(id) => {
|
|
15687
|
+
var _a;
|
|
15688
|
+
return !((_a = relationDictRef.current[col.name]) == null ? void 0 : _a.has(id)) && !relationRequestedRef.current.has(`${col.name}:${id}`);
|
|
15689
|
+
}
|
|
15690
|
+
);
|
|
15691
|
+
if (need.length === 0) continue;
|
|
15692
|
+
need.forEach((id) => relationRequestedRef.current.add(`${col.name}:${id}`));
|
|
15693
|
+
executeAction("FETCH_RELATION", {
|
|
15694
|
+
referencedTableId: cfg.referencedTableId,
|
|
15695
|
+
displayField: cfg.displayField,
|
|
15696
|
+
recordIds: need,
|
|
15697
|
+
take: need.length,
|
|
15698
|
+
limit: need.length
|
|
15699
|
+
}).then((res) => {
|
|
15700
|
+
const rows = Array.isArray(res) ? res : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
|
|
15701
|
+
if (rows.length === 0) return;
|
|
15702
|
+
const map = relationDictRef.current[col.name] || /* @__PURE__ */ new Map();
|
|
15703
|
+
rows.forEach((r) => map.set(String(r.id), r));
|
|
15704
|
+
relationDictRef.current[col.name] = map;
|
|
15705
|
+
bumpRelationLabels((n) => n + 1);
|
|
15706
|
+
}).catch((err) => console.warn("[StyledFormBlock] relation label fetch failed:", err));
|
|
15707
|
+
}
|
|
15708
|
+
}, [columns, formData, previewMode, executeAction]);
|
|
15563
15709
|
const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
|
|
15564
15710
|
var _a, _b;
|
|
15565
15711
|
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
15566
15712
|
});
|
|
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
|
-
};
|
|
15713
|
+
const isDesignHidden = (col) => isFieldHidden(col, design);
|
|
15571
15714
|
const orderedColumns = applyFieldOrder(baseColumns, design);
|
|
15572
15715
|
const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
|
|
15573
15716
|
const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
|
|
15574
15717
|
const handleFieldChange = (colName, value) => {
|
|
15575
15718
|
setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: value }));
|
|
15719
|
+
if (missingNames.includes(colName)) {
|
|
15720
|
+
const left = missingNames.filter((n) => n !== colName);
|
|
15721
|
+
setMissingNames(left);
|
|
15722
|
+
if (left.length === 0) setFormError(null);
|
|
15723
|
+
}
|
|
15576
15724
|
};
|
|
15577
15725
|
const canReorder = !!onReorder;
|
|
15578
15726
|
const reorderFields = (fromName, toName, side) => {
|
|
@@ -15713,55 +15861,99 @@ function StyledFormBlock({
|
|
|
15713
15861
|
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
15862
|
return;
|
|
15715
15863
|
}
|
|
15864
|
+
if (submitMode === "update" && !recordId) {
|
|
15865
|
+
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");
|
|
15866
|
+
return;
|
|
15867
|
+
}
|
|
15868
|
+
const isEmptyValue = (col) => {
|
|
15869
|
+
var _a;
|
|
15870
|
+
const v = formData[col.name];
|
|
15871
|
+
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "BOOLEAN") return v !== true;
|
|
15872
|
+
return v === void 0 || v === null || v === "" || Array.isArray(v) && v.length === 0 || typeof v === "string" && v.trim() === "";
|
|
15873
|
+
};
|
|
15716
15874
|
const missingFields = formColumns.filter(
|
|
15717
|
-
(col) => col
|
|
15875
|
+
(col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && isEmptyValue(col)
|
|
15718
15876
|
);
|
|
15719
15877
|
if (missingFields.length > 0) {
|
|
15720
|
-
|
|
15878
|
+
const names = missingFields.map((c) => c.name);
|
|
15879
|
+
setMissingNames(names);
|
|
15880
|
+
setFormError(
|
|
15881
|
+
names.length === 1 ? `\u05E0\u05E8\u05D0\u05D4 \u05E9\u05E9\u05DB\u05D7\u05EA\u05DD \u05DC\u05DE\u05DC\u05D0 \u05D0\u05EA \u05D4\u05E9\u05D3\u05D4 "${names[0]}". \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05E9\u05DC\u05D9\u05DE\u05D5 \u05D0\u05D5\u05EA\u05D5 \u05D5\u05EA\u05E9\u05DC\u05D7\u05D5 \u05E9\u05D5\u05D1. \u05EA\u05D5\u05D3\u05D4!` : `\u05E0\u05E8\u05D0\u05D4 \u05E9\u05E9\u05DB\u05D7\u05EA\u05DD \u05DC\u05DE\u05DC\u05D0 \u05DB\u05DE\u05D4 \u05E9\u05D3\u05D5\u05EA \u05D7\u05D5\u05D1\u05D4: ${names.map((n) => `"${n}"`).join(", ")}. \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05E9\u05DC\u05D9\u05DE\u05D5 \u05D0\u05D5\u05EA\u05DD \u05D5\u05EA\u05E9\u05DC\u05D7\u05D5 \u05E9\u05D5\u05D1. \u05EA\u05D5\u05D3\u05D4!`
|
|
15882
|
+
);
|
|
15883
|
+
setTimeout(() => {
|
|
15884
|
+
var _a;
|
|
15885
|
+
return (_a = errorRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
15886
|
+
}, 0);
|
|
15721
15887
|
return;
|
|
15722
15888
|
}
|
|
15889
|
+
setFormError(null);
|
|
15890
|
+
setMissingNames([]);
|
|
15723
15891
|
setIsSubmitting(true);
|
|
15724
15892
|
try {
|
|
15725
15893
|
const payload = {};
|
|
15726
15894
|
formColumns.forEach((col) => {
|
|
15727
15895
|
var _a;
|
|
15896
|
+
if (isFieldLocked(col, design)) {
|
|
15897
|
+
const lockedDefault = parseColumnDefault(col);
|
|
15898
|
+
if (submitMode !== "update" && lockedDefault !== void 0) payload[col.name] = lockedDefault;
|
|
15899
|
+
return;
|
|
15900
|
+
}
|
|
15728
15901
|
let val = formData[col.name];
|
|
15729
15902
|
if (val !== void 0 && val !== null) {
|
|
15730
15903
|
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
|
|
15731
15904
|
payload[col.name] = val;
|
|
15732
|
-
} else if (
|
|
15733
|
-
|
|
15905
|
+
} else if (submitMode !== "update") {
|
|
15906
|
+
const dv = parseColumnDefault(col);
|
|
15907
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15734
15908
|
}
|
|
15735
15909
|
});
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
}
|
|
15910
|
+
if (submitMode === "update") {
|
|
15911
|
+
await executeAction("UPDATE_RECORD", {
|
|
15912
|
+
tableId: targetTableId,
|
|
15913
|
+
tableMetaId: targetTableId,
|
|
15914
|
+
recordId,
|
|
15915
|
+
data: payload
|
|
15916
|
+
});
|
|
15917
|
+
} else {
|
|
15918
|
+
hiddenColumns.forEach((col) => {
|
|
15919
|
+
const dv = parseColumnDefault(col);
|
|
15920
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15921
|
+
});
|
|
15922
|
+
await executeAction("CREATE_RECORD", {
|
|
15923
|
+
tableId: targetTableId,
|
|
15924
|
+
tableMetaId: targetTableId,
|
|
15925
|
+
records: [payload]
|
|
15926
|
+
});
|
|
15927
|
+
}
|
|
15744
15928
|
addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
|
|
15745
|
-
setFormData(
|
|
15929
|
+
if (submitMode !== "update") setFormData(buildDefaultValues(columns));
|
|
15746
15930
|
setIsSubmitted(true);
|
|
15747
15931
|
if (onSuccess) onSuccess();
|
|
15748
15932
|
} catch (err) {
|
|
15749
15933
|
console.error("[StyledFormBlock] Submit error:", err);
|
|
15750
15934
|
showError((err == null ? void 0 : err.message) || String(err), "\u05E9\u05D2\u05D9\u05D0\u05D4 \u05D1\u05E9\u05DE\u05D9\u05E8\u05EA \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD");
|
|
15935
|
+
const raw = String((err == null ? void 0 : err.message) || "");
|
|
15936
|
+
setFormError(
|
|
15937
|
+
raw.startsWith("Validation Error") ? "\u05DC\u05D0 \u05D4\u05E6\u05DC\u05D7\u05E0\u05D5 \u05DC\u05E9\u05DE\u05D5\u05E8: \u05D7\u05DC\u05E7 \u05DE\u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D7\u05E1\u05E8\u05D9\u05DD \u05D0\u05D5 \u05D0\u05D9\u05E0\u05DD \u05EA\u05E7\u05D9\u05E0\u05D9\u05DD. \u05E0\u05E9\u05DE\u05D7 \u05D0\u05DD \u05EA\u05D1\u05D3\u05E7\u05D5 \u05D0\u05D5\u05EA\u05DD \u05D5\u05EA\u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1." : "\u05D0\u05D9\u05E8\u05E2\u05D4 \u05EA\u05E7\u05DC\u05D4 \u05D1\u05E9\u05DE\u05D9\u05E8\u05EA \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05D1\u05E2\u05D5\u05D3 \u05E8\u05D2\u05E2, \u05D5\u05D0\u05DD \u05D6\u05D4 \u05D7\u05D5\u05D6\u05E8 \u05E0\u05E9\u05DE\u05D7 \u05E9\u05EA\u05D9\u05E6\u05E8\u05D5 \u05D0\u05D9\u05EA\u05E0\u05D5 \u05E7\u05E9\u05E8."
|
|
15938
|
+
);
|
|
15751
15939
|
} finally {
|
|
15752
15940
|
setIsSubmitting(false);
|
|
15753
15941
|
}
|
|
15754
15942
|
};
|
|
15755
15943
|
const muted = t.invertText ? "rgba(255,255,255,0.85)" : "#64748b";
|
|
15756
|
-
const
|
|
15944
|
+
const frameCss = frameToCss(d.frame);
|
|
15945
|
+
const framed = !!d.frame && d.frame !== "none";
|
|
15946
|
+
const cardRadius = t.radius || (framed ? 12 : 0);
|
|
15947
|
+
const cardPadding = t.padding || (framed ? 24 : 0);
|
|
15948
|
+
const cardStyle = __spreadValues({
|
|
15757
15949
|
background: d.background,
|
|
15758
15950
|
color: d.text,
|
|
15759
|
-
borderRadius:
|
|
15951
|
+
borderRadius: cardRadius,
|
|
15760
15952
|
border: t.border,
|
|
15761
15953
|
boxShadow: t.shadow,
|
|
15762
|
-
padding: t.headerBand ? 0 :
|
|
15954
|
+
padding: t.headerBand ? 0 : cardPadding,
|
|
15763
15955
|
overflow: t.headerBand ? "hidden" : void 0
|
|
15764
|
-
};
|
|
15956
|
+
}, frameCss ? __spreadValues(__spreadValues(__spreadValues({}, frameCss.border !== void 0 ? { border: frameCss.border } : {}), frameCss.boxShadow ? { boxShadow: t.shadow && t.shadow !== "none" ? `${frameCss.boxShadow}, ${t.shadow}` : frameCss.boxShadow } : {}), frameCss.outline ? { outline: frameCss.outline, outlineOffset: frameCss.outlineOffset } : {}) : {});
|
|
15765
15957
|
const inputBoxStyle = t.inputStyle === "underline" ? { borderBottom: "1px solid #cbd5e1", borderRadius: 0, background: "transparent", minHeight: 40, position: "relative" } : {
|
|
15766
15958
|
border: "1px solid #e2e8f0",
|
|
15767
15959
|
borderRadius: Math.min(t.radius, 10) || 6,
|
|
@@ -15771,16 +15963,21 @@ function StyledFormBlock({
|
|
|
15771
15963
|
position: "relative"
|
|
15772
15964
|
};
|
|
15773
15965
|
const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
|
|
15774
|
-
minHeight: 0,
|
|
15775
15966
|
width: "fit-content",
|
|
15776
|
-
|
|
15967
|
+
minWidth: 40,
|
|
15968
|
+
alignSelf: "flex-start",
|
|
15969
|
+
display: "flex",
|
|
15970
|
+
alignItems: "center",
|
|
15971
|
+
justifyContent: "center"
|
|
15777
15972
|
});
|
|
15778
15973
|
const css = `
|
|
15779
15974
|
.${uid}{container-type:inline-size}
|
|
15780
|
-
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-
|
|
15975
|
+
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
|
|
15781
15976
|
.${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
15977
|
.${uid} .fdz-s1{--n:2}
|
|
15783
|
-
.${uid} .fdz-b{width:fit-content;max-width:
|
|
15978
|
+
.${uid} .fdz-b{width:fit-content;max-width:100%;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
|
|
15979
|
+
.${uid} .fdz-b label{white-space:nowrap}
|
|
15980
|
+
.${uid} [data-fdz-box] input:focus,.${uid} [data-fdz-box] input:focus-visible,.${uid} [data-fdz-box] select:focus,.${uid} [data-fdz-box] textarea:focus{outline:none!important;box-shadow:none!important;--tw-ring-shadow:0 0 #0000!important;--tw-ring-offset-shadow:0 0 #0000!important}
|
|
15784
15981
|
@container (min-width:480px){
|
|
15785
15982
|
.${uid} .fdz-f{--n:var(--span)}
|
|
15786
15983
|
}
|
|
@@ -15794,12 +15991,14 @@ function StyledFormBlock({
|
|
|
15794
15991
|
if (!formColumns || formColumns.length === 0) {
|
|
15795
15992
|
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
15993
|
}
|
|
15797
|
-
const
|
|
15994
|
+
const logoJustify = d.logoAlign === "center" ? "center" : d.logoAlign === "end" ? "flex-end" : "flex-start";
|
|
15995
|
+
const headerBlock = (schema == null ? void 0 : schema.title) || d.subtitle || d.logoUrl ? /* @__PURE__ */ jsxs26(
|
|
15798
15996
|
"div",
|
|
15799
15997
|
{
|
|
15800
15998
|
style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
|
|
15801
15999
|
children: [
|
|
15802
|
-
(schema == null ? void 0 : schema.title)
|
|
16000
|
+
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" } }) }),
|
|
16001
|
+
(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
16002
|
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
16003
|
]
|
|
15805
16004
|
}
|
|
@@ -15826,7 +16025,7 @@ function StyledFormBlock({
|
|
|
15826
16025
|
),
|
|
15827
16026
|
/* @__PURE__ */ jsx30("h3", { style: { fontSize: 24, fontWeight: 800, margin: "0 0 8px" }, children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
|
|
15828
16027
|
/* @__PURE__ */ jsx30("p", { style: { fontSize: 16, color: muted, maxWidth: 420, margin: "0 auto", whiteSpace: "pre-wrap" }, children: customMessage }),
|
|
15829
|
-
/* @__PURE__ */ jsx30(
|
|
16028
|
+
submitMode !== "update" && /* @__PURE__ */ jsx30(
|
|
15830
16029
|
"button",
|
|
15831
16030
|
{
|
|
15832
16031
|
type: "button",
|
|
@@ -15855,9 +16054,11 @@ function StyledFormBlock({
|
|
|
15855
16054
|
const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
|
|
15856
16055
|
const span = spanOf(col);
|
|
15857
16056
|
const isBoolean = colType === "BOOLEAN";
|
|
15858
|
-
const
|
|
16057
|
+
const locked = isFieldLocked(col, design);
|
|
16058
|
+
const shownValue = (_c = formData[col.name]) != null ? _c : locked && submitMode !== "update" ? (_b = parseColumnDefault(col)) != null ? _b : "" : "";
|
|
16059
|
+
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
16060
|
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" } : {});
|
|
16061
|
+
const boxStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {}), missingNames.includes(col.name) ? t.inputStyle === "underline" ? { borderBottom: "2px solid #f43f5e" } : { border: "1px solid #f43f5e", boxShadow: "0 0 0 3px rgba(244,63,94,0.15)" } : {}), locked ? { background: t.inputStyle === "underline" ? "transparent" : "#f1f5f9", opacity: 0.85, cursor: "not-allowed" } : {});
|
|
15861
16062
|
return /* @__PURE__ */ jsxs26(
|
|
15862
16063
|
"div",
|
|
15863
16064
|
{
|
|
@@ -15885,14 +16086,15 @@ function StyledFormBlock({
|
|
|
15885
16086
|
/* @__PURE__ */ jsxs26("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
|
|
15886
16087
|
col.name,
|
|
15887
16088
|
" ",
|
|
15888
|
-
col
|
|
16089
|
+
isFieldRequired(col, design) && !locked && /* @__PURE__ */ jsx30("span", { style: { color: t.invertText ? "#fecdd3" : "#f43f5e" }, children: "*" }),
|
|
16090
|
+
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
16091
|
] }),
|
|
15890
16092
|
/* @__PURE__ */ jsx30("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ jsx30(
|
|
15891
16093
|
"textarea",
|
|
15892
16094
|
{
|
|
15893
|
-
value:
|
|
16095
|
+
value: shownValue,
|
|
15894
16096
|
onChange: (e) => handleFieldChange(col.name, e.target.value),
|
|
15895
|
-
readOnly: previewMode,
|
|
16097
|
+
readOnly: previewMode || locked,
|
|
15896
16098
|
style: {
|
|
15897
16099
|
width: "100%",
|
|
15898
16100
|
height: "100%",
|
|
@@ -15912,10 +16114,10 @@ function StyledFormBlock({
|
|
|
15912
16114
|
{
|
|
15913
16115
|
column: col,
|
|
15914
16116
|
rowId: "new_form_record",
|
|
15915
|
-
value:
|
|
16117
|
+
value: shownValue,
|
|
15916
16118
|
onChange: (val) => handleFieldChange(col.name, val),
|
|
15917
|
-
readOnly: previewMode,
|
|
15918
|
-
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId }
|
|
16119
|
+
readOnly: previewMode || locked,
|
|
16120
|
+
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
|
|
15919
16121
|
}
|
|
15920
16122
|
) }),
|
|
15921
16123
|
canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ jsx30(
|
|
@@ -15963,6 +16165,25 @@ function StyledFormBlock({
|
|
|
15963
16165
|
};
|
|
15964
16166
|
return formColumns.map((col) => renderField(col));
|
|
15965
16167
|
})() }),
|
|
16168
|
+
formError && /* @__PURE__ */ jsx30(
|
|
16169
|
+
"div",
|
|
16170
|
+
{
|
|
16171
|
+
ref: errorRef,
|
|
16172
|
+
role: "alert",
|
|
16173
|
+
"aria-live": "polite",
|
|
16174
|
+
style: {
|
|
16175
|
+
marginTop: t.gap + 8,
|
|
16176
|
+
padding: "10px 14px",
|
|
16177
|
+
borderRadius: Math.min(t.radius, 10) || 6,
|
|
16178
|
+
background: "#fff1f2",
|
|
16179
|
+
border: "1px solid #fda4af",
|
|
16180
|
+
color: "#9f1239",
|
|
16181
|
+
fontSize: 14,
|
|
16182
|
+
lineHeight: 1.5
|
|
16183
|
+
},
|
|
16184
|
+
children: formError
|
|
16185
|
+
}
|
|
16186
|
+
),
|
|
15966
16187
|
/* @__PURE__ */ jsx30(
|
|
15967
16188
|
"div",
|
|
15968
16189
|
{
|