@universe-platform/ui 0.1.0-beta.20 → 0.1.0-beta.21
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 +3 -0
- package/dist/index.d.mts +246 -1
- package/dist/index.d.ts +246 -1
- package/dist/index.js +358 -31
- package/dist/index.mjs +356 -32
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5591,7 +5591,9 @@ function TableBlockClient({
|
|
|
5591
5591
|
role,
|
|
5592
5592
|
permissions,
|
|
5593
5593
|
readOnly,
|
|
5594
|
+
selectedRowIds,
|
|
5594
5595
|
onSelectionChange,
|
|
5596
|
+
onRowToggle,
|
|
5595
5597
|
rowStatusMap,
|
|
5596
5598
|
editModelUrl
|
|
5597
5599
|
}) {
|
|
@@ -6035,12 +6037,29 @@ function TableBlockClient({
|
|
|
6035
6037
|
setPage((prev) => Math.min(totalPages, prev + 1));
|
|
6036
6038
|
};
|
|
6037
6039
|
const [selectedIds, setSelectedIds] = useState13(/* @__PURE__ */ new Set());
|
|
6040
|
+
const isExternalSyncRef = useRef10(false);
|
|
6041
|
+
useEffect11(() => {
|
|
6042
|
+
if (selectedRowIds !== void 0) {
|
|
6043
|
+
const nextSet = new Set(selectedRowIds);
|
|
6044
|
+
setSelectedIds((prev) => {
|
|
6045
|
+
if (prev.size === nextSet.size && Array.from(prev).every((id) => nextSet.has(id))) {
|
|
6046
|
+
return prev;
|
|
6047
|
+
}
|
|
6048
|
+
isExternalSyncRef.current = true;
|
|
6049
|
+
return nextSet;
|
|
6050
|
+
});
|
|
6051
|
+
}
|
|
6052
|
+
}, [selectedRowIds]);
|
|
6038
6053
|
const isFirstSelectionChangeRef = useRef10(true);
|
|
6039
6054
|
useEffect11(() => {
|
|
6040
6055
|
if (isFirstSelectionChangeRef.current) {
|
|
6041
6056
|
isFirstSelectionChangeRef.current = false;
|
|
6042
6057
|
if (selectedIds.size === 0) return;
|
|
6043
6058
|
}
|
|
6059
|
+
if (isExternalSyncRef.current) {
|
|
6060
|
+
isExternalSyncRef.current = false;
|
|
6061
|
+
return;
|
|
6062
|
+
}
|
|
6044
6063
|
onSelectionChange == null ? void 0 : onSelectionChange(Array.from(selectedIds));
|
|
6045
6064
|
}, [selectedIds, onSelectionChange]);
|
|
6046
6065
|
const [pendingDeletions, setPendingDeletions] = useState13([]);
|
|
@@ -6489,17 +6508,19 @@ function TableBlockClient({
|
|
|
6489
6508
|
}
|
|
6490
6509
|
}, []);
|
|
6491
6510
|
const toggleSelectAll = useCallback11((checked) => {
|
|
6511
|
+
onRowToggle == null ? void 0 : onRowToggle("ALL", checked);
|
|
6492
6512
|
const next = checked ? new Set(filteredData.map((r) => r.id)) : /* @__PURE__ */ new Set();
|
|
6493
6513
|
setSelectedIds(next);
|
|
6494
|
-
}, [filteredData]);
|
|
6514
|
+
}, [filteredData, onRowToggle]);
|
|
6495
6515
|
const toggleSelectRow = useCallback11((rowId, checked) => {
|
|
6516
|
+
onRowToggle == null ? void 0 : onRowToggle(rowId, checked);
|
|
6496
6517
|
setSelectedIds((prev) => {
|
|
6497
6518
|
const next = new Set(prev);
|
|
6498
6519
|
if (checked) next.add(rowId);
|
|
6499
6520
|
else next.delete(rowId);
|
|
6500
6521
|
return next;
|
|
6501
6522
|
});
|
|
6502
|
-
}, []);
|
|
6523
|
+
}, [onRowToggle]);
|
|
6503
6524
|
const handleToggleExpand = useCallback11((rowId) => {
|
|
6504
6525
|
setExpandedRowIds((prev) => {
|
|
6505
6526
|
const next = new Set(prev);
|
|
@@ -10228,7 +10249,12 @@ function useWhatsAppState(props) {
|
|
|
10228
10249
|
const [tableError, setTableError] = useState15(null);
|
|
10229
10250
|
const [filters, setFilters] = useState15({});
|
|
10230
10251
|
const [selectedRowIds, setSelectedRowIds] = useState15([]);
|
|
10252
|
+
const [autoSelectCount, setAutoSelectCount] = useState15(null);
|
|
10253
|
+
const isAutoSelectingRef = useRef12(false);
|
|
10254
|
+
const isManualOverrideRef = useRef12(false);
|
|
10255
|
+
const prevAutoSelectCountRef = useRef12(null);
|
|
10231
10256
|
const fetchedTableIdsRef = useRef12(/* @__PURE__ */ new Set());
|
|
10257
|
+
const fullyFetchedRelationKeysRef = useRef12(/* @__PURE__ */ new Set());
|
|
10232
10258
|
const loadTableData = useCallback12(async () => {
|
|
10233
10259
|
var _a2;
|
|
10234
10260
|
const tableId = (settings == null ? void 0 : settings.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableId);
|
|
@@ -10253,7 +10279,34 @@ function useWhatsAppState(props) {
|
|
|
10253
10279
|
setRawRecords(res.records);
|
|
10254
10280
|
}
|
|
10255
10281
|
if (res.relationOptions && typeof res.relationOptions === "object") {
|
|
10256
|
-
setRelationOptions((prev) =>
|
|
10282
|
+
setRelationOptions((prev) => {
|
|
10283
|
+
const merged = __spreadValues({}, prev);
|
|
10284
|
+
Object.entries(res.relationOptions).forEach(([k, opts]) => {
|
|
10285
|
+
if (Array.isArray(opts)) {
|
|
10286
|
+
const existing = prev[k] || [];
|
|
10287
|
+
if (existing.length >= opts.length && existing.length > 0) {
|
|
10288
|
+
const existingMap = new Map(existing.map((o) => [String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id)), o]));
|
|
10289
|
+
opts.forEach((o) => {
|
|
10290
|
+
const id = String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id));
|
|
10291
|
+
if (id && !existingMap.has(id)) {
|
|
10292
|
+
existingMap.set(id, o);
|
|
10293
|
+
}
|
|
10294
|
+
});
|
|
10295
|
+
merged[k] = Array.from(existingMap.values());
|
|
10296
|
+
} else {
|
|
10297
|
+
const map = new Map(opts.map((o) => [String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id)), o]));
|
|
10298
|
+
existing.forEach((o) => {
|
|
10299
|
+
const id = String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id));
|
|
10300
|
+
if (id && !map.has(id)) {
|
|
10301
|
+
map.set(id, o);
|
|
10302
|
+
}
|
|
10303
|
+
});
|
|
10304
|
+
merged[k] = Array.from(map.values());
|
|
10305
|
+
}
|
|
10306
|
+
}
|
|
10307
|
+
});
|
|
10308
|
+
return merged;
|
|
10309
|
+
});
|
|
10257
10310
|
}
|
|
10258
10311
|
}
|
|
10259
10312
|
} catch (err) {
|
|
@@ -10481,7 +10534,7 @@ function useWhatsAppState(props) {
|
|
|
10481
10534
|
}, []);
|
|
10482
10535
|
const getRelationOptionsForCol = useCallback12(
|
|
10483
10536
|
(colName, parentColName) => {
|
|
10484
|
-
var _a2;
|
|
10537
|
+
var _a2, _b2, _c, _d;
|
|
10485
10538
|
if (parentColName) {
|
|
10486
10539
|
const subKey = `${parentColName}.${colName}`;
|
|
10487
10540
|
if (relationOptions[subKey] && relationOptions[subKey].length > 0) {
|
|
@@ -10496,20 +10549,55 @@ function useWhatsAppState(props) {
|
|
|
10496
10549
|
if (refId && relationOptions[refId] && relationOptions[refId].length > 0) {
|
|
10497
10550
|
return relationOptions[refId];
|
|
10498
10551
|
}
|
|
10552
|
+
const postSendCol = postSendActionTargetOptions.find(
|
|
10553
|
+
(c) => c.columnName === colName && (!parentColName || c.parentColumnName === parentColName) || c.id === colName
|
|
10554
|
+
);
|
|
10555
|
+
if (postSendCol) {
|
|
10556
|
+
if (postSendCol.id && relationOptions[postSendCol.id] && relationOptions[postSendCol.id].length > 0) {
|
|
10557
|
+
return relationOptions[postSendCol.id];
|
|
10558
|
+
}
|
|
10559
|
+
const postSendRefId = postSendCol.referencedTableId || ((_b2 = postSendCol.config) == null ? void 0 : _b2.referencedTableId);
|
|
10560
|
+
if (postSendRefId && relationOptions[postSendRefId] && relationOptions[postSendRefId].length > 0) {
|
|
10561
|
+
return relationOptions[postSendRefId];
|
|
10562
|
+
}
|
|
10563
|
+
}
|
|
10564
|
+
const mainCol = (tableColumns || []).find((c) => c.name === colName);
|
|
10565
|
+
const mainRefId = ((_c = mainCol == null ? void 0 : mainCol.config) == null ? void 0 : _c.referencedTableId) || (mainCol == null ? void 0 : mainCol.referencedTableId);
|
|
10566
|
+
if (mainRefId && relationOptions[mainRefId] && relationOptions[mainRefId].length > 0) {
|
|
10567
|
+
return relationOptions[mainRefId];
|
|
10568
|
+
}
|
|
10569
|
+
const filterCol = filterableColumns.find((c) => c.name === colName);
|
|
10570
|
+
const filterRefId = ((_d = filterCol == null ? void 0 : filterCol.config) == null ? void 0 : _d.referencedTableId) || (filterCol == null ? void 0 : filterCol.referencedTableId);
|
|
10571
|
+
if (filterRefId && relationOptions[filterRefId] && relationOptions[filterRefId].length > 0) {
|
|
10572
|
+
return relationOptions[filterRefId];
|
|
10573
|
+
}
|
|
10499
10574
|
return [];
|
|
10500
10575
|
},
|
|
10501
|
-
[relationOptions, subtableFilterableColumns]
|
|
10576
|
+
[relationOptions, subtableFilterableColumns, postSendActionTargetOptions, tableColumns, filterableColumns]
|
|
10502
10577
|
);
|
|
10503
10578
|
useEffect13(() => {
|
|
10504
|
-
var _a2, _b2, _c;
|
|
10579
|
+
var _a2, _b2, _c, _d, _e;
|
|
10505
10580
|
if (!executeAction) return;
|
|
10506
10581
|
const targets = [];
|
|
10582
|
+
(tableColumns || []).forEach((col) => {
|
|
10583
|
+
var _a3, _b3, _c2;
|
|
10584
|
+
if (((_a3 = col.type) == null ? void 0 : _a3.toUpperCase()) === "RELATION") {
|
|
10585
|
+
const refId = ((_b3 = col.config) == null ? void 0 : _b3.referencedTableId) || col.referencedTableId;
|
|
10586
|
+
const displayField = ((_c2 = col.config) == null ? void 0 : _c2.displayField) || col.displayField;
|
|
10587
|
+
if (refId) {
|
|
10588
|
+
targets.push({ key: col.name, refId, displayField, colName: col.name, extraKey: col.id });
|
|
10589
|
+
targets.push({ key: refId, refId, displayField, colName: col.name, extraKey: col.id });
|
|
10590
|
+
}
|
|
10591
|
+
}
|
|
10592
|
+
});
|
|
10507
10593
|
filterableColumns.forEach((col) => {
|
|
10508
10594
|
var _a3, _b3, _c2;
|
|
10509
10595
|
if (((_a3 = col.type) == null ? void 0 : _a3.toUpperCase()) === "RELATION") {
|
|
10510
10596
|
const refId = ((_b3 = col.config) == null ? void 0 : _b3.referencedTableId) || col.referencedTableId;
|
|
10511
10597
|
const displayField = ((_c2 = col.config) == null ? void 0 : _c2.displayField) || col.displayField;
|
|
10512
|
-
if (refId)
|
|
10598
|
+
if (refId) {
|
|
10599
|
+
targets.push({ key: col.name, refId, displayField, colName: col.name, extraKey: col.id });
|
|
10600
|
+
}
|
|
10513
10601
|
}
|
|
10514
10602
|
});
|
|
10515
10603
|
if ((selectedPhoneOption == null ? void 0 : selectedPhoneOption.type) === "SUBTABLE") {
|
|
@@ -10525,35 +10613,64 @@ function useWhatsAppState(props) {
|
|
|
10525
10613
|
const refId = ((_b3 = subCol.config) == null ? void 0 : _b3.referencedTableId) || subCol.referencedTableId;
|
|
10526
10614
|
const displayField = ((_c2 = subCol.config) == null ? void 0 : _c2.displayField) || subCol.displayField;
|
|
10527
10615
|
if (refId) {
|
|
10528
|
-
targets.push({ key: `${parentColName}.${subCol.name}`, refId, displayField });
|
|
10529
|
-
targets.push({ key: subCol.name, refId, displayField });
|
|
10530
|
-
targets.push({ key: refId, refId, displayField });
|
|
10616
|
+
targets.push({ key: `${parentColName}.${subCol.name}`, refId, displayField, colName: subCol.name });
|
|
10617
|
+
targets.push({ key: subCol.name, refId, displayField, colName: subCol.name });
|
|
10618
|
+
targets.push({ key: refId, refId, displayField, colName: subCol.name });
|
|
10531
10619
|
}
|
|
10532
10620
|
}
|
|
10533
10621
|
});
|
|
10534
10622
|
}
|
|
10623
|
+
if (selectedPostSendOption && selectedPostSendOption.type === "RELATION") {
|
|
10624
|
+
const postSendRefId = selectedPostSendOption.referencedTableId || ((_d = selectedPostSendOption.config) == null ? void 0 : _d.referencedTableId);
|
|
10625
|
+
const postSendDisplayField = ((_e = selectedPostSendOption.config) == null ? void 0 : _e.displayField) || (selectedPostSendOption == null ? void 0 : selectedPostSendOption.displayField);
|
|
10626
|
+
if (postSendRefId) {
|
|
10627
|
+
const parentCol = selectedPostSendOption.parentColumnName;
|
|
10628
|
+
if (parentCol) {
|
|
10629
|
+
targets.push({ key: `${parentCol}.${selectedPostSendOption.columnName}`, refId: postSendRefId, displayField: postSendDisplayField, colName: selectedPostSendOption.columnName, extraKey: selectedPostSendOption.id });
|
|
10630
|
+
}
|
|
10631
|
+
targets.push({ key: selectedPostSendOption.columnName, refId: postSendRefId, displayField: postSendDisplayField, colName: selectedPostSendOption.columnName, extraKey: selectedPostSendOption.id });
|
|
10632
|
+
targets.push({ key: postSendRefId, refId: postSendRefId, displayField: postSendDisplayField, colName: selectedPostSendOption.columnName });
|
|
10633
|
+
}
|
|
10634
|
+
}
|
|
10535
10635
|
targets.forEach(async (target) => {
|
|
10536
|
-
if (
|
|
10636
|
+
if (fullyFetchedRelationKeysRef.current.has(target.key)) return;
|
|
10537
10637
|
try {
|
|
10538
|
-
const result = await executeAction("FETCH_RELATION", {
|
|
10638
|
+
const result = await executeAction("FETCH_RELATION", __spreadValues({
|
|
10539
10639
|
referencedTableId: target.refId,
|
|
10540
10640
|
displayField: target.displayField,
|
|
10541
|
-
take: 1e3
|
|
10542
|
-
|
|
10641
|
+
take: 1e3,
|
|
10642
|
+
limit: 1e3,
|
|
10643
|
+
isFilter: false,
|
|
10644
|
+
bypassScoping: true,
|
|
10645
|
+
allOptions: true
|
|
10646
|
+
}, orgId ? { orgId, organizationId: orgId } : {}));
|
|
10543
10647
|
const list = Array.isArray(result) ? result : (result == null ? void 0 : result.data) && Array.isArray(result.data) ? result.data : [];
|
|
10544
10648
|
if (list.length > 0) {
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10649
|
+
fullyFetchedRelationKeysRef.current.add(target.key);
|
|
10650
|
+
fullyFetchedRelationKeysRef.current.add(target.refId);
|
|
10651
|
+
if (target.colName) fullyFetchedRelationKeysRef.current.add(target.colName);
|
|
10652
|
+
if (target.extraKey) fullyFetchedRelationKeysRef.current.add(target.extraKey);
|
|
10653
|
+
setRelationOptions((prev) => {
|
|
10654
|
+
const existing = prev[target.key] || [];
|
|
10655
|
+
const existingMap = new Map(existing.map((o) => [String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id)), o]));
|
|
10656
|
+
list.forEach((o) => {
|
|
10657
|
+
const id = String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id));
|
|
10658
|
+
if (id) existingMap.set(id, o);
|
|
10659
|
+
});
|
|
10660
|
+
const mergedList = Array.from(existingMap.values());
|
|
10661
|
+
return __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, prev), {
|
|
10662
|
+
[target.key]: mergedList,
|
|
10663
|
+
[target.refId]: mergedList
|
|
10664
|
+
}), target.colName ? { [target.colName]: mergedList } : {}), target.extraKey ? { [target.extraKey]: mergedList } : {});
|
|
10665
|
+
});
|
|
10549
10666
|
}
|
|
10550
10667
|
} catch (err) {
|
|
10551
10668
|
console.warn(`[useWhatsAppState] Failed to fetch relation options for ${target.key}:`, err);
|
|
10552
10669
|
}
|
|
10553
10670
|
});
|
|
10554
|
-
}, [filterableColumns, selectedPhoneOption, referencedTableSchemas, tableColumns, executeAction,
|
|
10671
|
+
}, [filterableColumns, selectedPhoneOption, referencedTableSchemas, tableColumns, executeAction, selectedPostSendOption, orgId]);
|
|
10555
10672
|
useEffect13(() => {
|
|
10556
|
-
var _a2, _b2, _c
|
|
10673
|
+
var _a2, _b2, _c;
|
|
10557
10674
|
if (!executeAction || !selectedSubtableFilterCol) return;
|
|
10558
10675
|
if (((_a2 = selectedSubtableFilterCol.type) == null ? void 0 : _a2.toUpperCase()) !== "RELATION") return;
|
|
10559
10676
|
const refId = ((_b2 = selectedSubtableFilterCol.config) == null ? void 0 : _b2.referencedTableId) || selectedSubtableFilterCol.referencedTableId;
|
|
@@ -10561,24 +10678,39 @@ function useWhatsAppState(props) {
|
|
|
10561
10678
|
const parentColName = (selectedPhoneOption == null ? void 0 : selectedPhoneOption.parentColumnName) || "";
|
|
10562
10679
|
const keyWithParent = parentColName ? `${parentColName}.${selectedSubtableFilterCol.name}` : "";
|
|
10563
10680
|
const keyDirect = selectedSubtableFilterCol.name;
|
|
10564
|
-
if (keyWithParent && (
|
|
10681
|
+
if (keyWithParent && fullyFetchedRelationKeysRef.current.has(keyWithParent) || fullyFetchedRelationKeysRef.current.has(keyDirect) || fullyFetchedRelationKeysRef.current.has(refId)) {
|
|
10565
10682
|
return;
|
|
10566
10683
|
}
|
|
10567
|
-
const displayField = ((
|
|
10684
|
+
const displayField = ((_c = selectedSubtableFilterCol.config) == null ? void 0 : _c.displayField) || selectedSubtableFilterCol.displayField;
|
|
10568
10685
|
(async () => {
|
|
10569
10686
|
try {
|
|
10570
10687
|
const res = await executeAction("FETCH_RELATION", __spreadValues({
|
|
10571
10688
|
referencedTableId: refId,
|
|
10572
10689
|
displayField,
|
|
10573
10690
|
take: 1e3,
|
|
10574
|
-
limit: 1e3
|
|
10691
|
+
limit: 1e3,
|
|
10692
|
+
isFilter: false,
|
|
10693
|
+
bypassScoping: true,
|
|
10694
|
+
allOptions: true
|
|
10575
10695
|
}, orgId ? { orgId, organizationId: orgId } : {}));
|
|
10576
10696
|
const list = Array.isArray(res) ? res : (res == null ? void 0 : res.data) && Array.isArray(res.data) ? res.data : [];
|
|
10577
10697
|
if (list.length > 0) {
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10698
|
+
if (keyWithParent) fullyFetchedRelationKeysRef.current.add(keyWithParent);
|
|
10699
|
+
fullyFetchedRelationKeysRef.current.add(keyDirect);
|
|
10700
|
+
fullyFetchedRelationKeysRef.current.add(refId);
|
|
10701
|
+
setRelationOptions((prev) => {
|
|
10702
|
+
const existing = prev[keyDirect] || [];
|
|
10703
|
+
const existingMap = new Map(existing.map((o) => [String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id)), o]));
|
|
10704
|
+
list.forEach((o) => {
|
|
10705
|
+
const id = String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id));
|
|
10706
|
+
if (id) existingMap.set(id, o);
|
|
10707
|
+
});
|
|
10708
|
+
const mergedList = Array.from(existingMap.values());
|
|
10709
|
+
return __spreadProps(__spreadValues(__spreadValues({}, prev), keyWithParent ? { [keyWithParent]: mergedList } : {}), {
|
|
10710
|
+
[keyDirect]: mergedList,
|
|
10711
|
+
[refId]: mergedList
|
|
10712
|
+
});
|
|
10713
|
+
});
|
|
10582
10714
|
}
|
|
10583
10715
|
} catch (err) {
|
|
10584
10716
|
console.warn(
|
|
@@ -10587,7 +10719,60 @@ function useWhatsAppState(props) {
|
|
|
10587
10719
|
);
|
|
10588
10720
|
}
|
|
10589
10721
|
})();
|
|
10590
|
-
}, [selectedSubtableFilterCol, selectedPhoneOption, executeAction,
|
|
10722
|
+
}, [selectedSubtableFilterCol, selectedPhoneOption, executeAction, orgId]);
|
|
10723
|
+
useEffect13(() => {
|
|
10724
|
+
var _a2, _b2;
|
|
10725
|
+
if (!executeAction || !selectedPostSendOption) return;
|
|
10726
|
+
if (selectedPostSendOption.type !== "RELATION") return;
|
|
10727
|
+
const refId = selectedPostSendOption.referencedTableId || ((_a2 = selectedPostSendOption.config) == null ? void 0 : _a2.referencedTableId);
|
|
10728
|
+
if (!refId) return;
|
|
10729
|
+
const parentColName = selectedPostSendOption.parentColumnName || "";
|
|
10730
|
+
const keyWithParent = parentColName ? `${parentColName}.${selectedPostSendOption.columnName}` : "";
|
|
10731
|
+
const keyDirect = selectedPostSendOption.columnName;
|
|
10732
|
+
const optionId = selectedPostSendOption.id;
|
|
10733
|
+
if (keyWithParent && fullyFetchedRelationKeysRef.current.has(keyWithParent) || fullyFetchedRelationKeysRef.current.has(keyDirect) || fullyFetchedRelationKeysRef.current.has(refId) || optionId && fullyFetchedRelationKeysRef.current.has(optionId)) {
|
|
10734
|
+
return;
|
|
10735
|
+
}
|
|
10736
|
+
const displayField = ((_b2 = selectedPostSendOption.config) == null ? void 0 : _b2.displayField) || (selectedPostSendOption == null ? void 0 : selectedPostSendOption.displayField);
|
|
10737
|
+
(async () => {
|
|
10738
|
+
try {
|
|
10739
|
+
const res = await executeAction("FETCH_RELATION", __spreadValues({
|
|
10740
|
+
referencedTableId: refId,
|
|
10741
|
+
displayField,
|
|
10742
|
+
take: 1e3,
|
|
10743
|
+
limit: 1e3,
|
|
10744
|
+
isFilter: false,
|
|
10745
|
+
bypassScoping: true,
|
|
10746
|
+
allOptions: true
|
|
10747
|
+
}, orgId ? { orgId, organizationId: orgId } : {}));
|
|
10748
|
+
const list = Array.isArray(res) ? res : (res == null ? void 0 : res.data) && Array.isArray(res.data) ? res.data : [];
|
|
10749
|
+
if (list.length > 0) {
|
|
10750
|
+
if (keyWithParent) fullyFetchedRelationKeysRef.current.add(keyWithParent);
|
|
10751
|
+
fullyFetchedRelationKeysRef.current.add(keyDirect);
|
|
10752
|
+
fullyFetchedRelationKeysRef.current.add(refId);
|
|
10753
|
+
if (optionId) fullyFetchedRelationKeysRef.current.add(optionId);
|
|
10754
|
+
setRelationOptions((prev) => {
|
|
10755
|
+
const existing = prev[keyDirect] || [];
|
|
10756
|
+
const existingMap = new Map(existing.map((o) => [String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id)), o]));
|
|
10757
|
+
list.forEach((o) => {
|
|
10758
|
+
const id = String((o == null ? void 0 : o.id) || (o == null ? void 0 : o._id));
|
|
10759
|
+
if (id) existingMap.set(id, o);
|
|
10760
|
+
});
|
|
10761
|
+
const mergedList = Array.from(existingMap.values());
|
|
10762
|
+
return __spreadValues(__spreadProps(__spreadValues(__spreadValues({}, prev), keyWithParent ? { [keyWithParent]: mergedList } : {}), {
|
|
10763
|
+
[keyDirect]: mergedList,
|
|
10764
|
+
[refId]: mergedList
|
|
10765
|
+
}), optionId ? { [optionId]: mergedList } : {});
|
|
10766
|
+
});
|
|
10767
|
+
}
|
|
10768
|
+
} catch (err) {
|
|
10769
|
+
console.warn(
|
|
10770
|
+
`[useWhatsAppState] Failed to fetch relation options for post-send column ${selectedPostSendOption.columnName}:`,
|
|
10771
|
+
err
|
|
10772
|
+
);
|
|
10773
|
+
}
|
|
10774
|
+
})();
|
|
10775
|
+
}, [selectedPostSendOption, executeAction, orgId]);
|
|
10591
10776
|
const filteredRecords = useMemo8(() => {
|
|
10592
10777
|
const activeEntries = Object.entries(filters).filter(
|
|
10593
10778
|
([_, val]) => val !== void 0 && val !== null && val !== ""
|
|
@@ -10619,6 +10804,25 @@ function useWhatsAppState(props) {
|
|
|
10619
10804
|
return true;
|
|
10620
10805
|
});
|
|
10621
10806
|
}, [rawRecords, filters, filterableColumns]);
|
|
10807
|
+
const filteredData = filteredRecords;
|
|
10808
|
+
useEffect13(() => {
|
|
10809
|
+
if (autoSelectCount !== null && autoSelectCount > 0) {
|
|
10810
|
+
isAutoSelectingRef.current = true;
|
|
10811
|
+
const sliced = filteredData.slice(0, autoSelectCount);
|
|
10812
|
+
const slicedIds = sliced.map((r) => r.id);
|
|
10813
|
+
setSelectedRowIds(slicedIds);
|
|
10814
|
+
const timer = setTimeout(() => {
|
|
10815
|
+
isAutoSelectingRef.current = false;
|
|
10816
|
+
}, 0);
|
|
10817
|
+
return () => clearTimeout(timer);
|
|
10818
|
+
} else if (autoSelectCount === 0 || autoSelectCount === null) {
|
|
10819
|
+
if (!isManualOverrideRef.current && prevAutoSelectCountRef.current !== null) {
|
|
10820
|
+
setSelectedRowIds([]);
|
|
10821
|
+
}
|
|
10822
|
+
}
|
|
10823
|
+
isManualOverrideRef.current = false;
|
|
10824
|
+
prevAutoSelectCountRef.current = autoSelectCount;
|
|
10825
|
+
}, [autoSelectCount, filteredData]);
|
|
10622
10826
|
const embeddedTableExecuteAction = useCallback12(async (actionType, payload) => {
|
|
10623
10827
|
if (actionType === "FETCH_TABLE_DATA") {
|
|
10624
10828
|
const colFilters = (payload == null ? void 0 : payload.columnFilters) || (payload == null ? void 0 : payload.filters);
|
|
@@ -10640,6 +10844,15 @@ function useWhatsAppState(props) {
|
|
|
10640
10844
|
relationOptions
|
|
10641
10845
|
};
|
|
10642
10846
|
}
|
|
10847
|
+
if (actionType === "FETCH_RELATION") {
|
|
10848
|
+
if (executeAction) {
|
|
10849
|
+
return executeAction("FETCH_RELATION", __spreadProps(__spreadValues({}, payload), {
|
|
10850
|
+
isFilter: false,
|
|
10851
|
+
bypassScoping: true,
|
|
10852
|
+
allOptions: true
|
|
10853
|
+
}));
|
|
10854
|
+
}
|
|
10855
|
+
}
|
|
10643
10856
|
if (executeAction) {
|
|
10644
10857
|
return executeAction(actionType, payload);
|
|
10645
10858
|
}
|
|
@@ -10661,11 +10874,37 @@ function useWhatsAppState(props) {
|
|
|
10661
10874
|
if (prev.length === selectedIds.length && prev.every((id, idx) => id === selectedIds[idx])) {
|
|
10662
10875
|
return prev;
|
|
10663
10876
|
}
|
|
10877
|
+
if (!isAutoSelectingRef.current && autoSelectCount !== null && autoSelectCount > 0) {
|
|
10878
|
+
isManualOverrideRef.current = true;
|
|
10879
|
+
setAutoSelectCount(null);
|
|
10880
|
+
}
|
|
10664
10881
|
setBroadcastSummary(null);
|
|
10665
10882
|
setRowStatusMap({});
|
|
10666
10883
|
return selectedIds;
|
|
10667
10884
|
});
|
|
10668
|
-
}, []);
|
|
10885
|
+
}, [autoSelectCount]);
|
|
10886
|
+
const handleRowToggle = useCallback12((rowId, checked) => {
|
|
10887
|
+
if (autoSelectCount !== null && autoSelectCount > 0) {
|
|
10888
|
+
isManualOverrideRef.current = true;
|
|
10889
|
+
setAutoSelectCount(null);
|
|
10890
|
+
}
|
|
10891
|
+
}, [autoSelectCount]);
|
|
10892
|
+
const toggleRowSelection = useCallback12((rowId, checked) => {
|
|
10893
|
+
if (autoSelectCount !== null && autoSelectCount > 0) {
|
|
10894
|
+
isManualOverrideRef.current = true;
|
|
10895
|
+
setAutoSelectCount(null);
|
|
10896
|
+
}
|
|
10897
|
+
setSelectedRowIds((prev) => {
|
|
10898
|
+
const isSelected = prev.includes(rowId);
|
|
10899
|
+
const nextChecked = checked !== void 0 ? checked : !isSelected;
|
|
10900
|
+
if (nextChecked && !isSelected) {
|
|
10901
|
+
return [...prev, rowId];
|
|
10902
|
+
} else if (!nextChecked && isSelected) {
|
|
10903
|
+
return prev.filter((id) => id !== rowId);
|
|
10904
|
+
}
|
|
10905
|
+
return prev;
|
|
10906
|
+
});
|
|
10907
|
+
}, [autoSelectCount]);
|
|
10669
10908
|
const [templates, setTemplates] = useState15([]);
|
|
10670
10909
|
const [selectedTemplateId, setSelectedTemplateId] = useState15(null);
|
|
10671
10910
|
const [isLoading, setIsLoading] = useState15(true);
|
|
@@ -11223,6 +11462,11 @@ function useWhatsAppState(props) {
|
|
|
11223
11462
|
// Selection
|
|
11224
11463
|
selectedRowIds,
|
|
11225
11464
|
handleSelectionChange,
|
|
11465
|
+
handleRowToggle,
|
|
11466
|
+
toggleRowSelection,
|
|
11467
|
+
autoSelectCount,
|
|
11468
|
+
setAutoSelectCount,
|
|
11469
|
+
filteredData,
|
|
11226
11470
|
// Phone & Subtable settings
|
|
11227
11471
|
targetPhoneOptions,
|
|
11228
11472
|
phoneColumns,
|
|
@@ -11660,6 +11904,7 @@ function DynamicFiltersBlock({
|
|
|
11660
11904
|
handleClearFilters,
|
|
11661
11905
|
activeFiltersCount,
|
|
11662
11906
|
relationOptions,
|
|
11907
|
+
getRelationOptionsForCol,
|
|
11663
11908
|
selectedRowIds,
|
|
11664
11909
|
filteredRecordsCount,
|
|
11665
11910
|
rawRecordsCount,
|
|
@@ -11691,12 +11936,13 @@ function DynamicFiltersBlock({
|
|
|
11691
11936
|
/* @__PURE__ */ jsx16("span", { children: "\u05D0\u05D9\u05DF \u05E9\u05D3\u05D5\u05EA \u05DC\u05E1\u05D9\u05E0\u05D5\u05DF \u05D1\u05D8\u05D1\u05DC\u05D4 \u05D6\u05D5" }),
|
|
11692
11937
|
/* @__PURE__ */ jsx16("span", { className: "text-[10px] text-slate-400", children: "\u05E9\u05D3\u05D5\u05EA \u05DE\u05E1\u05D5\u05D2 \u05E7\u05E9\u05E8 \u05D5\u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9 \u05D1\u05DC\u05D1\u05D3" })
|
|
11693
11938
|
] }) : /* @__PURE__ */ jsx16("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-1 gap-2", children: filterableColumns.map((col) => {
|
|
11694
|
-
var _a;
|
|
11939
|
+
var _a, _b, _c;
|
|
11695
11940
|
const colType = (_a = col.type) == null ? void 0 : _a.toUpperCase();
|
|
11696
11941
|
const isBoolean = colType === "BOOLEAN";
|
|
11697
11942
|
const currentValue = filters[col.name] || "";
|
|
11698
11943
|
const isActive = Boolean(currentValue);
|
|
11699
|
-
const
|
|
11944
|
+
const refTableId = ((_b = col == null ? void 0 : col.config) == null ? void 0 : _b.referencedTableId) || (col == null ? void 0 : col.referencedTableId);
|
|
11945
|
+
const options = ((_c = getRelationOptionsForCol ? getRelationOptionsForCol(col.name) : []) == null ? void 0 : _c.length) > 0 ? getRelationOptionsForCol(col.name) : relationOptions[col.name] && relationOptions[col.name].length > 0 ? relationOptions[col.name] : refTableId && relationOptions[refTableId] && relationOptions[refTableId].length > 0 ? relationOptions[refTableId] : col.id && relationOptions[col.id] && relationOptions[col.id].length > 0 ? relationOptions[col.id] : [];
|
|
11700
11946
|
return /* @__PURE__ */ jsxs15("div", { className: "space-y-1", children: [
|
|
11701
11947
|
/* @__PURE__ */ jsxs15("div", { className: "flex items-center justify-between", children: [
|
|
11702
11948
|
/* @__PURE__ */ jsx16(
|
|
@@ -11777,7 +12023,8 @@ import {
|
|
|
11777
12023
|
Loader2 as Loader26,
|
|
11778
12024
|
AlertCircle as AlertCircle3,
|
|
11779
12025
|
Send,
|
|
11780
|
-
X as X11
|
|
12026
|
+
X as X11,
|
|
12027
|
+
CheckSquare as CheckSquare2
|
|
11781
12028
|
} from "lucide-react";
|
|
11782
12029
|
import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
11783
12030
|
function SettingsAndActionsBlock({
|
|
@@ -11786,6 +12033,8 @@ function SettingsAndActionsBlock({
|
|
|
11786
12033
|
phoneColumnId,
|
|
11787
12034
|
setPhoneColumnId,
|
|
11788
12035
|
selectedPhoneOption,
|
|
12036
|
+
autoSelectCount = null,
|
|
12037
|
+
setAutoSelectCount,
|
|
11789
12038
|
subtableFilterColumn,
|
|
11790
12039
|
setSubtableFilterColumn,
|
|
11791
12040
|
subtableFilterValue,
|
|
@@ -11875,6 +12124,72 @@ function SettingsAndActionsBlock({
|
|
|
11875
12124
|
/* @__PURE__ */ jsx17(ChevronDown5, { className: "w-3 h-3 text-slate-400 absolute left-2 top-1/2 -translate-y-1/2 pointer-events-none" })
|
|
11876
12125
|
] })
|
|
11877
12126
|
] }),
|
|
12127
|
+
/* @__PURE__ */ jsxs16("div", { className: "space-y-1", children: [
|
|
12128
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-center justify-between", children: [
|
|
12129
|
+
/* @__PURE__ */ jsxs16(
|
|
12130
|
+
"label",
|
|
12131
|
+
{
|
|
12132
|
+
htmlFor: "whatsapp-auto-select-records",
|
|
12133
|
+
className: "text-[11px] font-semibold text-slate-700 flex items-center gap-1 cursor-pointer",
|
|
12134
|
+
children: [
|
|
12135
|
+
/* @__PURE__ */ jsx17(CheckSquare2, { className: "w-3 h-3 text-slate-400" }),
|
|
12136
|
+
/* @__PURE__ */ jsx17("span", { children: "\u05D1\u05D7\u05E8 \u05E8\u05E9\u05D5\u05DE\u05D4 (\u05DB\u05DE\u05D5\u05EA \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05DE\u05E8\u05D1\u05D9\u05EA)" })
|
|
12137
|
+
]
|
|
12138
|
+
}
|
|
12139
|
+
),
|
|
12140
|
+
autoSelectCount !== null && autoSelectCount > 0 && /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1.5 animate-in fade-in duration-150", children: [
|
|
12141
|
+
/* @__PURE__ */ jsxs16("span", { className: "text-[9px] font-semibold text-emerald-700 bg-emerald-50 border border-emerald-200/80 px-1.5 py-0.5 rounded-full flex items-center gap-1", children: [
|
|
12142
|
+
/* @__PURE__ */ jsx17("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" }),
|
|
12143
|
+
/* @__PURE__ */ jsxs16("span", { children: [
|
|
12144
|
+
"\u05E0\u05D1\u05D7\u05E8\u05D5 ",
|
|
12145
|
+
selectedRowIdsCount,
|
|
12146
|
+
" \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA"
|
|
12147
|
+
] })
|
|
12148
|
+
] }),
|
|
12149
|
+
/* @__PURE__ */ jsxs16(
|
|
12150
|
+
"button",
|
|
12151
|
+
{
|
|
12152
|
+
type: "button",
|
|
12153
|
+
onClick: () => setAutoSelectCount == null ? void 0 : setAutoSelectCount(null),
|
|
12154
|
+
className: "text-[10px] text-slate-400 hover:text-rose-600 flex items-center gap-0.5 font-medium hover:underline cursor-pointer transition-colors p-0.5 rounded",
|
|
12155
|
+
title: "\u05E0\u05E7\u05D4 \u05D1\u05D7\u05D9\u05E8\u05D4 \u05D0\u05D5\u05D8\u05D5\u05DE\u05D8\u05D9\u05EA",
|
|
12156
|
+
"aria-label": "Clear auto select count",
|
|
12157
|
+
children: [
|
|
12158
|
+
/* @__PURE__ */ jsx17(X11, { className: "w-3 h-3" }),
|
|
12159
|
+
/* @__PURE__ */ jsx17("span", { children: "\u05E0\u05E7\u05D4" })
|
|
12160
|
+
]
|
|
12161
|
+
}
|
|
12162
|
+
)
|
|
12163
|
+
] })
|
|
12164
|
+
] }),
|
|
12165
|
+
/* @__PURE__ */ jsx17("div", { className: "relative", children: /* @__PURE__ */ jsx17(
|
|
12166
|
+
"input",
|
|
12167
|
+
{
|
|
12168
|
+
id: "whatsapp-auto-select-records",
|
|
12169
|
+
name: "autoSelectCount",
|
|
12170
|
+
type: "number",
|
|
12171
|
+
min: "0",
|
|
12172
|
+
placeholder: "\u05DB\u05DE\u05D5\u05EA \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05DE\u05E8\u05D1\u05D9\u05EA",
|
|
12173
|
+
"aria-label": "\u05DB\u05DE\u05D5\u05EA \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05DE\u05E8\u05D1\u05D9\u05EA",
|
|
12174
|
+
"data-testid": "auto-select-records-input",
|
|
12175
|
+
value: autoSelectCount === null || autoSelectCount === void 0 ? "" : autoSelectCount,
|
|
12176
|
+
onChange: (e) => {
|
|
12177
|
+
const val = e.target.value.trim();
|
|
12178
|
+
if (val === "") {
|
|
12179
|
+
setAutoSelectCount == null ? void 0 : setAutoSelectCount(null);
|
|
12180
|
+
} else {
|
|
12181
|
+
const num = parseInt(val, 10);
|
|
12182
|
+
if (isNaN(num) || num < 0) {
|
|
12183
|
+
setAutoSelectCount == null ? void 0 : setAutoSelectCount(null);
|
|
12184
|
+
} else {
|
|
12185
|
+
setAutoSelectCount == null ? void 0 : setAutoSelectCount(num);
|
|
12186
|
+
}
|
|
12187
|
+
}
|
|
12188
|
+
},
|
|
12189
|
+
className: "w-full h-8 px-2.5 text-[11px] rounded-lg border border-slate-200 bg-white text-slate-700 placeholder:text-slate-400 focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500 transition-all font-medium"
|
|
12190
|
+
}
|
|
12191
|
+
) })
|
|
12192
|
+
] }),
|
|
11878
12193
|
(selectedPhoneOption == null ? void 0 : selectedPhoneOption.type) === "SUBTABLE" && /* @__PURE__ */ jsxs16("div", { className: "p-2.5 bg-emerald-50/60 border border-emerald-200/80 rounded-xl space-y-2 animate-in fade-in duration-150", children: [
|
|
11879
12194
|
/* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1.5 pb-1 border-b border-emerald-200/60", children: [
|
|
11880
12195
|
/* @__PURE__ */ jsx17(Users, { className: "w-3.5 h-3.5 text-emerald-700" }),
|
|
@@ -12279,6 +12594,7 @@ function WhatsAppComponent(props) {
|
|
|
12279
12594
|
handleClearFilters: state.handleClearFilters,
|
|
12280
12595
|
activeFiltersCount: state.activeFiltersCount,
|
|
12281
12596
|
relationOptions: state.relationOptions,
|
|
12597
|
+
getRelationOptionsForCol: state.getRelationOptionsForCol,
|
|
12282
12598
|
selectedRowIds: state.selectedRowIds,
|
|
12283
12599
|
filteredRecordsCount: state.filteredRecords.length,
|
|
12284
12600
|
rawRecordsCount: state.rawRecords.length,
|
|
@@ -12294,6 +12610,8 @@ function WhatsAppComponent(props) {
|
|
|
12294
12610
|
phoneColumnId: state.phoneColumnId,
|
|
12295
12611
|
setPhoneColumnId: state.setPhoneColumnId,
|
|
12296
12612
|
selectedPhoneOption: state.selectedPhoneOption,
|
|
12613
|
+
autoSelectCount: state.autoSelectCount,
|
|
12614
|
+
setAutoSelectCount: state.setAutoSelectCount,
|
|
12297
12615
|
subtableFilterColumn: state.subtableFilterColumn,
|
|
12298
12616
|
setSubtableFilterColumn: state.setSubtableFilterColumn,
|
|
12299
12617
|
subtableFilterValue: state.subtableFilterValue,
|
|
@@ -12347,7 +12665,9 @@ function WhatsAppComponent(props) {
|
|
|
12347
12665
|
},
|
|
12348
12666
|
data: state.filteredRecords,
|
|
12349
12667
|
readOnly: true,
|
|
12668
|
+
selectedRowIds: state.selectedRowIds,
|
|
12350
12669
|
onSelectionChange: state.handleSelectionChange,
|
|
12670
|
+
onRowToggle: state.handleRowToggle,
|
|
12351
12671
|
executeAction: state.embeddedTableExecuteAction,
|
|
12352
12672
|
orgId,
|
|
12353
12673
|
componentId: `${componentId || "whatsapp"}-embedded-table`,
|
|
@@ -12543,13 +12863,16 @@ export {
|
|
|
12543
12863
|
ColumnHeaderTitle,
|
|
12544
12864
|
CreateTemplateModal,
|
|
12545
12865
|
DatePickerCell,
|
|
12866
|
+
DynamicFiltersBlock,
|
|
12546
12867
|
LinkPickerCell,
|
|
12547
12868
|
PASTEL_PALETTES,
|
|
12548
12869
|
RelationFilterPopover,
|
|
12549
12870
|
RelationPickerCell,
|
|
12871
|
+
SettingsAndActionsBlock,
|
|
12550
12872
|
SmartTextCell,
|
|
12551
12873
|
TEXT_REPRESENTABLE_TYPES,
|
|
12552
12874
|
TableBlock,
|
|
12875
|
+
TableBlockClient,
|
|
12553
12876
|
TimePickerCell,
|
|
12554
12877
|
ToastContext,
|
|
12555
12878
|
ToastProvider,
|
|
@@ -12600,6 +12923,7 @@ export {
|
|
|
12600
12923
|
useColumnResize,
|
|
12601
12924
|
useSmartTooltip,
|
|
12602
12925
|
useToast,
|
|
12926
|
+
useWhatsAppState,
|
|
12603
12927
|
validateSequentialVariables,
|
|
12604
12928
|
validateTemplateBody,
|
|
12605
12929
|
validateTemplateButtons,
|