@universe-platform/ui 0.1.0-beta.54 → 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.js CHANGED
@@ -15465,28 +15465,268 @@ function WhatsAppComponent(props) {
15465
15465
  var import_react28 = require("react");
15466
15466
  var import_lucide_react18 = require("lucide-react");
15467
15467
  var import_jsx_runtime29 = require("react/jsx-runtime");
15468
- function FormBlock({ settings: schema, executeAction, componentId, className = "", onSuccess }) {
15468
+
15469
+ // src/components/FormBlock/StyledFormBlock.tsx
15470
+ var import_react29 = require("react");
15471
+ var import_lucide_react19 = require("lucide-react");
15472
+
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
+ }
15487
+ var FORM_PRESETS = {
15488
+ classic: {
15489
+ label: "\u05E7\u05DC\u05D0\u05E1\u05D9",
15490
+ description: "\u05DB\u05E8\u05D8\u05D9\u05E1 \u05DC\u05D1\u05DF, \u05E9\u05D3\u05D4 \u05D1\u05DB\u05DC \u05E9\u05D5\u05E8\u05D4",
15491
+ radius: 12,
15492
+ padding: 24,
15493
+ gap: 16,
15494
+ labelSize: 14,
15495
+ titleSize: 20,
15496
+ border: "1px solid #e2e8f0",
15497
+ shadow: "0 1px 2px rgba(0,0,0,0.05)",
15498
+ headerBand: false,
15499
+ inputStyle: "box",
15500
+ defaultColumns: 1,
15501
+ defaultBackground: "#ffffff",
15502
+ defaultText: "#1e293b",
15503
+ invertText: false
15504
+ },
15505
+ compact: {
15506
+ label: "\u05E7\u05D5\u05DE\u05E4\u05E7\u05D8\u05D9",
15507
+ description: "\u05E9\u05E0\u05D9 \u05E9\u05D3\u05D5\u05EA \u05D1\u05E9\u05D5\u05E8\u05D4, \u05E8\u05D9\u05D5\u05D5\u05D7 \u05E7\u05D8\u05DF - \u05D8\u05D5\u05E4\u05E1 \u05E7\u05E6\u05E8 \u05D9\u05D5\u05EA\u05E8",
15508
+ radius: 10,
15509
+ padding: 16,
15510
+ gap: 10,
15511
+ labelSize: 12,
15512
+ titleSize: 18,
15513
+ border: "1px solid #e2e8f0",
15514
+ shadow: "0 1px 2px rgba(0,0,0,0.05)",
15515
+ headerBand: false,
15516
+ inputStyle: "box",
15517
+ defaultColumns: 2,
15518
+ defaultBackground: "#ffffff",
15519
+ defaultText: "#1e293b",
15520
+ invertText: false
15521
+ },
15522
+ card: {
15523
+ label: "\u05DB\u05E8\u05D8\u05D9\u05E1",
15524
+ description: "\u05E4\u05D9\u05E0\u05D5\u05EA \u05E2\u05D2\u05D5\u05DC\u05D5\u05EA, \u05E6\u05DC, \u05DB\u05D5\u05EA\u05E8\u05EA \u05E2\u05DC \u05E4\u05E1 \u05E6\u05D1\u05E2\u05D5\u05E0\u05D9",
15525
+ radius: 20,
15526
+ padding: 28,
15527
+ gap: 18,
15528
+ labelSize: 14,
15529
+ titleSize: 22,
15530
+ border: "none",
15531
+ shadow: "0 20px 40px -12px rgba(15,23,42,0.18)",
15532
+ headerBand: true,
15533
+ inputStyle: "box",
15534
+ defaultColumns: 2,
15535
+ defaultBackground: "#ffffff",
15536
+ defaultText: "#1e293b",
15537
+ invertText: false
15538
+ },
15539
+ minimal: {
15540
+ label: "\u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9\u05E1\u05D8\u05D9",
15541
+ description: "\u05D1\u05DC\u05D9 \u05DE\u05E1\u05D2\u05E8\u05EA, \u05E7\u05D5 \u05EA\u05D7\u05EA\u05D5\u05DF \u05DC\u05E9\u05D3\u05D5\u05EA",
15542
+ radius: 0,
15543
+ padding: 0,
15544
+ gap: 20,
15545
+ labelSize: 13,
15546
+ titleSize: 22,
15547
+ border: "none",
15548
+ shadow: "none",
15549
+ headerBand: false,
15550
+ inputStyle: "underline",
15551
+ defaultColumns: 1,
15552
+ defaultBackground: "transparent",
15553
+ defaultText: "#1e293b",
15554
+ invertText: false
15555
+ },
15556
+ bold: {
15557
+ label: "\u05D1\u05D5\u05DC\u05D8",
15558
+ description: "\u05E8\u05E7\u05E2 \u05D1\u05E6\u05D1\u05E2 \u05D4\u05DE\u05D5\u05EA\u05D2 \u05D5\u05D8\u05E7\u05E1\u05D8 \u05DC\u05D1\u05DF",
15559
+ radius: 16,
15560
+ padding: 28,
15561
+ gap: 16,
15562
+ labelSize: 14,
15563
+ titleSize: 22,
15564
+ border: "none",
15565
+ shadow: "0 10px 30px -10px rgba(0,0,0,0.3)",
15566
+ headerBand: false,
15567
+ inputStyle: "box",
15568
+ defaultColumns: 1,
15569
+ defaultBackground: "",
15570
+ defaultText: "#ffffff",
15571
+ invertText: true
15572
+ }
15573
+ };
15574
+ var DEFAULT_PRIMARY = "#00b7a2";
15575
+ var ALWAYS_FULL_TYPES = /* @__PURE__ */ new Set(["GOOGLE_DRIVE_FILE", "SUB_TABLE", "SUBTABLE", "LINK"]);
15576
+ function isFormPresetId(v) {
15577
+ return typeof v === "string" && v in FORM_PRESETS;
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
+ }
15586
+ function resolveFormDesign(design) {
15587
+ var _a, _b;
15588
+ const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
15589
+ const tokens = FORM_PRESETS[presetId];
15590
+ const primary = (design == null ? void 0 : design.primaryColor) || DEFAULT_PRIMARY;
15591
+ const background = (design == null ? void 0 : design.backgroundColor) || (tokens.invertText ? primary : tokens.defaultBackground);
15592
+ const text2 = (design == null ? void 0 : design.textColor) || tokens.defaultText;
15593
+ return {
15594
+ tokens,
15595
+ presetId,
15596
+ primary,
15597
+ background,
15598
+ text: text2,
15599
+ buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
15600
+ buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
15601
+ subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
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"
15607
+ };
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
+ }
15660
+ function resolveFieldWidth(colName, colType, design, columnsDefault) {
15661
+ var _a, _b;
15662
+ const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
15663
+ if (manual) return manual;
15664
+ if ((colType || "").toUpperCase() === "BOOLEAN") return "third";
15665
+ if (ALWAYS_FULL_TYPES.has((colType || "").toUpperCase())) return "full";
15666
+ return columnsDefault === 3 ? "third" : columnsDefault === 2 ? "half" : "full";
15667
+ }
15668
+ var WIDTH_TO_SPAN = { full: 6, half: 3, third: 2, sixth: 1 };
15669
+ function resolveFieldSpan(colName, colType, design, columnsDefault) {
15670
+ var _a, _b;
15671
+ const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.span;
15672
+ if (manual && manual >= 1 && manual <= 6) return manual;
15673
+ return WIDTH_TO_SPAN[resolveFieldWidth(colName, colType, design, columnsDefault)];
15674
+ }
15675
+ function applyFieldOrder(cols, design) {
15676
+ const order = design == null ? void 0 : design.fieldOrder;
15677
+ if (!order || order.length === 0) return cols;
15678
+ const idx = (n) => {
15679
+ const i = order.indexOf(n);
15680
+ return i === -1 ? Number.MAX_SAFE_INTEGER : i;
15681
+ };
15682
+ return cols.map((c, i) => ({ c, i })).sort((a, b) => idx(a.c.name) - idx(b.c.name) || a.i - b.i).map((x) => x.c);
15683
+ }
15684
+
15685
+ // src/components/FormBlock/StyledFormBlock.tsx
15686
+ var import_jsx_runtime30 = require("react/jsx-runtime");
15687
+ var SYSTEM_FIELDS = ["_id", "id", "createdAt", "updatedAt", "orgId", "tableId"];
15688
+ function StyledFormBlock({
15689
+ settings: schema,
15690
+ executeAction,
15691
+ componentId,
15692
+ className = "",
15693
+ onSuccess,
15694
+ previewMode = false,
15695
+ onReorder,
15696
+ onFieldResize,
15697
+ initialValues,
15698
+ submitMode = "create",
15699
+ recordId
15700
+ }) {
15469
15701
  const { showError, addToast } = useToast();
15470
- const [formData, setFormData] = (0, import_react28.useState)({});
15471
- const [isSubmitting, setIsSubmitting] = (0, import_react28.useState)(false);
15472
- const [isSubmitted, setIsSubmitted] = (0, import_react28.useState)(false);
15473
- const [columns, setColumns] = (0, import_react28.useState)((schema == null ? void 0 : schema.columns) || []);
15474
- const [isLoadingSchema, setIsLoadingSchema] = (0, import_react28.useState)(false);
15702
+ const uid = "fdz" + (0, import_react29.useId)().replace(/[^a-zA-Z0-9]/g, "");
15703
+ const design = schema == null ? void 0 : schema.design;
15704
+ const d = resolveFormDesign(design);
15705
+ const t = d.tokens;
15706
+ const [formData, setFormData] = (0, import_react29.useState)(initialValues || {});
15707
+ const [isSubmitting, setIsSubmitting] = (0, import_react29.useState)(false);
15708
+ const [isSubmitted, setIsSubmitted] = (0, import_react29.useState)(false);
15709
+ const [columns, setColumns] = (0, import_react29.useState)((schema == null ? void 0 : schema.columns) || []);
15710
+ const [isLoadingSchema, setIsLoadingSchema] = (0, import_react29.useState)(false);
15711
+ const [dragName, setDragName] = (0, import_react29.useState)(null);
15712
+ const [drop, setDrop] = (0, import_react29.useState)(null);
15713
+ const [resizing, setResizing] = (0, import_react29.useState)(null);
15714
+ const resizeRef = (0, import_react29.useRef)(null);
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);
15475
15719
  const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
15476
- (0, import_react28.useEffect)(() => {
15720
+ (0, import_react29.useEffect)(() => {
15477
15721
  let isMounted = true;
15478
- if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction) {
15722
+ if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction && !previewMode) {
15479
15723
  setIsLoadingSchema(true);
15480
15724
  executeAction("FETCH_TABLE_DATA", { tableId: targetTableId, limit: 1 }).then((res) => {
15481
15725
  var _a;
15482
15726
  if (!isMounted) return;
15483
15727
  const fetchedCols = ((_a = res == null ? void 0 : res.schema) == null ? void 0 : _a.columns) || (res == null ? void 0 : res.columns);
15484
- if (fetchedCols && Array.isArray(fetchedCols)) {
15485
- setColumns(fetchedCols);
15486
- }
15487
- }).catch((err) => {
15488
- console.error("[FormBlock] Failed to fetch table schema:", err);
15489
- }).finally(() => {
15728
+ if (fetchedCols && Array.isArray(fetchedCols)) setColumns(fetchedCols);
15729
+ }).catch((err) => console.error("[StyledFormBlock] Failed to fetch table schema:", err)).finally(() => {
15490
15730
  if (isMounted) setIsLoadingSchema(false);
15491
15731
  });
15492
15732
  } else if (schema == null ? void 0 : schema.columns) {
@@ -15496,18 +15736,184 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
15496
15736
  isMounted = false;
15497
15737
  };
15498
15738
  }, [schema == null ? void 0 : schema.columns, targetTableId]);
15499
- const systemFields = ["_id", "id", "createdAt", "updatedAt", "orgId", "tableId"];
15500
- const formColumns = (columns || []).filter(
15501
- (col) => !systemFields.includes(col.name) && !col.isHidden
15502
- ).sort((a, b) => {
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]);
15775
+ const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
15503
15776
  var _a, _b;
15504
15777
  return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
15505
15778
  });
