@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/globals.css +13 -0
- package/dist/index.d.mts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +705 -85
- package/dist/index.mjs +705 -85
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15370,28 +15370,268 @@ function WhatsAppComponent(props) {
|
|
|
15370
15370
|
import { useState as useState21, useEffect as useEffect19 } from "react";
|
|
15371
15371
|
import { Loader2 as Loader29, CheckCircle2 as CheckCircle25 } from "lucide-react";
|
|
15372
15372
|
import { jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
15373
|
-
|
|
15373
|
+
|
|
15374
|
+
// src/components/FormBlock/StyledFormBlock.tsx
|
|
15375
|
+
import { useState as useState22, useEffect as useEffect20, useId, useRef as useRef20 } from "react";
|
|
15376
|
+
import { Loader2 as Loader210, CheckCircle2 as CheckCircle26 } from "lucide-react";
|
|
15377
|
+
|
|
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
|
+
}
|
|
15392
|
+
var FORM_PRESETS = {
|
|
15393
|
+
classic: {
|
|
15394
|
+
label: "\u05E7\u05DC\u05D0\u05E1\u05D9",
|
|
15395
|
+
description: "\u05DB\u05E8\u05D8\u05D9\u05E1 \u05DC\u05D1\u05DF, \u05E9\u05D3\u05D4 \u05D1\u05DB\u05DC \u05E9\u05D5\u05E8\u05D4",
|
|
15396
|
+
radius: 12,
|
|
15397
|
+
padding: 24,
|
|
15398
|
+
gap: 16,
|
|
15399
|
+
labelSize: 14,
|
|
15400
|
+
titleSize: 20,
|
|
15401
|
+
border: "1px solid #e2e8f0",
|
|
15402
|
+
shadow: "0 1px 2px rgba(0,0,0,0.05)",
|
|
15403
|
+
headerBand: false,
|
|
15404
|
+
inputStyle: "box",
|
|
15405
|
+
defaultColumns: 1,
|
|
15406
|
+
defaultBackground: "#ffffff",
|
|
15407
|
+
defaultText: "#1e293b",
|
|
15408
|
+
invertText: false
|
|
15409
|
+
},
|
|
15410
|
+
compact: {
|
|
15411
|
+
label: "\u05E7\u05D5\u05DE\u05E4\u05E7\u05D8\u05D9",
|
|
15412
|
+
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",
|
|
15413
|
+
radius: 10,
|
|
15414
|
+
padding: 16,
|
|
15415
|
+
gap: 10,
|
|
15416
|
+
labelSize: 12,
|
|
15417
|
+
titleSize: 18,
|
|
15418
|
+
border: "1px solid #e2e8f0",
|
|
15419
|
+
shadow: "0 1px 2px rgba(0,0,0,0.05)",
|
|
15420
|
+
headerBand: false,
|
|
15421
|
+
inputStyle: "box",
|
|
15422
|
+
defaultColumns: 2,
|
|
15423
|
+
defaultBackground: "#ffffff",
|
|
15424
|
+
defaultText: "#1e293b",
|
|
15425
|
+
invertText: false
|
|
15426
|
+
},
|
|
15427
|
+
card: {
|
|
15428
|
+
label: "\u05DB\u05E8\u05D8\u05D9\u05E1",
|
|
15429
|
+
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",
|
|
15430
|
+
radius: 20,
|
|
15431
|
+
padding: 28,
|
|
15432
|
+
gap: 18,
|
|
15433
|
+
labelSize: 14,
|
|
15434
|
+
titleSize: 22,
|
|
15435
|
+
border: "none",
|
|
15436
|
+
shadow: "0 20px 40px -12px rgba(15,23,42,0.18)",
|
|
15437
|
+
headerBand: true,
|
|
15438
|
+
inputStyle: "box",
|
|
15439
|
+
defaultColumns: 2,
|
|
15440
|
+
defaultBackground: "#ffffff",
|
|
15441
|
+
defaultText: "#1e293b",
|
|
15442
|
+
invertText: false
|
|
15443
|
+
},
|
|
15444
|
+
minimal: {
|
|
15445
|
+
label: "\u05DE\u05D9\u05E0\u05D9\u05DE\u05DC\u05D9\u05E1\u05D8\u05D9",
|
|
15446
|
+
description: "\u05D1\u05DC\u05D9 \u05DE\u05E1\u05D2\u05E8\u05EA, \u05E7\u05D5 \u05EA\u05D7\u05EA\u05D5\u05DF \u05DC\u05E9\u05D3\u05D5\u05EA",
|
|
15447
|
+
radius: 0,
|
|
15448
|
+
padding: 0,
|
|
15449
|
+
gap: 20,
|
|
15450
|
+
labelSize: 13,
|
|
15451
|
+
titleSize: 22,
|
|
15452
|
+
border: "none",
|
|
15453
|
+
shadow: "none",
|
|
15454
|
+
headerBand: false,
|
|
15455
|
+
inputStyle: "underline",
|
|
15456
|
+
defaultColumns: 1,
|
|
15457
|
+
defaultBackground: "transparent",
|
|
15458
|
+
defaultText: "#1e293b",
|
|
15459
|
+
invertText: false
|
|
15460
|
+
},
|
|
15461
|
+
bold: {
|
|
15462
|
+
label: "\u05D1\u05D5\u05DC\u05D8",
|
|
15463
|
+
description: "\u05E8\u05E7\u05E2 \u05D1\u05E6\u05D1\u05E2 \u05D4\u05DE\u05D5\u05EA\u05D2 \u05D5\u05D8\u05E7\u05E1\u05D8 \u05DC\u05D1\u05DF",
|
|
15464
|
+
radius: 16,
|
|
15465
|
+
padding: 28,
|
|
15466
|
+
gap: 16,
|
|
15467
|
+
labelSize: 14,
|
|
15468
|
+
titleSize: 22,
|
|
15469
|
+
border: "none",
|
|
15470
|
+
shadow: "0 10px 30px -10px rgba(0,0,0,0.3)",
|
|
15471
|
+
headerBand: false,
|
|
15472
|
+
inputStyle: "box",
|
|
15473
|
+
defaultColumns: 1,
|
|
15474
|
+
defaultBackground: "",
|
|
15475
|
+
defaultText: "#ffffff",
|
|
15476
|
+
invertText: true
|
|
15477
|
+
}
|
|
15478
|
+
};
|
|
15479
|
+
var DEFAULT_PRIMARY = "#00b7a2";
|
|
15480
|
+
var ALWAYS_FULL_TYPES = /* @__PURE__ */ new Set(["GOOGLE_DRIVE_FILE", "SUB_TABLE", "SUBTABLE", "LINK"]);
|
|
15481
|
+
function isFormPresetId(v) {
|
|
15482
|
+
return typeof v === "string" && v in FORM_PRESETS;
|
|
15483
|
+
}
|
|
15484
|
+
function safeLogoUrl(url) {
|
|
15485
|
+
const u = (url || "").trim();
|
|
15486
|
+
if (!u) return void 0;
|
|
15487
|
+
if (/^https?:\/\//i.test(u)) return u;
|
|
15488
|
+
if (/^data:image\/(png|jpe?g|webp|gif);base64,[a-z0-9+/=]+$/i.test(u)) return u;
|
|
15489
|
+
return void 0;
|
|
15490
|
+
}
|
|
15491
|
+
function resolveFormDesign(design) {
|
|
15492
|
+
var _a, _b;
|
|
15493
|
+
const presetId = isFormPresetId(design == null ? void 0 : design.preset) ? design.preset : "classic";
|
|
15494
|
+
const tokens = FORM_PRESETS[presetId];
|
|
15495
|
+
const primary = (design == null ? void 0 : design.primaryColor) || DEFAULT_PRIMARY;
|
|
15496
|
+
const background = (design == null ? void 0 : design.backgroundColor) || (tokens.invertText ? primary : tokens.defaultBackground);
|
|
15497
|
+
const text2 = (design == null ? void 0 : design.textColor) || tokens.defaultText;
|
|
15498
|
+
return {
|
|
15499
|
+
tokens,
|
|
15500
|
+
presetId,
|
|
15501
|
+
primary,
|
|
15502
|
+
background,
|
|
15503
|
+
text: text2,
|
|
15504
|
+
buttonText: ((_a = design == null ? void 0 : design.buttonText) == null ? void 0 : _a.trim()) || "\u05E9\u05DC\u05D9\u05D7\u05D4",
|
|
15505
|
+
buttonAlign: (design == null ? void 0 : design.buttonAlign) || (presetId === "compact" ? "full" : "end"),
|
|
15506
|
+
subtitle: ((_b = design == null ? void 0 : design.subtitle) == null ? void 0 : _b.trim()) || "",
|
|
15507
|
+
columns: (design == null ? void 0 : design.columns) || tokens.defaultColumns,
|
|
15508
|
+
titleColor: (design == null ? void 0 : design.titleColor) || void 0,
|
|
15509
|
+
logoUrl: safeLogoUrl(design == null ? void 0 : design.logoUrl),
|
|
15510
|
+
logoHeight: Math.min(200, Math.max(24, Number(design == null ? void 0 : design.logoHeight) || 56)),
|
|
15511
|
+
logoAlign: (design == null ? void 0 : design.logoAlign) || "start"
|
|
15512
|
+
};
|
|
15513
|
+
}
|
|
15514
|
+
var TODAY_DEFAULT_TOKEN = "@today";
|
|
15515
|
+
function todayIsoDate() {
|
|
15516
|
+
try {
|
|
15517
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
15518
|
+
timeZone: "Asia/Jerusalem",
|
|
15519
|
+
year: "numeric",
|
|
15520
|
+
month: "2-digit",
|
|
15521
|
+
day: "2-digit"
|
|
15522
|
+
}).format(/* @__PURE__ */ new Date());
|
|
15523
|
+
} catch (e) {
|
|
15524
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
15525
|
+
}
|
|
15526
|
+
}
|
|
15527
|
+
function parseColumnDefault(col) {
|
|
15528
|
+
const raw = col.defaultValue;
|
|
15529
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
15530
|
+
const type = (col.type || "").toUpperCase();
|
|
15531
|
+
const first = Array.isArray(raw) ? raw[0] : raw;
|
|
15532
|
+
if (first === void 0 || first === null || first === "") return void 0;
|
|
15533
|
+
switch (type) {
|
|
15534
|
+
case "NUMBER":
|
|
15535
|
+
case "CURRENCY": {
|
|
15536
|
+
const n = Number(first);
|
|
15537
|
+
return isNaN(n) ? void 0 : n;
|
|
15538
|
+
}
|
|
15539
|
+
case "BOOLEAN":
|
|
15540
|
+
return first === true || first === "true";
|
|
15541
|
+
case "DATE":
|
|
15542
|
+
return first === TODAY_DEFAULT_TOKEN ? todayIsoDate() : String(first);
|
|
15543
|
+
case "RELATION":
|
|
15544
|
+
return Array.isArray(raw) ? raw.map(String) : [String(first)];
|
|
15545
|
+
case "SUB_TABLE":
|
|
15546
|
+
case "SUBTABLE":
|
|
15547
|
+
case "LINK":
|
|
15548
|
+
case "GOOGLE_DRIVE_FILE":
|
|
15549
|
+
case "GOOGLE_CONTACT":
|
|
15550
|
+
case "FORMULA":
|
|
15551
|
+
case "SEQUENCE":
|
|
15552
|
+
return void 0;
|
|
15553
|
+
default:
|
|
15554
|
+
return String(first);
|
|
15555
|
+
}
|
|
15556
|
+
}
|
|
15557
|
+
function buildDefaultValues(cols) {
|
|
15558
|
+
const out = {};
|
|
15559
|
+
for (const c of cols || []) {
|
|
15560
|
+
const v = parseColumnDefault(c);
|
|
15561
|
+
if (v !== void 0) out[c.name] = v;
|
|
15562
|
+
}
|
|
15563
|
+
return out;
|
|
15564
|
+
}
|
|
15565
|
+
function resolveFieldWidth(colName, colType, design, columnsDefault) {
|
|
15566
|
+
var _a, _b;
|
|
15567
|
+
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.width;
|
|
15568
|
+
if (manual) return manual;
|
|
15569
|
+
if ((colType || "").toUpperCase() === "BOOLEAN") return "third";
|
|
15570
|
+
if (ALWAYS_FULL_TYPES.has((colType || "").toUpperCase())) return "full";
|
|
15571
|
+
return columnsDefault === 3 ? "third" : columnsDefault === 2 ? "half" : "full";
|
|
15572
|
+
}
|
|
15573
|
+
var WIDTH_TO_SPAN = { full: 6, half: 3, third: 2, sixth: 1 };
|
|
15574
|
+
function resolveFieldSpan(colName, colType, design, columnsDefault) {
|
|
15575
|
+
var _a, _b;
|
|
15576
|
+
const manual = (_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.span;
|
|
15577
|
+
if (manual && manual >= 1 && manual <= 6) return manual;
|
|
15578
|
+
return WIDTH_TO_SPAN[resolveFieldWidth(colName, colType, design, columnsDefault)];
|
|
15579
|
+
}
|
|
15580
|
+
function applyFieldOrder(cols, design) {
|
|
15581
|
+
const order = design == null ? void 0 : design.fieldOrder;
|
|
15582
|
+
if (!order || order.length === 0) return cols;
|
|
15583
|
+
const idx = (n) => {
|
|
15584
|
+
const i = order.indexOf(n);
|
|
15585
|
+
return i === -1 ? Number.MAX_SAFE_INTEGER : i;
|
|
15586
|
+
};
|
|
15587
|
+
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);
|
|
15588
|
+
}
|
|
15589
|
+
|
|
15590
|
+
// src/components/FormBlock/StyledFormBlock.tsx
|
|
15591
|
+
import { jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
15592
|
+
var SYSTEM_FIELDS = ["_id", "id", "createdAt", "updatedAt", "orgId", "tableId"];
|
|
15593
|
+
function StyledFormBlock({
|
|
15594
|
+
settings: schema,
|
|
15595
|
+
executeAction,
|
|
15596
|
+
componentId,
|
|
15597
|
+
className = "",
|
|
15598
|
+
onSuccess,
|
|
15599
|
+
previewMode = false,
|
|
15600
|
+
onReorder,
|
|
15601
|
+
onFieldResize,
|
|
15602
|
+
initialValues,
|
|
15603
|
+
submitMode = "create",
|
|
15604
|
+
recordId
|
|
15605
|
+
}) {
|
|
15374
15606
|
const { showError, addToast } = useToast();
|
|
15375
|
-
const
|
|
15376
|
-
const
|
|
15377
|
-
const
|
|
15378
|
-
const
|
|
15379
|
-
const [
|
|
15607
|
+
const uid = "fdz" + useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
15608
|
+
const design = schema == null ? void 0 : schema.design;
|
|
15609
|
+
const d = resolveFormDesign(design);
|
|
15610
|
+
const t = d.tokens;
|
|
15611
|
+
const [formData, setFormData] = useState22(initialValues || {});
|
|
15612
|
+
const [isSubmitting, setIsSubmitting] = useState22(false);
|
|
15613
|
+
const [isSubmitted, setIsSubmitted] = useState22(false);
|
|
15614
|
+
const [columns, setColumns] = useState22((schema == null ? void 0 : schema.columns) || []);
|
|
15615
|
+
const [isLoadingSchema, setIsLoadingSchema] = useState22(false);
|
|
15616
|
+
const [dragName, setDragName] = useState22(null);
|
|
15617
|
+
const [drop, setDrop] = useState22(null);
|
|
15618
|
+
const [resizing, setResizing] = useState22(null);
|
|
15619
|
+
const resizeRef = useRef20(null);
|
|
15620
|
+
const gridRef = useRef20(null);
|
|
15621
|
+
const relationDictRef = useRef20({});
|
|
15622
|
+
const relationRequestedRef = useRef20(/* @__PURE__ */ new Set());
|
|
15623
|
+
const [, bumpRelationLabels] = useState22(0);
|
|
15380
15624
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
15381
|
-
|
|
15625
|
+
useEffect20(() => {
|
|
15382
15626
|
let isMounted = true;
|
|
15383
|
-
if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction) {
|
|
15627
|
+
if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction && !previewMode) {
|
|
15384
15628
|
setIsLoadingSchema(true);
|
|
15385
15629
|
executeAction("FETCH_TABLE_DATA", { tableId: targetTableId, limit: 1 }).then((res) => {
|
|
15386
15630
|
var _a;
|
|
15387
15631
|
if (!isMounted) return;
|
|
15388
15632
|
const fetchedCols = ((_a = res == null ? void 0 : res.schema) == null ? void 0 : _a.columns) || (res == null ? void 0 : res.columns);
|
|
15389
|
-
if (fetchedCols && Array.isArray(fetchedCols))
|
|
15390
|
-
|
|
15391
|
-
}
|
|
15392
|
-
}).catch((err) => {
|
|
15393
|
-
console.error("[FormBlock] Failed to fetch table schema:", err);
|
|
15394
|
-
}).finally(() => {
|
|
15633
|
+
if (fetchedCols && Array.isArray(fetchedCols)) setColumns(fetchedCols);
|
|
15634
|
+
}).catch((err) => console.error("[StyledFormBlock] Failed to fetch table schema:", err)).finally(() => {
|
|
15395
15635
|
if (isMounted) setIsLoadingSchema(false);
|
|
15396
15636
|
});
|
|
15397
15637
|
} else if (schema == null ? void 0 : schema.columns) {
|
|
@@ -15401,18 +15641,184 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
|
|
|
15401
15641
|
isMounted = false;
|
|
15402
15642
|
};
|
|
15403
15643
|
}, [schema == null ? void 0 : schema.columns, targetTableId]);
|
|
15404
|
-
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15644
|
+
useEffect20(() => {
|
|
15645
|
+
if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
|
|
15646
|
+
const defaults = buildDefaultValues(columns);
|
|
15647
|
+
if (Object.keys(defaults).length === 0) return;
|
|
15648
|
+
setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
|
|
15649
|
+
}, [columns, submitMode, previewMode]);
|
|
15650
|
+
useEffect20(() => {
|
|
15651
|
+
if (previewMode || !executeAction || !columns) return;
|
|
15652
|
+
for (const col of columns) {
|
|
15653
|
+
if ((col.type || "").toUpperCase() !== "RELATION") continue;
|
|
15654
|
+
const cfg = col.config || {};
|
|
15655
|
+
if (!cfg.referencedTableId) continue;
|
|
15656
|
+
const need = normalizeRelationValue(formData[col.name]).filter(
|
|
15657
|
+
(id) => {
|
|
15658
|
+
var _a;
|
|
15659
|
+
return !((_a = relationDictRef.current[col.name]) == null ? void 0 : _a.has(id)) && !relationRequestedRef.current.has(`${col.name}:${id}`);
|
|
15660
|
+
}
|
|
15661
|
+
);
|
|
15662
|
+
if (need.length === 0) continue;
|
|
15663
|
+
need.forEach((id) => relationRequestedRef.current.add(`${col.name}:${id}`));
|
|
15664
|
+
executeAction("FETCH_RELATION", {
|
|
15665
|
+
referencedTableId: cfg.referencedTableId,
|
|
15666
|
+
displayField: cfg.displayField,
|
|
15667
|
+
recordIds: need,
|
|
15668
|
+
take: need.length,
|
|
15669
|
+
limit: need.length
|
|
15670
|
+
}).then((res) => {
|
|
15671
|
+
const rows = Array.isArray(res) ? res : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
|
|
15672
|
+
if (rows.length === 0) return;
|
|
15673
|
+
const map = relationDictRef.current[col.name] || /* @__PURE__ */ new Map();
|
|
15674
|
+
rows.forEach((r) => map.set(String(r.id), r));
|
|
15675
|
+
relationDictRef.current[col.name] = map;
|
|
15676
|
+
bumpRelationLabels((n) => n + 1);
|
|
15677
|
+
}).catch((err) => console.warn("[StyledFormBlock] relation label fetch failed:", err));
|
|
15678
|
+
}
|
|
15679
|
+
}, [columns, formData, previewMode, executeAction]);
|
|
15680
|
+
const baseColumns = (columns || []).filter((col) => !SYSTEM_FIELDS.includes(col.name) && !col.isHidden).sort((a, b) => {
|
|
15408
15681
|
var _a, _b;
|
|
15409
15682
|
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
15410
15683
|
});
|
|
15684
|
+
const isDesignHidden = (col) => isFieldHidden(col, design);
|
|
15685
|
+
const orderedColumns = applyFieldOrder(baseColumns, design);
|
|
15686
|
+
const formColumns = orderedColumns.filter((c) => !isDesignHidden(c));
|
|
15687
|
+
const hiddenColumns = orderedColumns.filter((c) => isDesignHidden(c));
|
|
15411
15688
|
const handleFieldChange = (colName, value) => {
|
|
15412
15689
|
setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: value }));
|
|
15413
15690
|
};
|
|
15691
|
+
const canReorder = !!onReorder;
|
|
15692
|
+
const reorderFields = (fromName, toName, side) => {
|
|
15693
|
+
if (!onReorder || fromName === toName) return;
|
|
15694
|
+
const original = orderedColumns.map((c) => c.name);
|
|
15695
|
+
const names = [...original];
|
|
15696
|
+
const from = names.indexOf(fromName);
|
|
15697
|
+
if (from === -1 || !names.includes(toName)) return;
|
|
15698
|
+
names.splice(from, 1);
|
|
15699
|
+
const to = names.indexOf(toName);
|
|
15700
|
+
names.splice(side === "before" ? to : to + 1, 0, fromName);
|
|
15701
|
+
if (names.every((n, i) => n === original[i])) return;
|
|
15702
|
+
onReorder(names);
|
|
15703
|
+
};
|
|
15704
|
+
const findDropTarget = (x, y, dragged) => {
|
|
15705
|
+
const grid = gridRef.current;
|
|
15706
|
+
if (!grid) return null;
|
|
15707
|
+
const rtl = getComputedStyle(grid).direction === "rtl";
|
|
15708
|
+
let best = null;
|
|
15709
|
+
const nodes = Array.from(grid.querySelectorAll("[data-fdz-field]"));
|
|
15710
|
+
for (const node of nodes) {
|
|
15711
|
+
const name = node.getAttribute("data-fdz-field");
|
|
15712
|
+
if (!name) continue;
|
|
15713
|
+
const r = node.getBoundingClientRect();
|
|
15714
|
+
if (name === dragged) {
|
|
15715
|
+
if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return null;
|
|
15716
|
+
continue;
|
|
15717
|
+
}
|
|
15718
|
+
const dx = x < r.left ? r.left - x : x > r.right ? x - r.right : 0;
|
|
15719
|
+
const dy = y < r.top ? r.top - y : y > r.bottom ? y - r.bottom : 0;
|
|
15720
|
+
const dist = Math.hypot(dx, dy);
|
|
15721
|
+
if (!best || dist < best.dist) {
|
|
15722
|
+
const cx = r.left + r.width / 2;
|
|
15723
|
+
const before = rtl ? x >= cx : x < cx;
|
|
15724
|
+
best = { name, side: before ? "before" : "after", dist };
|
|
15725
|
+
}
|
|
15726
|
+
}
|
|
15727
|
+
return best ? { name: best.name, side: best.side } : null;
|
|
15728
|
+
};
|
|
15729
|
+
const startDrag = (e, colName) => {
|
|
15730
|
+
if (!onReorder || e.pointerType === "mouse" && e.button !== 0) return;
|
|
15731
|
+
const startX = e.clientX;
|
|
15732
|
+
const startY = e.clientY;
|
|
15733
|
+
let started = false;
|
|
15734
|
+
let current = null;
|
|
15735
|
+
const prevUserSelect = document.body.style.userSelect;
|
|
15736
|
+
const prevCursor = document.body.style.cursor;
|
|
15737
|
+
const onMove = (ev) => {
|
|
15738
|
+
if (!started) {
|
|
15739
|
+
if (Math.hypot(ev.clientX - startX, ev.clientY - startY) < 5) return;
|
|
15740
|
+
started = true;
|
|
15741
|
+
document.body.style.userSelect = "none";
|
|
15742
|
+
document.body.style.cursor = "grabbing";
|
|
15743
|
+
setDragName(colName);
|
|
15744
|
+
}
|
|
15745
|
+
const next = findDropTarget(ev.clientX, ev.clientY, colName);
|
|
15746
|
+
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)) {
|
|
15747
|
+
current = next;
|
|
15748
|
+
setDrop(next);
|
|
15749
|
+
}
|
|
15750
|
+
};
|
|
15751
|
+
const finish = (commit) => {
|
|
15752
|
+
window.removeEventListener("pointermove", onMove);
|
|
15753
|
+
window.removeEventListener("pointerup", onUp);
|
|
15754
|
+
window.removeEventListener("pointercancel", onCancel);
|
|
15755
|
+
document.body.style.userSelect = prevUserSelect;
|
|
15756
|
+
document.body.style.cursor = prevCursor;
|
|
15757
|
+
if (started && commit && current) reorderFields(colName, current.name, current.side);
|
|
15758
|
+
setDragName(null);
|
|
15759
|
+
setDrop(null);
|
|
15760
|
+
};
|
|
15761
|
+
const onUp = () => finish(true);
|
|
15762
|
+
const onCancel = () => {
|
|
15763
|
+
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)');
|
|
15764
|
+
finish(false);
|
|
15765
|
+
};
|
|
15766
|
+
window.addEventListener("pointermove", onMove);
|
|
15767
|
+
window.addEventListener("pointerup", onUp);
|
|
15768
|
+
window.addEventListener("pointercancel", onCancel);
|
|
15769
|
+
};
|
|
15770
|
+
const startResize = (e, colName, startSpan) => {
|
|
15771
|
+
var _a, _b, _c, _d;
|
|
15772
|
+
if (!onFieldResize) return;
|
|
15773
|
+
const grid = gridRef.current;
|
|
15774
|
+
const item = e.currentTarget.closest("[data-fdz-field]");
|
|
15775
|
+
if (!grid || !item) return;
|
|
15776
|
+
e.preventDefault();
|
|
15777
|
+
e.stopPropagation();
|
|
15778
|
+
const box = item.querySelector("[data-fdz-box]");
|
|
15779
|
+
const colW = (grid.clientWidth - t.gap * 5) / 6;
|
|
15780
|
+
const rtl = grid.closest('[dir="rtl"]') !== null || getComputedStyle(grid).direction === "rtl";
|
|
15781
|
+
const state = {
|
|
15782
|
+
name: colName,
|
|
15783
|
+
startX: e.clientX,
|
|
15784
|
+
startY: e.clientY,
|
|
15785
|
+
startSpan,
|
|
15786
|
+
step: colW + t.gap,
|
|
15787
|
+
rtl,
|
|
15788
|
+
startHeight: box ? box.offsetHeight : 40,
|
|
15789
|
+
hadHeight: !!((_b = (_a = design == null ? void 0 : design.fields) == null ? void 0 : _a[colName]) == null ? void 0 : _b.height),
|
|
15790
|
+
span: startSpan,
|
|
15791
|
+
height: (_d = (_c = design == null ? void 0 : design.fields) == null ? void 0 : _c[colName]) == null ? void 0 : _d.height
|
|
15792
|
+
};
|
|
15793
|
+
resizeRef.current = state;
|
|
15794
|
+
setResizing({ name: colName, span: state.span, height: state.height });
|
|
15795
|
+
const onMove = (ev) => {
|
|
15796
|
+
const dxRaw = ev.clientX - state.startX;
|
|
15797
|
+
const dx = state.rtl ? -dxRaw : dxRaw;
|
|
15798
|
+
const span = Math.max(1, Math.min(6, Math.round(state.startSpan + dx / state.step)));
|
|
15799
|
+
const dy = ev.clientY - state.startY;
|
|
15800
|
+
const height = Math.abs(dy) < 8 && !state.hadHeight ? void 0 : Math.max(40, Math.round(state.startHeight + dy));
|
|
15801
|
+
if (span !== state.span || height !== state.height) {
|
|
15802
|
+
state.span = span;
|
|
15803
|
+
state.height = height;
|
|
15804
|
+
setResizing({ name: state.name, span, height });
|
|
15805
|
+
}
|
|
15806
|
+
};
|
|
15807
|
+
const onUp = () => {
|
|
15808
|
+
window.removeEventListener("pointermove", onMove);
|
|
15809
|
+
window.removeEventListener("pointerup", onUp);
|
|
15810
|
+
window.removeEventListener("pointercancel", onUp);
|
|
15811
|
+
resizeRef.current = null;
|
|
15812
|
+
onFieldResize(state.name, { span: state.span, height: state.height });
|
|
15813
|
+
setResizing(null);
|
|
15814
|
+
};
|
|
15815
|
+
window.addEventListener("pointermove", onMove);
|
|
15816
|
+
window.addEventListener("pointerup", onUp);
|
|
15817
|
+
window.addEventListener("pointercancel", onUp);
|
|
15818
|
+
};
|
|
15414
15819
|
const handleSubmit = async (e) => {
|
|
15415
15820
|
e.preventDefault();
|
|
15821
|
+
if (previewMode) return;
|
|
15416
15822
|
if (!executeAction) {
|
|
15417
15823
|
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");
|
|
15418
15824
|
return;
|
|
@@ -15421,8 +15827,12 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
|
|
|
15421
15827
|
showError("\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E9\u05DE\u05D5\u05E8: \u05DE\u05D6\u05D4\u05D4 \u05D4\u05D8\u05D1\u05DC\u05D4 \u05D7\u05E1\u05E8", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15422
15828
|
return;
|
|
15423
15829
|
}
|
|
15830
|
+
if (submitMode === "update" && !recordId) {
|
|
15831
|
+
showError("\u05D4\u05E7\u05D9\u05E9\u05D5\u05E8 \u05D0\u05D9\u05E0\u05D5 \u05DE\u05E7\u05D5\u05E9\u05E8 \u05DC\u05E8\u05E9\u05D5\u05DE\u05D4 \u05E7\u05D9\u05D9\u05DE\u05EA", "\u05E9\u05D2\u05D9\u05D0\u05EA \u05E9\u05DE\u05D9\u05E8\u05D4");
|
|
15832
|
+
return;
|
|
15833
|
+
}
|
|
15424
15834
|
const missingFields = formColumns.filter(
|
|
15425
|
-
(col) => col
|
|
15835
|
+
(col) => isFieldRequired(col, design) && !isFieldLocked(col, design) && (formData[col.name] === void 0 || formData[col.name] === null || formData[col.name] === "")
|
|
15426
15836
|
);
|
|
15427
15837
|
if (missingFields.length > 0) {
|
|
15428
15838
|
showError(`\u05D9\u05E9 \u05DC\u05DE\u05DC\u05D0 \u05D0\u05EA \u05D4\u05E9\u05D3\u05D5\u05EA \u05D4\u05D1\u05D0\u05D9\u05DD: ${missingFields.map((c) => c.name).join(", ")}`, "\u05E9\u05D2\u05D9\u05D0\u05EA \u05D5\u05DC\u05D9\u05D3\u05E6\u05D9\u05D4");
|
|
@@ -15430,108 +15840,318 @@ function FormBlock({ settings: schema, executeAction, componentId, className = "
|
|
|
15430
15840
|
}
|
|
15431
15841
|
setIsSubmitting(true);
|
|
15432
15842
|
try {
|
|
15433
|
-
const
|
|
15843
|
+
const payload = {};
|
|
15434
15844
|
formColumns.forEach((col) => {
|
|
15435
15845
|
var _a;
|
|
15846
|
+
if (isFieldLocked(col, design)) {
|
|
15847
|
+
const lockedDefault = parseColumnDefault(col);
|
|
15848
|
+
if (submitMode !== "update" && lockedDefault !== void 0) payload[col.name] = lockedDefault;
|
|
15849
|
+
return;
|
|
15850
|
+
}
|
|
15436
15851
|
let val = formData[col.name];
|
|
15437
15852
|
if (val !== void 0 && val !== null) {
|
|
15438
|
-
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER")
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
formattedPayload[col.name] = col.defaultValue;
|
|
15853
|
+
if (((_a = col.type) == null ? void 0 : _a.toUpperCase()) === "NUMBER") val = val === "" ? 0 : Number(val);
|
|
15854
|
+
payload[col.name] = val;
|
|
15855
|
+
} else if (submitMode !== "update") {
|
|
15856
|
+
const dv = parseColumnDefault(col);
|
|
15857
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15444
15858
|
}
|
|
15445
15859
|
});
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15860
|
+
if (submitMode === "update") {
|
|
15861
|
+
await executeAction("UPDATE_RECORD", {
|
|
15862
|
+
tableId: targetTableId,
|
|
15863
|
+
tableMetaId: targetTableId,
|
|
15864
|
+
recordId,
|
|
15865
|
+
data: payload
|
|
15866
|
+
});
|
|
15867
|
+
} else {
|
|
15868
|
+
hiddenColumns.forEach((col) => {
|
|
15869
|
+
const dv = parseColumnDefault(col);
|
|
15870
|
+
if (dv !== void 0) payload[col.name] = dv;
|
|
15871
|
+
});
|
|
15872
|
+
await executeAction("CREATE_RECORD", {
|
|
15873
|
+
tableId: targetTableId,
|
|
15874
|
+
tableMetaId: targetTableId,
|
|
15875
|
+
records: [payload]
|
|
15876
|
+
});
|
|
15877
|
+
}
|
|
15451
15878
|
addToast({ message: "\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D5 \u05D1\u05D4\u05E6\u05DC\u05D7\u05D4", type: "success" });
|
|
15452
|
-
setFormData(
|
|
15879
|
+
if (submitMode !== "update") setFormData(buildDefaultValues(columns));
|
|
15453
15880
|
setIsSubmitted(true);
|
|
15454
15881
|
if (onSuccess) onSuccess();
|
|
15455
15882
|
} catch (err) {
|
|
15456
|
-
console.error("[
|
|
15883
|
+
console.error("[StyledFormBlock] Submit error:", err);
|
|
15457
15884
|
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");
|
|
15458
15885
|
} finally {
|
|
15459
15886
|
setIsSubmitting(false);
|
|
15460
15887
|
}
|
|
15461
15888
|
};
|
|
15889
|
+
const muted = t.invertText ? "rgba(255,255,255,0.85)" : "#64748b";
|
|
15890
|
+
const cardStyle = {
|
|
15891
|
+
background: d.background,
|
|
15892
|
+
color: d.text,
|
|
15893
|
+
borderRadius: t.radius,
|
|
15894
|
+
border: t.border,
|
|
15895
|
+
boxShadow: t.shadow,
|
|
15896
|
+
padding: t.headerBand ? 0 : t.padding,
|
|
15897
|
+
overflow: t.headerBand ? "hidden" : void 0
|
|
15898
|
+
};
|
|
15899
|
+
const inputBoxStyle = t.inputStyle === "underline" ? { borderBottom: "1px solid #cbd5e1", borderRadius: 0, background: "transparent", minHeight: 40, position: "relative" } : {
|
|
15900
|
+
border: "1px solid #e2e8f0",
|
|
15901
|
+
borderRadius: Math.min(t.radius, 10) || 6,
|
|
15902
|
+
background: "#ffffff",
|
|
15903
|
+
color: "#0f172a",
|
|
15904
|
+
minHeight: 40,
|
|
15905
|
+
position: "relative"
|
|
15906
|
+
};
|
|
15907
|
+
const booleanBoxStyle = __spreadProps(__spreadValues({}, inputBoxStyle), {
|
|
15908
|
+
width: "fit-content",
|
|
15909
|
+
minWidth: 40,
|
|
15910
|
+
alignSelf: "flex-start",
|
|
15911
|
+
display: "flex",
|
|
15912
|
+
alignItems: "center",
|
|
15913
|
+
justifyContent: "center"
|
|
15914
|
+
});
|
|
15915
|
+
const css = `
|
|
15916
|
+
.${uid}{container-type:inline-size}
|
|
15917
|
+
.${uid} .fdz-grid{display:flex;flex-wrap:wrap;align-items:flex-end;gap:${t.gap}px}
|
|
15918
|
+
.${uid} .fdz-f{--n:6;flex:0 0 auto;box-sizing:border-box;min-width:0;display:flex;flex-direction:column;gap:6px;width:calc((100% - ${t.gap * 5}px) / 6 * var(--n) + ${t.gap}px * (var(--n) - 1) - 0.5px)}
|
|
15919
|
+
.${uid} .fdz-s1{--n:2}
|
|
15920
|
+
.${uid} .fdz-b{width:fit-content;max-width:140px;margin-inline-end:-${Math.max(0, t.gap - 8)}px}
|
|
15921
|
+
@container (min-width:480px){
|
|
15922
|
+
.${uid} .fdz-f{--n:var(--span)}
|
|
15923
|
+
}
|
|
15924
|
+
`;
|
|
15462
15925
|
if (isLoadingSchema) {
|
|
15463
|
-
return /* @__PURE__ */
|
|
15464
|
-
/* @__PURE__ */
|
|
15465
|
-
/* @__PURE__ */
|
|
15926
|
+
return /* @__PURE__ */ jsxs26("div", { className: "p-8 flex items-center justify-center gap-2 text-slate-500", dir: "rtl", children: [
|
|
15927
|
+
/* @__PURE__ */ jsx30(Loader210, { className: "w-5 h-5 animate-spin", style: { color: d.primary } }),
|
|
15928
|
+
/* @__PURE__ */ jsx30("span", { className: "text-sm", children: "\u05D8\u05D5\u05E2\u05DF \u05E9\u05D3\u05D5\u05EA \u05D8\u05D5\u05E4\u05E1..." })
|
|
15466
15929
|
] });
|
|
15467
15930
|
}
|
|
15468
15931
|
if (!formColumns || formColumns.length === 0) {
|
|
15469
|
-
return /* @__PURE__ */
|
|
15932
|
+
return /* @__PURE__ */ jsx30("div", { className: "p-4 text-center text-slate-500", children: "\u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8\u05D5 \u05E9\u05D3\u05D5\u05EA \u05DC\u05D8\u05D5\u05E4\u05E1 \u05D6\u05D4." });
|
|
15470
15933
|
}
|
|
15934
|
+
const logoJustify = d.logoAlign === "center" ? "center" : d.logoAlign === "end" ? "flex-end" : "flex-start";
|
|
15935
|
+
const headerBlock = (schema == null ? void 0 : schema.title) || d.subtitle || d.logoUrl ? /* @__PURE__ */ jsxs26(
|
|
15936
|
+
"div",
|
|
15937
|
+
{
|
|
15938
|
+
style: t.headerBand ? { background: d.primary, color: "#ffffff", padding: `${t.padding * 0.8}px ${t.padding}px` } : { marginBottom: t.gap + 4 },
|
|
15939
|
+
children: [
|
|
15940
|
+
d.logoUrl && /* @__PURE__ */ jsx30("div", { style: { display: "flex", justifyContent: logoJustify, marginBottom: (schema == null ? void 0 : schema.title) || d.subtitle ? 12 : 0 }, children: /* @__PURE__ */ jsx30("img", { src: d.logoUrl, alt: "", style: { height: d.logoHeight, maxWidth: "100%", objectFit: "contain", display: "block" } }) }),
|
|
15941
|
+
(schema == null ? void 0 : schema.title) && /* @__PURE__ */ jsx30("h2", { style: __spreadValues({ fontSize: t.titleSize, fontWeight: 800, margin: 0 }, d.titleColor ? { color: d.titleColor } : {}), children: schema.title }),
|
|
15942
|
+
d.subtitle && /* @__PURE__ */ jsx30("p", { style: { fontSize: 14, margin: "6px 0 0", color: t.headerBand ? "rgba(255,255,255,0.9)" : muted }, children: d.subtitle })
|
|
15943
|
+
]
|
|
15944
|
+
}
|
|
15945
|
+
) : null;
|
|
15471
15946
|
if (isSubmitted) {
|
|
15472
15947
|
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.";
|
|
15473
|
-
return /* @__PURE__ */
|
|
15474
|
-
/* @__PURE__ */
|
|
15475
|
-
|
|
15476
|
-
|
|
15477
|
-
|
|
15948
|
+
return /* @__PURE__ */ jsxs26("div", { id: componentId, dir: "rtl", className, style: __spreadProps(__spreadValues({}, cardStyle), { padding: t.padding || 24, textAlign: "center" }), children: [
|
|
15949
|
+
/* @__PURE__ */ jsx30(
|
|
15950
|
+
"div",
|
|
15951
|
+
{
|
|
15952
|
+
style: {
|
|
15953
|
+
width: 64,
|
|
15954
|
+
height: 64,
|
|
15955
|
+
borderRadius: "50%",
|
|
15956
|
+
margin: "0 auto 16px",
|
|
15957
|
+
display: "flex",
|
|
15958
|
+
alignItems: "center",
|
|
15959
|
+
justifyContent: "center",
|
|
15960
|
+
background: t.invertText ? "rgba(255,255,255,0.2)" : "#ecfdf5",
|
|
15961
|
+
color: t.invertText ? "#ffffff" : "#059669"
|
|
15962
|
+
},
|
|
15963
|
+
children: /* @__PURE__ */ jsx30(CheckCircle26, { className: "w-8 h-8" })
|
|
15964
|
+
}
|
|
15965
|
+
),
|
|
15966
|
+
/* @__PURE__ */ jsx30("h3", { style: { fontSize: 24, fontWeight: 800, margin: "0 0 8px" }, children: "\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E0\u05E9\u05DC\u05D7\u05D4" }),
|
|
15967
|
+
/* @__PURE__ */ jsx30("p", { style: { fontSize: 16, color: muted, maxWidth: 420, margin: "0 auto", whiteSpace: "pre-wrap" }, children: customMessage }),
|
|
15968
|
+
submitMode !== "update" && /* @__PURE__ */ jsx30(
|
|
15478
15969
|
"button",
|
|
15479
15970
|
{
|
|
15480
15971
|
type: "button",
|
|
15481
15972
|
onClick: () => setIsSubmitted(false),
|
|
15482
|
-
|
|
15973
|
+
style: { marginTop: 24, fontSize: 12, fontWeight: 600, color: t.invertText ? "#ffffff" : d.primary, background: "none", border: "none", cursor: "pointer", textDecoration: "underline" },
|
|
15483
15974
|
children: "\u05E9\u05DC\u05D9\u05D7\u05EA \u05DE\u05E2\u05E0\u05D4 \u05E0\u05D5\u05E1\u05E3"
|
|
15484
15975
|
}
|
|
15485
15976
|
)
|
|
15486
15977
|
] });
|
|
15487
15978
|
}
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
/* @__PURE__ */
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
const
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15979
|
+
const justify = d.buttonAlign === "center" ? "center" : d.buttonAlign === "end" ? "flex-end" : d.buttonAlign === "full" ? "stretch" : "flex-start";
|
|
15980
|
+
return /* @__PURE__ */ jsxs26("div", { id: componentId, dir: "rtl", className: `${uid} ${className}`, style: cardStyle, children: [
|
|
15981
|
+
/* @__PURE__ */ jsx30("style", { children: css }),
|
|
15982
|
+
headerBlock,
|
|
15983
|
+
/* @__PURE__ */ jsx30("div", { style: t.headerBand ? { padding: t.padding } : void 0, children: /* @__PURE__ */ jsxs26("form", { onSubmit: handleSubmit, children: [
|
|
15984
|
+
/* @__PURE__ */ jsx30("div", { className: "fdz-grid", ref: gridRef, children: (() => {
|
|
15985
|
+
const spanOf = (col) => {
|
|
15986
|
+
var _a;
|
|
15987
|
+
if (resizing && resizing.name === col.name) return resizing.span;
|
|
15988
|
+
const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
|
|
15989
|
+
return resolveFieldSpan(col.name, colType, design, d.columns);
|
|
15990
|
+
};
|
|
15991
|
+
const renderField = (col) => {
|
|
15992
|
+
var _a, _b, _c, _d, _e;
|
|
15993
|
+
const colType = ((_a = col.type) == null ? void 0 : _a.toUpperCase()) || "DEFAULT";
|
|
15994
|
+
const InputComponent = FORM_INPUTS[colType] || FORM_INPUTS.DEFAULT;
|
|
15995
|
+
const span = spanOf(col);
|
|
15996
|
+
const isBoolean = colType === "BOOLEAN";
|
|
15997
|
+
const locked = isFieldLocked(col, design);
|
|
15998
|
+
const shownValue = (_c = formData[col.name]) != null ? _c : locked && submitMode !== "update" ? (_b = parseColumnDefault(col)) != null ? _b : "" : "";
|
|
15999
|
+
const fieldHeight = resizing && resizing.name === col.name ? resizing.height : (_e = (_d = design == null ? void 0 : design.fields) == null ? void 0 : _d[col.name]) == null ? void 0 : _e.height;
|
|
16000
|
+
const useTextarea = !!fieldHeight && fieldHeight > 56 && InputComponent === FORM_INPUTS.DEFAULT;
|
|
16001
|
+
const boxStyle = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, isBoolean ? booleanBoxStyle : inputBoxStyle), fieldHeight && !isBoolean ? __spreadValues({ minHeight: fieldHeight }, useTextarea ? { height: fieldHeight } : {}) : {}), canReorder ? { pointerEvents: "none" } : {}), locked ? { background: t.inputStyle === "underline" ? "transparent" : "#f1f5f9", opacity: 0.85, cursor: "not-allowed" } : {});
|
|
16002
|
+
return /* @__PURE__ */ jsxs26(
|
|
16003
|
+
"div",
|
|
15503
16004
|
{
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
16005
|
+
"data-fdz-field": col.name,
|
|
16006
|
+
className: `fdz-f fdz-s${span}${isBoolean ? " fdz-b" : ""}`,
|
|
16007
|
+
draggable: false,
|
|
16008
|
+
onDragStart: canReorder ? (e) => e.preventDefault() : void 0,
|
|
16009
|
+
onMouseDown: canReorder ? (e) => e.stopPropagation() : void 0,
|
|
16010
|
+
onTouchStart: canReorder ? (e) => e.stopPropagation() : void 0,
|
|
16011
|
+
onPointerDown: canReorder ? (e) => {
|
|
16012
|
+
e.stopPropagation();
|
|
16013
|
+
startDrag(e, col.name);
|
|
16014
|
+
} : void 0,
|
|
16015
|
+
style: __spreadValues({ "--span": span }, canReorder ? {
|
|
16016
|
+
position: "relative",
|
|
16017
|
+
cursor: "grab",
|
|
16018
|
+
touchAction: "none",
|
|
16019
|
+
userSelect: "none",
|
|
16020
|
+
opacity: dragName === col.name ? 0.4 : 1,
|
|
16021
|
+
outline: resizing && resizing.name === col.name ? `2px solid ${t.invertText ? "#ffffff" : d.primary}` : void 0,
|
|
16022
|
+
outlineOffset: 4,
|
|
16023
|
+
borderRadius: 6
|
|
16024
|
+
} : {}),
|
|
16025
|
+
children: [
|
|
16026
|
+
/* @__PURE__ */ jsxs26("label", { style: { fontSize: t.labelSize, fontWeight: 600, color: d.text }, children: [
|
|
16027
|
+
col.name,
|
|
16028
|
+
" ",
|
|
16029
|
+
isFieldRequired(col, design) && !locked && /* @__PURE__ */ jsx30("span", { style: { color: t.invertText ? "#fecdd3" : "#f43f5e" }, children: "*" }),
|
|
16030
|
+
locked && /* @__PURE__ */ jsx30("span", { style: { fontSize: 11, fontWeight: 400, opacity: 0.7 }, children: "(\u05DC\u05D0 \u05E0\u05D9\u05EA\u05DF \u05DC\u05E2\u05E8\u05D9\u05DB\u05D4)" })
|
|
16031
|
+
] }),
|
|
16032
|
+
/* @__PURE__ */ jsx30("div", { "data-fdz-box": true, style: boxStyle, children: useTextarea ? /* @__PURE__ */ jsx30(
|
|
16033
|
+
"textarea",
|
|
16034
|
+
{
|
|
16035
|
+
value: shownValue,
|
|
16036
|
+
onChange: (e) => handleFieldChange(col.name, e.target.value),
|
|
16037
|
+
readOnly: previewMode || locked,
|
|
16038
|
+
style: {
|
|
16039
|
+
width: "100%",
|
|
16040
|
+
height: "100%",
|
|
16041
|
+
minHeight: fieldHeight - 2,
|
|
16042
|
+
padding: "8px 12px",
|
|
16043
|
+
border: "none",
|
|
16044
|
+
outline: "none",
|
|
16045
|
+
background: "transparent",
|
|
16046
|
+
resize: "none",
|
|
16047
|
+
font: "inherit",
|
|
16048
|
+
color: "inherit",
|
|
16049
|
+
boxSizing: "border-box"
|
|
16050
|
+
}
|
|
16051
|
+
}
|
|
16052
|
+
) : /* @__PURE__ */ jsx30(
|
|
16053
|
+
InputComponent,
|
|
16054
|
+
{
|
|
16055
|
+
column: col,
|
|
16056
|
+
rowId: "new_form_record",
|
|
16057
|
+
value: shownValue,
|
|
16058
|
+
onChange: (val) => handleFieldChange(col.name, val),
|
|
16059
|
+
readOnly: previewMode || locked,
|
|
16060
|
+
context: { executeAction: previewMode ? void 0 : executeAction, tableId: targetTableId, relationDictionaryRef: relationDictRef }
|
|
16061
|
+
}
|
|
16062
|
+
) }),
|
|
16063
|
+
canReorder && dragName && drop && drop.name === col.name && /* @__PURE__ */ jsx30(
|
|
16064
|
+
"div",
|
|
16065
|
+
{
|
|
16066
|
+
style: __spreadValues({
|
|
16067
|
+
position: "absolute",
|
|
16068
|
+
top: 0,
|
|
16069
|
+
bottom: 0,
|
|
16070
|
+
width: 4,
|
|
16071
|
+
borderRadius: 2,
|
|
16072
|
+
background: t.invertText ? "#ffffff" : d.primary,
|
|
16073
|
+
pointerEvents: "none",
|
|
16074
|
+
zIndex: 3
|
|
16075
|
+
}, drop.side === "before" ? { insetInlineStart: -(t.gap / 2) - 2 } : { insetInlineEnd: -(t.gap / 2) - 2 })
|
|
16076
|
+
}
|
|
16077
|
+
),
|
|
16078
|
+
onFieldResize && !isBoolean && /* @__PURE__ */ jsx30(
|
|
16079
|
+
"div",
|
|
16080
|
+
{
|
|
16081
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
16082
|
+
onTouchStart: (e) => e.stopPropagation(),
|
|
16083
|
+
onPointerDown: (e) => startResize(e, col.name, span),
|
|
16084
|
+
onDoubleClick: () => onFieldResize(col.name, { reset: true }),
|
|
16085
|
+
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)",
|
|
16086
|
+
style: {
|
|
16087
|
+
position: "absolute",
|
|
16088
|
+
left: -6,
|
|
16089
|
+
bottom: -6,
|
|
16090
|
+
width: 14,
|
|
16091
|
+
height: 14,
|
|
16092
|
+
borderRadius: 4,
|
|
16093
|
+
background: "#ffffff",
|
|
16094
|
+
border: `2px solid ${d.primary}`,
|
|
16095
|
+
cursor: "nesw-resize",
|
|
16096
|
+
touchAction: "none",
|
|
16097
|
+
zIndex: 2
|
|
16098
|
+
}
|
|
16099
|
+
}
|
|
16100
|
+
)
|
|
16101
|
+
]
|
|
16102
|
+
},
|
|
16103
|
+
col.name
|
|
16104
|
+
);
|
|
16105
|
+
};
|
|
16106
|
+
return formColumns.map((col) => renderField(col));
|
|
16107
|
+
})() }),
|
|
16108
|
+
/* @__PURE__ */ jsx30(
|
|
16109
|
+
"div",
|
|
15518
16110
|
{
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
16111
|
+
style: {
|
|
16112
|
+
marginTop: t.gap + 8,
|
|
16113
|
+
paddingTop: t.inputStyle === "underline" || t.invertText ? 0 : t.gap,
|
|
16114
|
+
borderTop: t.inputStyle === "underline" || t.invertText ? "none" : "1px solid rgba(148,163,184,0.25)",
|
|
16115
|
+
display: "flex",
|
|
16116
|
+
justifyContent: justify
|
|
16117
|
+
},
|
|
16118
|
+
children: /* @__PURE__ */ jsxs26(
|
|
16119
|
+
"button",
|
|
16120
|
+
{
|
|
16121
|
+
type: "submit",
|
|
16122
|
+
disabled: isSubmitting || previewMode,
|
|
16123
|
+
style: {
|
|
16124
|
+
display: "flex",
|
|
16125
|
+
alignItems: "center",
|
|
16126
|
+
justifyContent: "center",
|
|
16127
|
+
gap: 8,
|
|
16128
|
+
padding: "10px 28px",
|
|
16129
|
+
width: d.buttonAlign === "full" ? "100%" : void 0,
|
|
16130
|
+
background: t.invertText ? "#ffffff" : d.primary,
|
|
16131
|
+
color: t.invertText ? d.primary : "#ffffff",
|
|
16132
|
+
fontWeight: 700,
|
|
16133
|
+
fontSize: 15,
|
|
16134
|
+
border: "none",
|
|
16135
|
+
borderRadius: Math.min(t.radius, 10) || 6,
|
|
16136
|
+
boxShadow: "0 1px 2px rgba(0,0,0,0.1)",
|
|
16137
|
+
cursor: isSubmitting || previewMode ? "default" : "pointer",
|
|
16138
|
+
opacity: isSubmitting ? 0.5 : 1
|
|
16139
|
+
},
|
|
16140
|
+
children: [
|
|
16141
|
+
isSubmitting && /* @__PURE__ */ jsx30(Loader210, { className: "w-4 h-4 animate-spin" }),
|
|
16142
|
+
/* @__PURE__ */ jsx30("span", { children: isSubmitting ? "\u05E9\u05D5\u05DE\u05E8..." : d.buttonText })
|
|
16143
|
+
]
|
|
16144
|
+
}
|
|
16145
|
+
)
|
|
15526
16146
|
}
|
|
15527
|
-
)
|
|
15528
|
-
] })
|
|
16147
|
+
)
|
|
16148
|
+
] }) })
|
|
15529
16149
|
] });
|
|
15530
16150
|
}
|
|
15531
16151
|
|
|
15532
16152
|
// src/themes/ThemeScope.tsx
|
|
15533
|
-
import * as
|
|
15534
|
-
import { jsx as
|
|
16153
|
+
import * as React23 from "react";
|
|
16154
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
15535
16155
|
var UNIVERSE_THEME_IDS = ["classic", "clean", "ocean", "warm"];
|
|
15536
16156
|
function resolveUniverseTheme(value) {
|
|
15537
16157
|
return typeof value === "string" && UNIVERSE_THEME_IDS.includes(value) ? value : "classic";
|
|
@@ -15541,7 +16161,7 @@ function withThemeScope(Component) {
|
|
|
15541
16161
|
var _a, _b, _c;
|
|
15542
16162
|
const p = props;
|
|
15543
16163
|
const theme = resolveUniverseTheme((_c = (_a = p.settings) == null ? void 0 : _a.theme) != null ? _c : (_b = p.config) == null ? void 0 : _b.theme);
|
|
15544
|
-
return /* @__PURE__ */
|
|
16164
|
+
return /* @__PURE__ */ jsx31("div", { "data-theme": theme, style: { display: "contents" }, children: React23.createElement(Component, props) });
|
|
15545
16165
|
}
|
|
15546
16166
|
ThemeScoped.displayName = `ThemeScoped(${Component.displayName || Component.name || "Component"})`;
|
|
15547
16167
|
return ThemeScoped;
|
|
@@ -15551,7 +16171,7 @@ function withThemeScope(Component) {
|
|
|
15551
16171
|
var UNIVERSE_COMPONENTS = {
|
|
15552
16172
|
TABLE: withThemeScope(TableBlock),
|
|
15553
16173
|
WHATSAPP: withThemeScope(WhatsAppComponent),
|
|
15554
|
-
FORM: withThemeScope(
|
|
16174
|
+
FORM: withThemeScope(StyledFormBlock),
|
|
15555
16175
|
PLACEMENT: withThemeScope(PlacementBlock)
|
|
15556
16176
|
};
|
|
15557
16177
|
export {
|