@universe-platform/ui 0.1.0-beta.73 → 0.1.0-beta.75
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 +50 -17
- package/dist/index.mjs +50 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6124,16 +6124,31 @@ function SubTableCell({
|
|
|
6124
6124
|
);
|
|
6125
6125
|
}
|
|
6126
6126
|
function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
6127
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6127
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6128
6128
|
const isReadOnly = readOnly != null ? readOnly : Boolean(context == null ? void 0 : context.readOnly);
|
|
6129
6129
|
const { addToast } = useToast();
|
|
6130
6130
|
const entries = Array.isArray(value) ? value : [];
|
|
6131
|
+
const linkedRepField = (_b = (_a = column.config) == null ? void 0 : _a.linkConfig) == null ? void 0 : _b.repField;
|
|
6132
|
+
const linkedRepValue = linkedRepField ? (_c = context == null ? void 0 : context.rowData) == null ? void 0 : _c[linkedRepField] : void 0;
|
|
6133
|
+
const repIndicatorField = (_e = (_d = column.config) == null ? void 0 : _d.linkConfig) == null ? void 0 : _e.repIndicatorField;
|
|
6134
|
+
const isRepEligible = (recordId) => {
|
|
6135
|
+
var _a2, _b2;
|
|
6136
|
+
if (!linkedRepField || !repIndicatorField) return true;
|
|
6137
|
+
const rec = linkedRecords.find((r) => r.id === recordId);
|
|
6138
|
+
const entry = entries.find((e) => e.recordId === recordId);
|
|
6139
|
+
const v = (_b2 = (_a2 = rec == null ? void 0 : rec.data) != null ? _a2 : entry == null ? void 0 : entry._resolvedData) == null ? void 0 : _b2[repIndicatorField];
|
|
6140
|
+
return v === true || v === "true" || v === "TRUE" || v === "\u05DB\u05DF";
|
|
6141
|
+
};
|
|
6131
6142
|
const effectivePrimaryRecordId = (0, import_react14.useMemo)(() => {
|
|
6143
|
+
if (Array.isArray(linkedRepValue)) {
|
|
6144
|
+
const repEntry = linkedRepValue.find((e) => e && typeof e === "object" && e.isSelected !== false && e.recordId);
|
|
6145
|
+
if (repEntry && entries.some((e) => e.isSelected && e.recordId === repEntry.recordId)) return repEntry.recordId;
|
|
6146
|
+
}
|
|
6132
6147
|
const explicit = entries.find((e) => e.isSelected && e.isPrimary);
|
|
6133
6148
|
if (explicit) return explicit.recordId;
|
|
6134
6149
|
const fallback = entries.find((e) => e.isSelected);
|
|
6135
6150
|
return fallback ? fallback.recordId : null;
|
|
6136
|
-
}, [entries]);
|
|
6151
|
+
}, [entries, linkedRepValue]);
|
|
6137
6152
|
const [linkedRecords, setLinkedRecords] = (0, import_react14.useState)(() => {
|
|
6138
6153
|
const initial = [];
|
|
6139
6154
|
for (const entry of entries) {
|
|
@@ -6159,7 +6174,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6159
6174
|
const searchRef = (0, import_react14.useRef)(null);
|
|
6160
6175
|
const searchTimerRef = (0, import_react14.useRef)(null);
|
|
6161
6176
|
const executeAction = context == null ? void 0 : context.executeAction;
|
|
6162
|
-
const referencedTableId = ((
|
|
6177
|
+
const referencedTableId = ((_f = column.config) == null ? void 0 : _f.referencedTableId) || column.referencedTableId;
|
|
6163
6178
|
const fetchedIdsRef = (0, import_react14.useRef)(/* @__PURE__ */ new Set());
|
|
6164
6179
|
(0, import_react14.useEffect)(() => {
|
|
6165
6180
|
if (entries.length > 0) {
|
|
@@ -6241,7 +6256,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6241
6256
|
const [localColumnOrder, setLocalColumnOrder] = (0, import_react14.useState)(null);
|
|
6242
6257
|
(0, import_react14.useEffect)(() => {
|
|
6243
6258
|
setLocalColumnOrder(null);
|
|
6244
|
-
}, [column.name, (
|
|
6259
|
+
}, [column.name, (_g = column.config) == null ? void 0 : _g.subTableColumnOrder]);
|
|
6245
6260
|
const rawTargetColumns = (0, import_react14.useMemo)(() => {
|
|
6246
6261
|
return ((targetSchema == null ? void 0 : targetSchema.columns) || []).filter(
|
|
6247
6262
|
(c) => c.name !== "_id" && c.type !== "SUB_TABLE"
|
|
@@ -6263,7 +6278,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6263
6278
|
return idxA - idxB;
|
|
6264
6279
|
});
|
|
6265
6280
|
return sorted;
|
|
6266
|
-
}, [rawTargetColumns, localColumnOrder, (
|
|
6281
|
+
}, [rawTargetColumns, localColumnOrder, (_h = column.config) == null ? void 0 : _h.subTableColumnOrder]);
|
|
6267
6282
|
const handleSubTableColumnReorder = async (draggedName, dropTargetName) => {
|
|
6268
6283
|
if (draggedName === dropTargetName) return;
|
|
6269
6284
|
const currentNames = targetColumns.map((c) => c.name);
|
|
@@ -6352,6 +6367,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6352
6367
|
return [];
|
|
6353
6368
|
}, [targetColumns, executeAction]);
|
|
6354
6369
|
const updateParentLinkage = async (updated) => {
|
|
6370
|
+
var _a2;
|
|
6355
6371
|
const isNewRow = rowId.startsWith("temp_");
|
|
6356
6372
|
if (context == null ? void 0 : context.updateQuietly) {
|
|
6357
6373
|
context.updateQuietly(rowId, column.name, updated);
|
|
@@ -6373,6 +6389,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6373
6389
|
if (context == null ? void 0 : context.triggerSaveSuccess) {
|
|
6374
6390
|
context.triggerSaveSuccess();
|
|
6375
6391
|
}
|
|
6392
|
+
(_a2 = context == null ? void 0 : context.refreshRows) == null ? void 0 : _a2.call(context);
|
|
6376
6393
|
} catch (err) {
|
|
6377
6394
|
console.error("Failed to auto-save parent linkage", err);
|
|
6378
6395
|
}
|
|
@@ -6500,6 +6517,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6500
6517
|
if (isReadOnly) return;
|
|
6501
6518
|
const target = entries.find((e) => e.recordId === recordId);
|
|
6502
6519
|
if (!target || !target.isSelected) return;
|
|
6520
|
+
if (!isRepEligible(recordId)) return;
|
|
6503
6521
|
const updated = entries.map((e) => {
|
|
6504
6522
|
const record = linkedRecords.find((r) => r.id === e.recordId);
|
|
6505
6523
|
if (e.recordId === recordId) {
|
|
@@ -6513,6 +6531,9 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6513
6531
|
_resolvedData: (record == null ? void 0 : record.data) || e._resolvedData
|
|
6514
6532
|
});
|
|
6515
6533
|
});
|
|
6534
|
+
if (linkedRepField && (context == null ? void 0 : context.updateQuietly)) {
|
|
6535
|
+
context.updateQuietly(rowId, linkedRepField, [{ recordId, isSelected: true, isPrimary: true }]);
|
|
6536
|
+
}
|
|
6516
6537
|
updateParentLinkage(updated);
|
|
6517
6538
|
};
|
|
6518
6539
|
const isMountedRef = (0, import_react14.useRef)(true);
|
|
@@ -6523,7 +6544,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6523
6544
|
};
|
|
6524
6545
|
}, []);
|
|
6525
6546
|
const handleCommitRecordCell = async (recordId, colName, value2) => {
|
|
6526
|
-
var _a2;
|
|
6547
|
+
var _a2, _b2;
|
|
6527
6548
|
const previousRecord = linkedRecords.find((r) => r.id === recordId);
|
|
6528
6549
|
const previousValue = (_a2 = previousRecord == null ? void 0 : previousRecord.data) == null ? void 0 : _a2[colName];
|
|
6529
6550
|
if (previousValue === value2) return true;
|
|
@@ -6567,6 +6588,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6567
6588
|
if (context == null ? void 0 : context.triggerSaveSuccess) {
|
|
6568
6589
|
context.triggerSaveSuccess();
|
|
6569
6590
|
}
|
|
6591
|
+
(_b2 = context == null ? void 0 : context.refreshRows) == null ? void 0 : _b2.call(context);
|
|
6570
6592
|
}
|
|
6571
6593
|
return true;
|
|
6572
6594
|
} catch (err) {
|
|
@@ -6699,7 +6721,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6699
6721
|
};
|
|
6700
6722
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "p-3 animate-in fade-in slide-in-from-top-2 duration-200", dir: "rtl", children: [
|
|
6701
6723
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-4 mb-2.5", children: [
|
|
6702
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-xs font-bold text-slate-600", children: (
|
|
6724
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-xs font-bold text-slate-600", children: (_j = targetSchema == null ? void 0 : targetSchema.name) != null ? _j : (_i = column.config) == null ? void 0 : _i.referencedTableName }) }),
|
|
6703
6725
|
!isReadOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
6704
6726
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative", ref: searchRef, children: [
|
|
6705
6727
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
@@ -6889,10 +6911,10 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6889
6911
|
"button",
|
|
6890
6912
|
{
|
|
6891
6913
|
type: "button",
|
|
6892
|
-
disabled: isReadOnly || !entry.isSelected,
|
|
6914
|
+
disabled: isReadOnly || !entry.isSelected || !isRepEligible(entry.recordId),
|
|
6893
6915
|
onClick: () => handleTogglePrimary(entry.recordId),
|
|
6894
|
-
title: !entry.isSelected ? "\u05D9\u05E9 \u05DC\u05E1\u05DE\u05DF \u05D0\u05EA \u05D4\u05E8\u05E9\u05D5\u05DE\u05D4 \u05DB\u05D3\u05D9 \u05DC\u05D4\u05D2\u05D3\u05D9\u05E8\u05D4 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : entry.recordId === effectivePrimaryRecordId ? "\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : "\u05D4\u05D2\u05D3\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9",
|
|
6895
|
-
className: `p-0.5 rounded transition-all inline-flex items-center justify-center ${entry.recordId === effectivePrimaryRecordId ? "text-amber-500 hover:text-amber-600 scale-110" : "text-slate-300 hover:text-amber-400 hover:scale-105"} ${isReadOnly || !entry.isSelected ? "opacity-25 cursor-not-allowed" : "cursor-pointer"}`,
|
|
6916
|
+
title: !entry.isSelected ? "\u05D9\u05E9 \u05DC\u05E1\u05DE\u05DF \u05D0\u05EA \u05D4\u05E8\u05E9\u05D5\u05DE\u05D4 \u05DB\u05D3\u05D9 \u05DC\u05D4\u05D2\u05D3\u05D9\u05E8\u05D4 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : !isRepEligible(entry.recordId) ? "\u05DB\u05D3\u05D9 \u05DC\u05D1\u05D7\u05D5\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05DE\u05D5\u05E2\u05D3\u05E3, \u05E1\u05DE\u05DF \u05E7\u05D5\u05D3\u05DD '\u05D4\u05D0\u05DD \u05E0\u05E6\u05D9\u05D2'" : entry.recordId === effectivePrimaryRecordId ? "\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : "\u05D4\u05D2\u05D3\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9",
|
|
6917
|
+
className: `p-0.5 rounded transition-all inline-flex items-center justify-center ${entry.recordId === effectivePrimaryRecordId ? "text-amber-500 hover:text-amber-600 scale-110" : "text-slate-300 hover:text-amber-400 hover:scale-105"} ${isReadOnly || !entry.isSelected || !isRepEligible(entry.recordId) ? "opacity-25 cursor-not-allowed" : "cursor-pointer"}`,
|
|
6896
6918
|
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6897
6919
|
import_lucide_react7.Star,
|
|
6898
6920
|
{
|
|
@@ -7052,7 +7074,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
7052
7074
|
" \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05E7\u05D9\u05D9\u05DE\u05D5\u05EA. \u05D4\u05D0\u05DD \u05DC\u05E7\u05E9\u05E8 \u05D0\u05EA \u05DB\u05D5\u05DC\u05DF?"
|
|
7053
7075
|
] }),
|
|
7054
7076
|
conflictModalState.matchingRecords.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "overflow-x-auto border border-slate-200 rounded-lg max-h-48 text-xs bg-white", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("table", { className: "w-full text-right border-collapse", children: [
|
|
7055
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: "bg-slate-100 text-slate-700 font-semibold border-b whitespace-nowrap", children: (targetColumns.length > 0 ? targetColumns.filter((c) => c.name !== "_id" && c.name !== "id") : Object.keys(((
|
|
7077
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("tr", { className: "bg-slate-100 text-slate-700 font-semibold border-b whitespace-nowrap", children: (targetColumns.length > 0 ? targetColumns.filter((c) => c.name !== "_id" && c.name !== "id") : Object.keys(((_k = conflictModalState.matchingRecords[0]) == null ? void 0 : _k.data) || {}).filter((k) => k !== "_id" && k !== "id").map((name) => ({ name }))).map((col) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
7056
7078
|
"th",
|
|
7057
7079
|
{
|
|
7058
7080
|
className: "bg-slate-100 text-slate-700 font-semibold p-2 border-b whitespace-nowrap",
|
|
@@ -11664,6 +11686,7 @@ function TableBlockClient({
|
|
|
11664
11686
|
handleUpdateColumnConfig,
|
|
11665
11687
|
onMarkForDeletion: handleMarkForDeletion,
|
|
11666
11688
|
triggerSaveSuccess,
|
|
11689
|
+
refreshRows: refetchTableData,
|
|
11667
11690
|
schema,
|
|
11668
11691
|
orgId,
|
|
11669
11692
|
componentId,
|
|
@@ -11859,10 +11882,18 @@ function ExpandedSubTables({
|
|
|
11859
11882
|
context
|
|
11860
11883
|
}) {
|
|
11861
11884
|
var _a;
|
|
11862
|
-
const
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11885
|
+
const repMirrorNames = new Set(
|
|
11886
|
+
subTableColumns.map((c) => {
|
|
11887
|
+
var _a2, _b;
|
|
11888
|
+
return (_b = (_a2 = c == null ? void 0 : c.config) == null ? void 0 : _a2.linkConfig) == null ? void 0 : _b.repField;
|
|
11889
|
+
}).filter((n) => typeof n === "string" && n.length > 0)
|
|
11890
|
+
);
|
|
11891
|
+
const visibleColumns = subTableColumns.filter((c) => !repMirrorNames.has(c.name));
|
|
11892
|
+
const tabColumns = visibleColumns.length > 0 ? visibleColumns : subTableColumns;
|
|
11893
|
+
const [activeTab, setActiveTab] = (0, import_react24.useState)((_a = tabColumns[0]) == null ? void 0 : _a.name);
|
|
11894
|
+
if (tabColumns.length === 0) return null;
|
|
11895
|
+
if (tabColumns.length === 1) {
|
|
11896
|
+
const stCol = tabColumns[0];
|
|
11866
11897
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { colSpan: filteredColumnsLength + 2, className: "p-0 border-b border-slate-200 bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
11867
11898
|
SubTableViewer,
|
|
11868
11899
|
{
|
|
@@ -11874,9 +11905,9 @@ function ExpandedSubTables({
|
|
|
11874
11905
|
}
|
|
11875
11906
|
) }) });
|
|
11876
11907
|
}
|
|
11877
|
-
const activeCol =
|
|
11908
|
+
const activeCol = tabColumns.find((c) => c.name === activeTab) || tabColumns[0];
|
|
11878
11909
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("td", { colSpan: filteredColumnsLength + 2, className: "p-0 border-b border-slate-200 bg-slate-50/50 overflow-hidden", children: [
|
|
11879
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex border-b border-slate-200 bg-slate-100/50 px-2 pt-2 gap-1 overflow-hidden", children:
|
|
11910
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex border-b border-slate-200 bg-slate-100/50 px-2 pt-2 gap-1 overflow-hidden", children: tabColumns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
11880
11911
|
"button",
|
|
11881
11912
|
{
|
|
11882
11913
|
type: "button",
|
|
@@ -11920,6 +11951,7 @@ var TableRow = import_react24.default.memo(function TableRow2({
|
|
|
11920
11951
|
handleUpdateColumnConfig,
|
|
11921
11952
|
onMarkForDeletion,
|
|
11922
11953
|
triggerSaveSuccess,
|
|
11954
|
+
refreshRows,
|
|
11923
11955
|
schema,
|
|
11924
11956
|
orgId,
|
|
11925
11957
|
componentId,
|
|
@@ -12098,6 +12130,7 @@ var TableRow = import_react24.default.memo(function TableRow2({
|
|
|
12098
12130
|
rowData: row.data,
|
|
12099
12131
|
updateQuietly: handleQuietCellChange,
|
|
12100
12132
|
triggerSaveSuccess,
|
|
12133
|
+
refreshRows,
|
|
12101
12134
|
onUpdateColumnConfig: handleUpdateColumnConfig,
|
|
12102
12135
|
readOnly,
|
|
12103
12136
|
permissions,
|
package/dist/index.mjs
CHANGED
|
@@ -5925,16 +5925,31 @@ function SubTableCell({
|
|
|
5925
5925
|
);
|
|
5926
5926
|
}
|
|
5927
5927
|
function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
5928
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5928
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5929
5929
|
const isReadOnly = readOnly != null ? readOnly : Boolean(context == null ? void 0 : context.readOnly);
|
|
5930
5930
|
const { addToast } = useToast();
|
|
5931
5931
|
const entries = Array.isArray(value) ? value : [];
|
|
5932
|
+
const linkedRepField = (_b = (_a = column.config) == null ? void 0 : _a.linkConfig) == null ? void 0 : _b.repField;
|
|
5933
|
+
const linkedRepValue = linkedRepField ? (_c = context == null ? void 0 : context.rowData) == null ? void 0 : _c[linkedRepField] : void 0;
|
|
5934
|
+
const repIndicatorField = (_e = (_d = column.config) == null ? void 0 : _d.linkConfig) == null ? void 0 : _e.repIndicatorField;
|
|
5935
|
+
const isRepEligible = (recordId) => {
|
|
5936
|
+
var _a2, _b2;
|
|
5937
|
+
if (!linkedRepField || !repIndicatorField) return true;
|
|
5938
|
+
const rec = linkedRecords.find((r) => r.id === recordId);
|
|
5939
|
+
const entry = entries.find((e) => e.recordId === recordId);
|
|
5940
|
+
const v = (_b2 = (_a2 = rec == null ? void 0 : rec.data) != null ? _a2 : entry == null ? void 0 : entry._resolvedData) == null ? void 0 : _b2[repIndicatorField];
|
|
5941
|
+
return v === true || v === "true" || v === "TRUE" || v === "\u05DB\u05DF";
|
|
5942
|
+
};
|
|
5932
5943
|
const effectivePrimaryRecordId = useMemo5(() => {
|
|
5944
|
+
if (Array.isArray(linkedRepValue)) {
|
|
5945
|
+
const repEntry = linkedRepValue.find((e) => e && typeof e === "object" && e.isSelected !== false && e.recordId);
|
|
5946
|
+
if (repEntry && entries.some((e) => e.isSelected && e.recordId === repEntry.recordId)) return repEntry.recordId;
|
|
5947
|
+
}
|
|
5933
5948
|
const explicit = entries.find((e) => e.isSelected && e.isPrimary);
|
|
5934
5949
|
if (explicit) return explicit.recordId;
|
|
5935
5950
|
const fallback = entries.find((e) => e.isSelected);
|
|
5936
5951
|
return fallback ? fallback.recordId : null;
|
|
5937
|
-
}, [entries]);
|
|
5952
|
+
}, [entries, linkedRepValue]);
|
|
5938
5953
|
const [linkedRecords, setLinkedRecords] = useState12(() => {
|
|
5939
5954
|
const initial = [];
|
|
5940
5955
|
for (const entry of entries) {
|
|
@@ -5960,7 +5975,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
5960
5975
|
const searchRef = useRef9(null);
|
|
5961
5976
|
const searchTimerRef = useRef9(null);
|
|
5962
5977
|
const executeAction = context == null ? void 0 : context.executeAction;
|
|
5963
|
-
const referencedTableId = ((
|
|
5978
|
+
const referencedTableId = ((_f = column.config) == null ? void 0 : _f.referencedTableId) || column.referencedTableId;
|
|
5964
5979
|
const fetchedIdsRef = useRef9(/* @__PURE__ */ new Set());
|
|
5965
5980
|
useEffect10(() => {
|
|
5966
5981
|
if (entries.length > 0) {
|
|
@@ -6042,7 +6057,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6042
6057
|
const [localColumnOrder, setLocalColumnOrder] = useState12(null);
|
|
6043
6058
|
useEffect10(() => {
|
|
6044
6059
|
setLocalColumnOrder(null);
|
|
6045
|
-
}, [column.name, (
|
|
6060
|
+
}, [column.name, (_g = column.config) == null ? void 0 : _g.subTableColumnOrder]);
|
|
6046
6061
|
const rawTargetColumns = useMemo5(() => {
|
|
6047
6062
|
return ((targetSchema == null ? void 0 : targetSchema.columns) || []).filter(
|
|
6048
6063
|
(c) => c.name !== "_id" && c.type !== "SUB_TABLE"
|
|
@@ -6064,7 +6079,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6064
6079
|
return idxA - idxB;
|
|
6065
6080
|
});
|
|
6066
6081
|
return sorted;
|
|
6067
|
-
}, [rawTargetColumns, localColumnOrder, (
|
|
6082
|
+
}, [rawTargetColumns, localColumnOrder, (_h = column.config) == null ? void 0 : _h.subTableColumnOrder]);
|
|
6068
6083
|
const handleSubTableColumnReorder = async (draggedName, dropTargetName) => {
|
|
6069
6084
|
if (draggedName === dropTargetName) return;
|
|
6070
6085
|
const currentNames = targetColumns.map((c) => c.name);
|
|
@@ -6153,6 +6168,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6153
6168
|
return [];
|
|
6154
6169
|
}, [targetColumns, executeAction]);
|
|
6155
6170
|
const updateParentLinkage = async (updated) => {
|
|
6171
|
+
var _a2;
|
|
6156
6172
|
const isNewRow = rowId.startsWith("temp_");
|
|
6157
6173
|
if (context == null ? void 0 : context.updateQuietly) {
|
|
6158
6174
|
context.updateQuietly(rowId, column.name, updated);
|
|
@@ -6174,6 +6190,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6174
6190
|
if (context == null ? void 0 : context.triggerSaveSuccess) {
|
|
6175
6191
|
context.triggerSaveSuccess();
|
|
6176
6192
|
}
|
|
6193
|
+
(_a2 = context == null ? void 0 : context.refreshRows) == null ? void 0 : _a2.call(context);
|
|
6177
6194
|
} catch (err) {
|
|
6178
6195
|
console.error("Failed to auto-save parent linkage", err);
|
|
6179
6196
|
}
|
|
@@ -6301,6 +6318,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6301
6318
|
if (isReadOnly) return;
|
|
6302
6319
|
const target = entries.find((e) => e.recordId === recordId);
|
|
6303
6320
|
if (!target || !target.isSelected) return;
|
|
6321
|
+
if (!isRepEligible(recordId)) return;
|
|
6304
6322
|
const updated = entries.map((e) => {
|
|
6305
6323
|
const record = linkedRecords.find((r) => r.id === e.recordId);
|
|
6306
6324
|
if (e.recordId === recordId) {
|
|
@@ -6314,6 +6332,9 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6314
6332
|
_resolvedData: (record == null ? void 0 : record.data) || e._resolvedData
|
|
6315
6333
|
});
|
|
6316
6334
|
});
|
|
6335
|
+
if (linkedRepField && (context == null ? void 0 : context.updateQuietly)) {
|
|
6336
|
+
context.updateQuietly(rowId, linkedRepField, [{ recordId, isSelected: true, isPrimary: true }]);
|
|
6337
|
+
}
|
|
6317
6338
|
updateParentLinkage(updated);
|
|
6318
6339
|
};
|
|
6319
6340
|
const isMountedRef = useRef9(true);
|
|
@@ -6324,7 +6345,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6324
6345
|
};
|
|
6325
6346
|
}, []);
|
|
6326
6347
|
const handleCommitRecordCell = async (recordId, colName, value2) => {
|
|
6327
|
-
var _a2;
|
|
6348
|
+
var _a2, _b2;
|
|
6328
6349
|
const previousRecord = linkedRecords.find((r) => r.id === recordId);
|
|
6329
6350
|
const previousValue = (_a2 = previousRecord == null ? void 0 : previousRecord.data) == null ? void 0 : _a2[colName];
|
|
6330
6351
|
if (previousValue === value2) return true;
|
|
@@ -6368,6 +6389,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6368
6389
|
if (context == null ? void 0 : context.triggerSaveSuccess) {
|
|
6369
6390
|
context.triggerSaveSuccess();
|
|
6370
6391
|
}
|
|
6392
|
+
(_b2 = context == null ? void 0 : context.refreshRows) == null ? void 0 : _b2.call(context);
|
|
6371
6393
|
}
|
|
6372
6394
|
return true;
|
|
6373
6395
|
} catch (err) {
|
|
@@ -6500,7 +6522,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6500
6522
|
};
|
|
6501
6523
|
return /* @__PURE__ */ jsxs11("div", { className: "p-3 animate-in fade-in slide-in-from-top-2 duration-200", dir: "rtl", children: [
|
|
6502
6524
|
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-4 mb-2.5", children: [
|
|
6503
|
-
/* @__PURE__ */ jsx13("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx13("span", { className: "text-xs font-bold text-slate-600", children: (
|
|
6525
|
+
/* @__PURE__ */ jsx13("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx13("span", { className: "text-xs font-bold text-slate-600", children: (_j = targetSchema == null ? void 0 : targetSchema.name) != null ? _j : (_i = column.config) == null ? void 0 : _i.referencedTableName }) }),
|
|
6504
6526
|
!isReadOnly && /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1.5", children: [
|
|
6505
6527
|
/* @__PURE__ */ jsxs11("div", { className: "relative", ref: searchRef, children: [
|
|
6506
6528
|
/* @__PURE__ */ jsxs11(
|
|
@@ -6690,10 +6712,10 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6690
6712
|
"button",
|
|
6691
6713
|
{
|
|
6692
6714
|
type: "button",
|
|
6693
|
-
disabled: isReadOnly || !entry.isSelected,
|
|
6715
|
+
disabled: isReadOnly || !entry.isSelected || !isRepEligible(entry.recordId),
|
|
6694
6716
|
onClick: () => handleTogglePrimary(entry.recordId),
|
|
6695
|
-
title: !entry.isSelected ? "\u05D9\u05E9 \u05DC\u05E1\u05DE\u05DF \u05D0\u05EA \u05D4\u05E8\u05E9\u05D5\u05DE\u05D4 \u05DB\u05D3\u05D9 \u05DC\u05D4\u05D2\u05D3\u05D9\u05E8\u05D4 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : entry.recordId === effectivePrimaryRecordId ? "\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : "\u05D4\u05D2\u05D3\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9",
|
|
6696
|
-
className: `p-0.5 rounded transition-all inline-flex items-center justify-center ${entry.recordId === effectivePrimaryRecordId ? "text-amber-500 hover:text-amber-600 scale-110" : "text-slate-300 hover:text-amber-400 hover:scale-105"} ${isReadOnly || !entry.isSelected ? "opacity-25 cursor-not-allowed" : "cursor-pointer"}`,
|
|
6717
|
+
title: !entry.isSelected ? "\u05D9\u05E9 \u05DC\u05E1\u05DE\u05DF \u05D0\u05EA \u05D4\u05E8\u05E9\u05D5\u05DE\u05D4 \u05DB\u05D3\u05D9 \u05DC\u05D4\u05D2\u05D3\u05D9\u05E8\u05D4 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : !isRepEligible(entry.recordId) ? "\u05DB\u05D3\u05D9 \u05DC\u05D1\u05D7\u05D5\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05DE\u05D5\u05E2\u05D3\u05E3, \u05E1\u05DE\u05DF \u05E7\u05D5\u05D3\u05DD '\u05D4\u05D0\u05DD \u05E0\u05E6\u05D9\u05D2'" : entry.recordId === effectivePrimaryRecordId ? "\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9" : "\u05D4\u05D2\u05D3\u05E8 \u05DB\u05E0\u05E6\u05D9\u05D2 \u05E8\u05D0\u05E9\u05D9",
|
|
6718
|
+
className: `p-0.5 rounded transition-all inline-flex items-center justify-center ${entry.recordId === effectivePrimaryRecordId ? "text-amber-500 hover:text-amber-600 scale-110" : "text-slate-300 hover:text-amber-400 hover:scale-105"} ${isReadOnly || !entry.isSelected || !isRepEligible(entry.recordId) ? "opacity-25 cursor-not-allowed" : "cursor-pointer"}`,
|
|
6697
6719
|
children: /* @__PURE__ */ jsx13(
|
|
6698
6720
|
Star,
|
|
6699
6721
|
{
|
|
@@ -6853,7 +6875,7 @@ function SubTableViewer({ rowId, column, value, onChange, context, readOnly }) {
|
|
|
6853
6875
|
" \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05E7\u05D9\u05D9\u05DE\u05D5\u05EA. \u05D4\u05D0\u05DD \u05DC\u05E7\u05E9\u05E8 \u05D0\u05EA \u05DB\u05D5\u05DC\u05DF?"
|
|
6854
6876
|
] }),
|
|
6855
6877
|
conflictModalState.matchingRecords.length > 0 && /* @__PURE__ */ jsx13("div", { className: "overflow-x-auto border border-slate-200 rounded-lg max-h-48 text-xs bg-white", children: /* @__PURE__ */ jsxs11("table", { className: "w-full text-right border-collapse", children: [
|
|
6856
|
-
/* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsx13("tr", { className: "bg-slate-100 text-slate-700 font-semibold border-b whitespace-nowrap", children: (targetColumns.length > 0 ? targetColumns.filter((c) => c.name !== "_id" && c.name !== "id") : Object.keys(((
|
|
6878
|
+
/* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsx13("tr", { className: "bg-slate-100 text-slate-700 font-semibold border-b whitespace-nowrap", children: (targetColumns.length > 0 ? targetColumns.filter((c) => c.name !== "_id" && c.name !== "id") : Object.keys(((_k = conflictModalState.matchingRecords[0]) == null ? void 0 : _k.data) || {}).filter((k) => k !== "_id" && k !== "id").map((name) => ({ name }))).map((col) => /* @__PURE__ */ jsx13(
|
|
6857
6879
|
"th",
|
|
6858
6880
|
{
|
|
6859
6881
|
className: "bg-slate-100 text-slate-700 font-semibold p-2 border-b whitespace-nowrap",
|
|
@@ -11465,6 +11487,7 @@ function TableBlockClient({
|
|
|
11465
11487
|
handleUpdateColumnConfig,
|
|
11466
11488
|
onMarkForDeletion: handleMarkForDeletion,
|
|
11467
11489
|
triggerSaveSuccess,
|
|
11490
|
+
refreshRows: refetchTableData,
|
|
11468
11491
|
schema,
|
|
11469
11492
|
orgId,
|
|
11470
11493
|
componentId,
|
|
@@ -11660,10 +11683,18 @@ function ExpandedSubTables({
|
|
|
11660
11683
|
context
|
|
11661
11684
|
}) {
|
|
11662
11685
|
var _a;
|
|
11663
|
-
const
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11686
|
+
const repMirrorNames = new Set(
|
|
11687
|
+
subTableColumns.map((c) => {
|
|
11688
|
+
var _a2, _b;
|
|
11689
|
+
return (_b = (_a2 = c == null ? void 0 : c.config) == null ? void 0 : _a2.linkConfig) == null ? void 0 : _b.repField;
|
|
11690
|
+
}).filter((n) => typeof n === "string" && n.length > 0)
|
|
11691
|
+
);
|
|
11692
|
+
const visibleColumns = subTableColumns.filter((c) => !repMirrorNames.has(c.name));
|
|
11693
|
+
const tabColumns = visibleColumns.length > 0 ? visibleColumns : subTableColumns;
|
|
11694
|
+
const [activeTab, setActiveTab] = useState20((_a = tabColumns[0]) == null ? void 0 : _a.name);
|
|
11695
|
+
if (tabColumns.length === 0) return null;
|
|
11696
|
+
if (tabColumns.length === 1) {
|
|
11697
|
+
const stCol = tabColumns[0];
|
|
11667
11698
|
return /* @__PURE__ */ jsx21("tr", { children: /* @__PURE__ */ jsx21("td", { colSpan: filteredColumnsLength + 2, className: "p-0 border-b border-slate-200 bg-slate-50/50", children: /* @__PURE__ */ jsx21(
|
|
11668
11699
|
SubTableViewer,
|
|
11669
11700
|
{
|
|
@@ -11675,9 +11706,9 @@ function ExpandedSubTables({
|
|
|
11675
11706
|
}
|
|
11676
11707
|
) }) });
|
|
11677
11708
|
}
|
|
11678
|
-
const activeCol =
|
|
11709
|
+
const activeCol = tabColumns.find((c) => c.name === activeTab) || tabColumns[0];
|
|
11679
11710
|
return /* @__PURE__ */ jsx21("tr", { children: /* @__PURE__ */ jsxs17("td", { colSpan: filteredColumnsLength + 2, className: "p-0 border-b border-slate-200 bg-slate-50/50 overflow-hidden", children: [
|
|
11680
|
-
/* @__PURE__ */ jsx21("div", { className: "flex border-b border-slate-200 bg-slate-100/50 px-2 pt-2 gap-1 overflow-hidden", children:
|
|
11711
|
+
/* @__PURE__ */ jsx21("div", { className: "flex border-b border-slate-200 bg-slate-100/50 px-2 pt-2 gap-1 overflow-hidden", children: tabColumns.map((col) => /* @__PURE__ */ jsx21(
|
|
11681
11712
|
"button",
|
|
11682
11713
|
{
|
|
11683
11714
|
type: "button",
|
|
@@ -11721,6 +11752,7 @@ var TableRow = React19.memo(function TableRow2({
|
|
|
11721
11752
|
handleUpdateColumnConfig,
|
|
11722
11753
|
onMarkForDeletion,
|
|
11723
11754
|
triggerSaveSuccess,
|
|
11755
|
+
refreshRows,
|
|
11724
11756
|
schema,
|
|
11725
11757
|
orgId,
|
|
11726
11758
|
componentId,
|
|
@@ -11899,6 +11931,7 @@ var TableRow = React19.memo(function TableRow2({
|
|
|
11899
11931
|
rowData: row.data,
|
|
11900
11932
|
updateQuietly: handleQuietCellChange,
|
|
11901
11933
|
triggerSaveSuccess,
|
|
11934
|
+
refreshRows,
|
|
11902
11935
|
onUpdateColumnConfig: handleUpdateColumnConfig,
|
|
11903
11936
|
readOnly,
|
|
11904
11937
|
permissions,
|