15779
+ const isDesignHidden = (col) => isFieldHidden(col, design);
15780
+ const orderedColumns = applyFieldOrder(baseColumns, design);
15781
+ const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
15782
+ const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
15506
15783
  const handleFieldChange = (colName, value) => {
15507
15784
  setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: value }));
15508
15785
  };
15786
+ const canReorder = !!onReorder;
15787
+ const reorderFields = (fromName, toName, side) => {
15788
+ if (!onReorder || fromName === toName) return;
15789
+ const original = orderedColumns.map((c) => c.name);
15790
+ const names = [...original];
15791
+ const from = names.indexOf(fromName);
15792
+ if (from === -1 || !names.includes(toName)) return;
15793
+ names.splice(from, 1);
15794
+ const to = names.indexOf(toName);
15795
+ names.splice(side === "before" ? to : to + 1, 0, fromName);
15796
+ if (names.every((n, i) => n === original[i])) return;
15797
+ onReorder(names);
15798
+ };
15799
+ const findDropTarget = (x, y, dragged) => {
15800
+ const grid = gridRef.current;
15801
+ if (!grid) return null;
15802
+ const rtl = getComputedStyle(grid).direction === "rtl";
15803
+ let best = null;
15804
+ const nodes = Array.from(grid.querySelectorAll("[data-fdz-field]"));
15805
+ for (const node of nodes) {
15806
+ const name = node.getAttribute("data-fdz-field");
15807
+ if (!name) continue;
15808
+ const r = node.getBoundingClientRect();
15809
+ if (name === dragged) {
15810
+ if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return null;
15811
+ continue;
15812
+ }
15813
+ const dx = x < r.left ? r.left - x : x > r.right ? x - r.right : 0;
15814
+ const dy = y < r.top ? r.top - y : y > r.bottom ? y - r.bottom : 0;
15815
+ const dist = Math.hypot(dx, dy);
15816
+ if (!best || dist < best.dist) {
15817
+ const cx = r.left + r.width / 2;
15818
+ const before = rtl ? x >= cx : x < cx;
15819
+ best = { name, side: before ? "before" : "after", dist };
15820
+ }
15821
+ }
15822
+ return best ? { name: best.name, side: best.side } : null;
15823
+ };
15824
+ const startDrag = (e, colName) => {
15825
+ if (!onReorder || e.pointerType === "mouse" && e.button !== 0) return;
15826
+ const startX = e.clientX;
15827
+ const startY = e.clientY;
15828
+ let started = false;
15829
+ let current = null;
15830
+ const prevUserSelect = document.body.style.userSelect;
15831
+ const prevCursor = document.body.style.cursor;
15832
+ const onMove = (ev) => {
15833
+ if (!started) {
15834
+ if (Math.hypot(ev.clientX - startX, ev.clientY - startY) < 5) return;
15835
+ started = true;
15836
+ document.body.style.userSelect = "none";
15837
+ document.body.style.cursor = "grabbing";
15838
+ setDragName(colName);
15839
+ }
15840
+ const next = findDropTarget(ev.clientX, ev.clientY, colName);
15841
+ if ((next == null ? void 0 : next.name) !== (current == null ? void 0 : current.name) || (next == null ? void 0 : next.side) !== (current == null ? void 0 : current.side)) {
15842
+ current = next;
15843
+ setDrop(next);
15844
+ }
15845
+ };
15846
+ const finish = (commit) => {
15847
+ window.removeEventListener("pointermove", onMove);
15848
+ window.removeEventListener("pointerup", onUp);
15849
+ window.removeEventListener("pointercancel", onCancel);
15850
+ document.body.style.userSelect = prevUserSelect;
15851
+ document.body.style.cursor = prevCursor;
15852
+ if (started && commit && current) reorderFields(colName, current.name, current.side);
15853
+ setDragName(null);
15854
+ setDrop(null);
15855
+ };
15856
+ const onUp = () => finish(true);
15857
+ const onCancel = () => {
15858
+ if (started) console.warn('[StyledFormBlock] \u05D4\u05D2\u05E8\u05D9\u05E8\u05D4 \u05D1\u05D5\u05D8\u05DC\u05D4 \u05E2"\u05D9 \u05D4\u05D3\u05E4\u05D3\u05E4\u05DF/\u05E8\u05DB\u05D9\u05D1 \u05D0\u05D1 (pointercancel)');
15859
+ finish(false);
15860
+ };
15861
+ window.addEventListener("pointermove", onMove);
15862
+ window.addEventListener("pointerup", onUp);
15863
+ window.addEventListener("pointercancel", onCancel);
15864
+ };
15865
+ const startResize = (e, colName, startSpan) => {
15866
+ var _a, _b, _c, _d;
15867
+ if (!onFieldResize) return;
15868
+ const grid = gridRef.current;
15869
+ const item = e.currentTarget.closest("[data-fdz-field]");
15870
+ if (!grid || !item) return;
15871
+ e.preventDefault();
15872
+ e.stopPropagation();
15873
+ const box = item.querySelector("[data-fdz-box]");
15874
+ const colW = (grid.clientWidth - t.gap * 5) / 6;
15875
+ const rtl = grid.closest('[dir="rtl"]') !== null || getComputedStyle(grid).direction === "rtl";
15876
+ const state = {
15877
+ name: colName,
15878
+ startX: e.clientX,
15879
+ startY: e.clientY,
15880
+ startSpan,
15881
+ step: colW + t.gap,
15882
+ rtl,
15883
+ startHeight: box ? box.offsetHeight : 40,
15884
+ hadHeight: !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.height),
15885
+ span: startSpan,
15886
+ height: (_d = (_c = design == null ? void 0 : design.fields) == null ? void 0 : _c[colName]) == null ? void 0 : _d.height
15887
+ };
15888
+ resizeRef.current = state;
15889
+ setResizing({ name: colName, span: state.span, height: state.height });
15890
+ const onMove = (ev) => {
15891
+ const dxRaw = ev.clientX - state.startX;
15892
+ const dx = state.rtl ? -dxRaw : dxRaw;
15893
+ const span = Math.max(1, Math.min(6, Math.round(state.startSpan + dx / state.step)));
15894
+ const dy = ev.clientY - state.startY;
15895
+ const height = Math.abs(dy) < 8 && !state.hadHeight ? void 0 : Math.max(40, Math.round(state.startHeight + dy));
15896
+ if (span !== state.span || height !== state.height) {
15897
+ state.span = span;
15898
+ state.height = height;
15899
+ setResizing({ name: state.name, span, height });
15900
+ }
15901
+ };
15902
+ const onUp = () => {
15903
+ window.removeEventListener("pointermove", onMove);
15904
+ window.removeEventListener("pointerup", onUp);
15905
+ window.removeEventListener("pointercancel", onUp);
15906
+ resizeRef.current = null;
15907
+ onFieldResize(state.name, { span: state.span, height: state.height });
15908
+ setResizing(null);
15909
+ };
15910
+ window.addEventListener("pointermove", onMove);
15911
+ window.addEventListener("pointerup", onUp);
15912
+ window.addEventListener("pointercancel", onUp);
15913
+ };
15509
15914
  const handleSubmit = async (e) => {
15510
15915
  e.preventDefault();
15916
+ if (previewMode) return;
15511
15917
  if (!executeAction) {
15512
15918
  showError("\u05E8\u05DB\u05D9\u05D1 \u05D4\u05EA\u05E7\u05E9\u05D5\u05E8\u05EA \u05DC\u05D0 \u05D0\u05D5\u05EA\u05D7\u05DC", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05DE\u05E2\u05E8\u05DB\u05EA");
15513
15919
  return;
@@ -15516,8 +15922,12 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
15516
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");
15517
15923
  return;
15518
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
+ }
15519
15929
  const missingFields = formColumns.filter(
15520
- (col) => col.isRequired && (formData[col.name] === void 0 || formData[col.name] === null || formData[col.name] === "")
15930
+ (col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && (formData[col.name] === void 0 || formData[col.name] === null || formData[col.name] === "")
15521
15931
  );
15522
15932
  if (missingFields.length > 0) {
15523
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");
@@ -15525,108 +15935,318 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
15525
15935
  }
15526
15936
  setIsSubmitting(true);
15527
15937
  try {
15528
- const formattedPayload = {};
15938
+ const payload = {};
15529
15939
  formColumns.forEach((col) => {
15530
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
+ }
15531
15946
  let val = formData[col.name];
15532
15947
  if (val !== void 0 && val !== null) {
15533
- if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") {
15534
- val = val === "" ? 0 : Number(val);
15535
- }
15536
- formattedPayload[col.name] = val;
15537
- } else if (col.defaultValue !== void 0) {
15538
- formattedPayload[col.name] = col.defaultValue;
15948
+ if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
15949
+ payload[col.name] = val;
15950
+ } else if (submitMode !== "update") {
15951
+ const dv = parseColumnDefault(col);
15952
+ if (dv !== void 0) payload[col.name] = dv;
15539
15953
  }
15540
15954
  });
15541
- await executeAction("CREATE_RECORD", {
15542
- tableId: targetTableId,
15543
- tableMetaId: targetTableId,
15544
- records: [formattedPayload]
15545
- });
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
+ }
15546
15973
  addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
15547
- setFormData({});
15974
+ if (submitMode !== "update") setFormData(buildDefaultValues(columns));
15548
15975
  setIsSubmitted(true);
15549
15976
  if (onSuccess) onSuccess();
15550
15977
  } catch (err) {
15551
- console.error("[FormBlock] Submit error:", err);
15978
+ console.error("[StyledFormBlock] Submit error:", err);
15552
15979
  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");
15553
15980
  } finally {
15554
15981
  setIsSubmitting(false);
15555
15982
  }
15556
15983
  };
15984
+ const muted = t.invertText ? "rgba(255,255,255,0.85)" : "#64748b";
15985
+ const cardStyle = {
15986
+ background: d.background,
15987
+ color: d.text,
15988
+ borderRadius: t.radius,
15989
+ border: t.border,
15990
+ boxShadow: t.shadow,
15991
+ padding: t.headerBand ? 0 : t.padding,
15992
+ overflow: t.headerBand ? "hidden" : void 0
15993
+ };
15994
+ const inputBoxStyle = t.inputStyle === "underline" ? { borderBottom: "1px solid #cbd5e1", borderRadius: 0, background: "transparent", minHeight: 40, position: "relative" } : {
15995
+ border: "1px solid #e2e8f0",
15996
+ borderRadius: Math.min(t.radius, 10) || 6,
15997
+ background: "#ffffff",
15998
+ color: "#0f172a",
15999
+ minHeight: 40,
16000
+ position: "relative"
16001
+ };
16002
+ const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
16003
+ width: "fit-content",
16004
+ minWidth: 40,
16005
+ alignSelf: "flex-start",
16006
+ display: "flex",
16007
+ alignItems: "center",
16008
+ justifyContent: "center"
16009
+ });
16010
+ const css = `
16011
+ .${uid}{container-type:inline-size}
16012
+ .${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
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)}
16014
+ .${uid} .fdz-s1{--n:2}
16015
+ .${uid} .fdz-b{width:fit-content;max-width:140px;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
16016
+ @container (min-width:480px){
16017
+ .${uid} .fdz-f{--n:var(--span)}
16018
+ }
16019
+ `;
15557
16020
  if (isLoadingSchema) {
15558
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "p-8 flex items-center justify-center gap-2 text-slate-500", children: [
15559
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react18.Loader2, { className: "w-5 h-5 animate-spin text-brand" }),
15560
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-sm", children: "\u05D8\u05D5\u05E2\u05DF \u05E9\u05D3\u05D5\u05EA \u05D8\u05D5\u05E4\u05E1..." })
16021
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "p-8 flex items-center justify-center gap-2 text-slate-500", dir: "rtl", children: [
16022
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react19.Loader2, { className: "w-5 h-5 animate-spin", style: { color: d.primary } }),
16023
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-sm", children: "\u05D8\u05D5\u05E2\u05DF \u05E9\u05D3\u05D5\u05EA \u05D8\u05D5\u05E4\u05E1..." })
15561
16024
  ] });
15562
16025
  }
15563
16026
  if (!formColumns || formColumns.length === 0) {
15564
- return /* @__PURE__ */ (0, import_jsx_runtime29.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." });
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." });
15565
16028
  }
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)(
16031
+ "div",
16032
+ {
16033
+ style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
16034
+ children: [
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 }),
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 })
16038
+ ]
16039
+ }
16040
+ ) : null;
15566
16041
  if (isSubmitted) {
15567
16042
  const customMessage = (schema == null ? void 0 : schema.successMessage) || "\u05EA\u05D5\u05D3\u05D4 \u05E8\u05D1\u05D4! \u05D4\u05E4\u05E8\u05D8\u05D9\u05DD \u05D4\u05EA\u05E7\u05D1\u05DC\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4.";
15568
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { id: componentId, className: `bg-white p-8 rounded-xl shadow-xs border border-slate-200 text-center dir-rtl ${className}`, children: [
15569
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-16 h-16 bg-emerald-50 text-emerald-600 rounded-full flex items-center justify-center mx-auto mb-4 animate-in zoom-in duration-200", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react18.CheckCircle2, { className: "w-8 h-8" }) }),
15570
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-2xl font-bold text-slate-800 mb-2", children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
15571
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-slate-600 text-base max-w-md mx-auto whitespace-pre-wrap", children: customMessage }),
15572
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
16043
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { id: componentId, dir: "rtl", className, style: __spreadProps(__spreadValues({}, cardStyle), { padding: t.padding || 24, textAlign: "center" }), children: [
16044
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16045
+ "div",
16046
+ {
16047
+ style: {
16048
+ width: 64,
16049
+ height: 64,
16050
+ borderRadius: "50%",
16051
+ margin: "0 auto 16px",
16052
+ display: "flex",
16053
+ alignItems: "center",
16054
+ justifyContent: "center",
16055
+ background: t.invertText ? "rgba(255,255,255,0.2)" : "#ecfdf5",
16056
+ color: t.invertText ? "#ffffff" : "#059669"
16057
+ },
16058
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react19.CheckCircle2, { className: "w-8 h-8" })
16059
+ }
16060
+ ),
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" }),
16062
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { style: { fontSize: 16, color: muted, maxWidth: 420, margin: "0 auto", whiteSpace: "pre-wrap" }, children: customMessage }),
16063
+ submitMode !== "update" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
15573
16064
  "button",
15574
16065
  {
15575
16066
  type: "button",
15576
16067
  onClick: () => setIsSubmitted(false),
15577
- className: "mt-6 px-4 py-2 text-xs font-semibold text-brand hover:underline cursor-pointer",
16068
+ style: { marginTop: 24, fontSize: 12, fontWeight: 600, color: t.invertText ? "#ffffff" : d.primary, background: "none", border: "none", cursor: "pointer", textDecoration: "underline" },
15578
16069
  children: "\u05E9\u05DC\u05D9\u05D7\u05EA \u05DE\u05E2\u05E0\u05D4 \u05E0\u05D5\u05E1\u05E3"
15579
16070
  }
15580
16071
  )
15581
16072
  ] });
15582
16073
  }
15583
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { id: componentId, className: `bg-white p-6 rounded-xl shadow-xs border border-slate-200 dir-rtl ${className}`, children: [
15584
- (schema == null ? void 0 : schema.title) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h2", { className: "text-xl font-bold text-slate-800 mb-6", children: schema.title }),
15585
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
15586
- formColumns.map((col) => {
15587
- var _a, _b;
15588
- const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
15589
- const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
15590
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
15591
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "text-sm font-semibold text-slate-700", children: [
15592
- col.name,
15593
- " ",
15594
- col.isRequired && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-rose-500", children: "*" })
15595
- ] }),
15596
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "border border-slate-200 rounded-lg min-h-[40px] relative", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
15597
- InputComponent,
16074
+ const justify = d.buttonAlign === "center" ? "center" : d.buttonAlign === "end" ? "flex-end" : d.buttonAlign === "full" ? "stretch" : "flex-start";
16075
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { id: componentId, dir: "rtl", className: `${uid} ${className}`, style: cardStyle, children: [
16076
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("style", { children: css }),
16077
+ headerBlock,
16078
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: t.headerBand ? { padding: t.padding } : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("form", { onSubmit: handleSubmit, children: [
16079
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "fdz-grid", ref: gridRef, children: (() => {
16080
+ const spanOf = (col) => {
16081
+ var _a;
16082
+ if (resizing && resizing.name === col.name) return resizing.span;
16083
+ const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
16084
+ return resolveFieldSpan(col.name, colType, design, d.columns);
16085
+ };
16086
+ const renderField = (col) => {
16087
+ var _a, _b, _c, _d, _e;
16088
+ const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
16089
+ const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
16090
+ const span = spanOf(col);
16091
+ const isBoolean = colType === "BOOLEAN";
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;
16095
+ const useTextarea = !!fieldHeight && fieldHeight > 56 && InputComponent === FORM_INPUTS.DEFAULT;
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" } : {});
16097
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
16098
+ "div",
15598
16099
  {
15599
- column: col,
15600
- rowId: "new_form_record",
15601
- value: (_b = formData[col.name]) != null ? _b : "",
15602
- onChange: (val) => handleFieldChange(col.name, val),
15603
- context: {
15604
- executeAction,
15605
- tableId: targetTableId
15606
- }
15607
- }
15608
- ) })
15609
- ] }, col.name);
15610
- }),
15611
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "pt-4 border-t border-slate-100 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
15612
- "button",
16100
+ "data-fdz-field": col.name,
16101
+ className: `fdz-f fdz-s${span}${isBoolean ? " fdz-b" : ""}`,
16102
+ draggable: false,
16103
+ onDragStart: canReorder ? (e) => e.preventDefault() : void 0,
16104
+ onMouseDown: canReorder ? (e) => e.stopPropagation() : void 0,
16105
+ onTouchStart: canReorder ? (e) => e.stopPropagation() : void 0,
16106
+ onPointerDown: canReorder ? (e) => {
16107
+ e.stopPropagation();
16108
+ startDrag(e, col.name);
16109
+ } : void 0,
16110
+ style: __spreadValues({ "--span": span }, canReorder ? {
16111
+ position: "relative",
16112
+ cursor: "grab",
16113
+ touchAction: "none",
16114
+ userSelect: "none",
16115
+ opacity: dragName === col.name ? 0.4 : 1,
16116
+ outline: resizing && resizing.name === col.name ? `2px solid ${t.invertText ? "#ffffff" : d.primary}` : void 0,
16117
+ outlineOffset: 4,
16118
+ borderRadius: 6
16119
+ } : {}),
16120
+ children: [
16121
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
16122
+ col.name,
16123
+ " ",
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)" })
16126
+ ] }),
16127
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16128
+ "textarea",
16129
+ {
16130
+ value: shownValue,
16131
+ onChange: (e) => handleFieldChange(col.name, e.target.value),
16132
+ readOnly: previewMode || locked,
16133
+ style: {
16134
+ width: "100%",
16135
+ height: "100%",
16136
+ minHeight: fieldHeight - 2,
16137
+ padding: "8px 12px",
16138
+ border: "none",
16139
+ outline: "none",
16140
+ background: "transparent",
16141
+ resize: "none",
16142
+ font: "inherit",
16143
+ color: "inherit",
16144
+ boxSizing: "border-box"
16145
+ }
16146
+ }
16147
+ ) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16148
+ InputComponent,
16149
+ {
16150
+ column: col,
16151
+ rowId: "new_form_record",
16152
+ value: shownValue,
16153
+ onChange: (val) => handleFieldChange(col.name, val),
16154
+ readOnly: previewMode || locked,
16155
+ context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
16156
+ }
16157
+ ) }),
16158
+ canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16159
+ "div",
16160
+ {
16161
+ style: __spreadValues({
16162
+ position: "absolute",
16163
+ top: 0,
16164
+ bottom: 0,
16165
+ width: 4,
16166
+ borderRadius: 2,
16167
+ background: t.invertText ? "#ffffff" : d.primary,
16168
+ pointerEvents: "none",
16169
+ zIndex: 3
16170
+ }, drop.side === "before" ? { insetInlineStart: -(t.gap / 2) - 2 } : { insetInlineEnd: -(t.gap / 2) - 2 })
16171
+ }
16172
+ ),
16173
+ onFieldResize && !isBoolean && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16174
+ "div",
16175
+ {
16176
+ onMouseDown: (e) => e.stopPropagation(),
16177
+ onTouchStart: (e) => e.stopPropagation(),
16178
+ onPointerDown: (e) => startResize(e, col.name, span),
16179
+ onDoubleClick: () => onFieldResize(col.name, { reset: true }),
16180
+ title: "\u05D2\u05E8\u05D5\u05E8 \u05DC\u05E9\u05D9\u05E0\u05D5\u05D9 \u05D2\u05D5\u05D3\u05DC (\u05DC\u05D7\u05D9\u05E6\u05D4 \u05DB\u05E4\u05D5\u05DC\u05D4 \u05DC\u05D0\u05D9\u05E4\u05D5\u05E1)",
16181
+ style: {
16182
+ position: "absolute",
16183
+ left: -6,
16184
+ bottom: -6,
16185
+ width: 14,
16186
+ height: 14,
16187
+ borderRadius: 4,
16188
+ background: "#ffffff",
16189
+ border: `2px solid ${d.primary}`,
16190
+ cursor: "nesw-resize",
16191
+ touchAction: "none",
16192
+ zIndex: 2
16193
+ }
16194
+ }
16195
+ )
16196
+ ]
16197
+ },
16198
+ col.name
16199
+ );
16200
+ };
16201
+ return formColumns.map((col) => renderField(col));
16202
+ })() }),
16203
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
16204
+ "div",
15613
16205
  {
15614
- type: "submit",
15615
- disabled: isSubmitting,
15616
- className: "flex items-center gap-2 px-6 py.2.5 bg-brand hover:bg-brand-hover text-white font-bold rounded-lg shadow-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
15617
- children: [
15618
- isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react18.Loader2, { className: "w-4 h-4 animate-spin" }),
15619
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: isSubmitting ? "\u05E9\u05D5\u05DE\u05E8..." : "\u05E9\u05DC\u05D9\u05D7\u05D4" })
15620
- ]
16206
+ style: {
16207
+ marginTop: t.gap + 8,
16208
+ paddingTop: t.inputStyle === "underline" || t.invertText ? 0 : t.gap,
16209
+ borderTop: t.inputStyle === "underline" || t.invertText ? "none" : "1px solid rgba(148,163,184,0.25)",
16210
+ display: "flex",
16211
+ justifyContent: justify
16212
+ },
16213
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
16214
+ "button",
16215
+ {
16216
+ type: "submit",
16217
+ disabled: isSubmitting || previewMode,
16218
+ style: {
16219
+ display: "flex",
16220
+ alignItems: "center",
16221
+ justifyContent: "center",
16222
+ gap: 8,
16223
+ padding: "10px 28px",
16224
+ width: d.buttonAlign === "full" ? "100%" : void 0,
16225
+ background: t.invertText ? "#ffffff" : d.primary,
16226
+ color: t.invertText ? d.primary : "#ffffff",
16227
+ fontWeight: 700,
16228
+ fontSize: 15,
16229
+ border: "none",
16230
+ borderRadius: Math.min(t.radius, 10) || 6,
16231
+ boxShadow: "0 1px 2px rgba(0,0,0,0.1)",
16232
+ cursor: isSubmitting || previewMode ? "default" : "pointer",
16233
+ opacity: isSubmitting ? 0.5 : 1
16234
+ },
16235
+ children: [
16236
+ isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react19.Loader2, { className: "w-4 h-4 animate-spin" }),
16237
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: isSubmitting ? "\u05E9\u05D5\u05DE\u05E8..." : d.buttonText })
16238
+ ]
16239
+ }
16240
+ )
15621
16241
  }
15622
- ) })
15623
- ] })
16242
+ )
16243
+ ] }) })
15624
16244
  ] });
15625
16245
  }
15626
16246
 
15627
16247
  // src/themes/ThemeScope.tsx
15628
- var React22 = __toESM(require("react"));
15629
- var import_jsx_runtime30 = require("react/jsx-runtime");
16248
+ var React23 = __toESM(require("react"));
16249
+ var import_jsx_runtime31 = require("react/jsx-runtime");
15630
16250
  var UNIVERSE_THEME_IDS = ["classic", "clean", "ocean", "warm"];
15631
16251
  function resolveUniverseTheme(value) {
15632
16252
  return typeof value === "string" && UNIVERSE_THEME_IDS.includes(value) ? value : "classic";
@@ -15636,7 +16256,7 @@ function withThemeScope(Component) {
15636
16256
  var _a, _b, _c;
15637
16257
  const p = props;
15638
16258
  const theme = resolveUniverseTheme((_c = (_a = p.settings) == null ? void 0 : _a.theme) != null ? _c : (_b = p.config) == null ? void 0 : _b.theme);
15639
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "data-theme": theme, style: { display: "contents" }, children: React22.createElement(Component, props) });
16259
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "data-theme": theme, style: { display: "contents" }, children: React23.createElement(Component, props) });
15640
16260
  }
15641
16261
  ThemeScoped.displayName = `ThemeScoped(${Component.displayName || Component.name || "Component"})`;
15642
16262
  return ThemeScoped;
@@ -15646,7 +16266,7 @@ function withThemeScope(Component) {
15646
16266
  var UNIVERSE_COMPONENTS = {
15647
16267
  TABLE: withThemeScope(TableBlock),
15648
16268
  WHATSAPP: withThemeScope(WhatsAppComponent),
15649
- FORM: withThemeScope(FormBlock),
16269
+ FORM: withThemeScope(StyledFormBlock),
15650
16270
  PLACEMENT: withThemeScope(PlacementBlock)
15651
16271
  };
15652
16272
  // Annotate the CommonJS export names for ESM import in node: