@universe-platform/ui 0.1.0-beta.67 → 0.1.0-beta.68
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 +14 -0
- package/dist/index.js +613 -459
- package/dist/index.mjs +338 -190
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1327,12 +1327,31 @@ function renameCopyTarget(col, oldName, newName) {
|
|
|
1327
1327
|
|
|
1328
1328
|
// ../shared/src/relationButtons.ts
|
|
1329
1329
|
var RELATION_BUTTON_COUNTS_ACTION = "FETCH_RELATION_BUTTON_COUNTS";
|
|
1330
|
+
var BOOLEAN_BUTTON_TRUE_ID = "true";
|
|
1331
|
+
var BOOLEAN_BUTTON_FALSE_ID = "false";
|
|
1332
|
+
var DEFAULT_BOOLEAN_TRUE_LABEL = "\u05DB\u05DF";
|
|
1333
|
+
var DEFAULT_BOOLEAN_FALSE_LABEL = "\u05DC\u05D0";
|
|
1330
1334
|
function isRelationButtonsColumn(col) {
|
|
1331
1335
|
var _a, _b;
|
|
1332
1336
|
return !!col && String(col.type).toUpperCase() === "RELATION" && ((_a = col.config) == null ? void 0 : _a.showAsButtons) === true && !!((_b = col.config) == null ? void 0 : _b.referencedTableId);
|
|
1333
1337
|
}
|
|
1338
|
+
function isBooleanButtonsColumn(col) {
|
|
1339
|
+
var _a;
|
|
1340
|
+
return !!col && String(col.type).toUpperCase() === "BOOLEAN" && ((_a = col.config) == null ? void 0 : _a.showAsButtons) === true;
|
|
1341
|
+
}
|
|
1342
|
+
function getBooleanButtonLabels(col) {
|
|
1343
|
+
var _a, _b, _c, _d;
|
|
1344
|
+
const t = String((_b = (_a = col == null ? void 0 : col.config) == null ? void 0 : _a.buttonsTrueLabel) != null ? _b : "").trim();
|
|
1345
|
+
const f = String((_d = (_c = col == null ? void 0 : col.config) == null ? void 0 : _c.buttonsFalseLabel) != null ? _d : "").trim();
|
|
1346
|
+
return {
|
|
1347
|
+
trueLabel: t || DEFAULT_BOOLEAN_TRUE_LABEL,
|
|
1348
|
+
falseLabel: f || DEFAULT_BOOLEAN_FALSE_LABEL
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1334
1351
|
function getRelationButtonColumns(columns) {
|
|
1335
|
-
return (columns || []).filter(
|
|
1352
|
+
return (columns || []).filter(
|
|
1353
|
+
(c) => (isRelationButtonsColumn(c) || isBooleanButtonsColumn(c)) && c.name !== "_id"
|
|
1354
|
+
);
|
|
1336
1355
|
}
|
|
1337
1356
|
|
|
1338
1357
|
// ../shared/src/defaultFilters.ts
|
|
@@ -1535,7 +1554,7 @@ function buildIfExpression(columns, conds, joiner, thenVal, elseVal) {
|
|
|
1535
1554
|
}
|
|
1536
1555
|
|
|
1537
1556
|
// src/components/TableBlock/TableBlockClient.tsx
|
|
1538
|
-
import
|
|
1557
|
+
import React15, { useState as useState16, useMemo as useMemo8, useEffect as useEffect14, useCallback as useCallback13, useRef as useRef15 } from "react";
|
|
1539
1558
|
|
|
1540
1559
|
// src/hooks/useToast.ts
|
|
1541
1560
|
import { useContext as useContext2 } from "react";
|
|
@@ -7182,68 +7201,139 @@ function RelationFilterPopover({
|
|
|
7182
7201
|
}
|
|
7183
7202
|
|
|
7184
7203
|
// src/components/TableBlock/RelationButtonsBar.tsx
|
|
7185
|
-
import { useEffect as useEffect12, useMemo as useMemo7, useRef as
|
|
7204
|
+
import { useCallback as useCallback12, useEffect as useEffect12, useMemo as useMemo7, useRef as useRef13, useState as useState14 } from "react";
|
|
7186
7205
|
|
|
7187
7206
|
// src/components/TableBlock/RelationButtonsView.tsx
|
|
7207
|
+
import { useRef as useRef12 } from "react";
|
|
7188
7208
|
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
7189
|
-
|
|
7209
|
+
var MIN_GROUP_WIDTH = 140;
|
|
7210
|
+
function RelationButtonsView({
|
|
7211
|
+
groups,
|
|
7212
|
+
onSelect,
|
|
7213
|
+
disabled,
|
|
7214
|
+
stacked = false,
|
|
7215
|
+
widths,
|
|
7216
|
+
onResize,
|
|
7217
|
+
onResizeEnd
|
|
7218
|
+
}) {
|
|
7219
|
+
const containerRef = useRef12(null);
|
|
7220
|
+
const dragRef = useRef12(null);
|
|
7221
|
+
const resizable = !stacked && !!onResize;
|
|
7190
7222
|
const visible = groups.filter((g) => g.options.length > 0);
|
|
7191
7223
|
if (visible.length === 0) return null;
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
);
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7224
|
+
const handlePointerDown = (e, key) => {
|
|
7225
|
+
var _a, _b;
|
|
7226
|
+
if (!onResize) return;
|
|
7227
|
+
e.preventDefault();
|
|
7228
|
+
const box = e.currentTarget.parentElement;
|
|
7229
|
+
const rtl = getComputedStyle(box).direction === "rtl";
|
|
7230
|
+
dragRef.current = {
|
|
7231
|
+
key,
|
|
7232
|
+
startX: e.clientX,
|
|
7233
|
+
startWidth: box.getBoundingClientRect().width,
|
|
7234
|
+
// הידית בקצה הסופי של המתחם: ב-RTL זה הצד השמאלי (גרירה שמאלה מגדילה), ב-LTR הצד הימני
|
|
7235
|
+
sign: rtl ? -1 : 1,
|
|
7236
|
+
max: (_b = (_a = containerRef.current) == null ? void 0 : _a.clientWidth) != null ? _b : 4e3
|
|
7237
|
+
};
|
|
7238
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
7239
|
+
};
|
|
7240
|
+
const handlePointerMove = (e) => {
|
|
7241
|
+
const d = dragRef.current;
|
|
7242
|
+
if (!d || !onResize) return;
|
|
7243
|
+
const next = d.startWidth + (e.clientX - d.startX) * d.sign;
|
|
7244
|
+
const clamped = Math.max(MIN_GROUP_WIDTH, Math.min(d.max, next));
|
|
7245
|
+
onResize(d.key, Math.round(clamped));
|
|
7246
|
+
};
|
|
7247
|
+
const handlePointerUp = () => {
|
|
7248
|
+
if (!dragRef.current) return;
|
|
7249
|
+
dragRef.current = null;
|
|
7250
|
+
onResizeEnd == null ? void 0 : onResizeEnd();
|
|
7251
|
+
};
|
|
7252
|
+
return /* @__PURE__ */ jsx15(
|
|
7253
|
+
"div",
|
|
7254
|
+
{
|
|
7255
|
+
ref: containerRef,
|
|
7256
|
+
className: `flex gap-2.5 ${stacked ? "flex-col" : "flex-wrap items-start"}`,
|
|
7257
|
+
children: visible.map((group) => {
|
|
7258
|
+
const titleIsDuplicate = group.options.some(
|
|
7259
|
+
(opt) => opt.label.trim() === group.title.trim()
|
|
7260
|
+
);
|
|
7261
|
+
const customWidth = resizable ? widths == null ? void 0 : widths[group.key] : void 0;
|
|
7262
|
+
const sizeClass = stacked ? "w-full" : customWidth ? "" : "w-full md:w-[calc(50%_-_5px)]";
|
|
7263
|
+
return /* @__PURE__ */ jsxs13(
|
|
7264
|
+
"div",
|
|
7265
|
+
{
|
|
7266
|
+
style: customWidth ? { width: customWidth, maxWidth: "100%" } : void 0,
|
|
7267
|
+
className: `relative min-w-0 bg-white border border-slate-200 rounded-xl px-3 py-2.5 shadow-2xs ${sizeClass}`,
|
|
7268
|
+
children: [
|
|
7269
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-end gap-x-2 gap-y-2.5", children: [
|
|
7270
|
+
!titleIsDuplicate && /* @__PURE__ */ jsx15(
|
|
7271
|
+
"span",
|
|
7272
|
+
{
|
|
7273
|
+
className: "self-end h-8 inline-flex items-center text-xs font-bold text-slate-800 max-w-[10rem] truncate",
|
|
7274
|
+
title: group.title,
|
|
7275
|
+
children: group.title
|
|
7276
|
+
}
|
|
7277
|
+
),
|
|
7278
|
+
group.options.map((opt) => {
|
|
7279
|
+
const active = group.activeId === opt.id;
|
|
7280
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col items-center gap-0.5", children: [
|
|
7281
|
+
/* @__PURE__ */ jsx15(
|
|
7282
|
+
"span",
|
|
7283
|
+
{
|
|
7284
|
+
className: `text-[11px] font-bold leading-none ${active ? "text-indigo-700" : "text-slate-500"}`,
|
|
7285
|
+
children: opt.count
|
|
7286
|
+
}
|
|
7287
|
+
),
|
|
7288
|
+
/* @__PURE__ */ jsx15(
|
|
7289
|
+
"button",
|
|
7290
|
+
{
|
|
7291
|
+
type: "button",
|
|
7292
|
+
disabled,
|
|
7293
|
+
onClick: () => onSelect(group.key, active ? void 0 : opt.id),
|
|
7294
|
+
title: active ? "\u05DC\u05D7\u05E5 \u05DC\u05D1\u05D9\u05D8\u05D5\u05DC \u05D4\u05E1\u05D9\u05E0\u05D5\u05DF" : `\u05E1\u05E0\u05DF \u05DC\u05E4\u05D9: ${opt.label}`,
|
|
7295
|
+
"aria-pressed": active,
|
|
7296
|
+
className: `px-3 h-8 rounded-md border text-xs font-semibold whitespace-nowrap shadow-2xs transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none ${active ? "bg-indigo-600 border-indigo-600 text-white hover:bg-indigo-700" : "bg-white border-slate-300 text-slate-700 hover:bg-slate-50 hover:border-slate-400"}`,
|
|
7297
|
+
children: opt.label
|
|
7298
|
+
}
|
|
7299
|
+
)
|
|
7300
|
+
] }, opt.id);
|
|
7301
|
+
}),
|
|
7302
|
+
group.activeId ? /* @__PURE__ */ jsx15(
|
|
7303
|
+
"button",
|
|
7304
|
+
{
|
|
7305
|
+
type: "button",
|
|
7306
|
+
onClick: () => onSelect(group.key, void 0),
|
|
7307
|
+
className: "self-end h-8 inline-flex items-center px-1 text-[11px] font-semibold text-rose-600 hover:text-rose-700 hover:underline cursor-pointer shrink-0 whitespace-nowrap",
|
|
7308
|
+
children: "\u05E0\u05E7\u05D4 \u05E1\u05D9\u05E0\u05D5\u05DF"
|
|
7309
|
+
}
|
|
7310
|
+
) : null
|
|
7311
|
+
] }),
|
|
7312
|
+
resizable && /* @__PURE__ */ jsx15(
|
|
7313
|
+
"div",
|
|
7221
7314
|
{
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7315
|
+
role: "separator",
|
|
7316
|
+
"aria-orientation": "vertical",
|
|
7317
|
+
title: "\u05D2\u05E8\u05D5\u05E8 \u05DC\u05E9\u05D9\u05E0\u05D5\u05D9 \u05D4\u05E8\u05D5\u05D7\u05D1 (\u05DC\u05D7\u05D9\u05E6\u05D4 \u05DB\u05E4\u05D5\u05DC\u05D4 \u05DC\u05D0\u05D9\u05E4\u05D5\u05E1)",
|
|
7318
|
+
onPointerDown: (e) => handlePointerDown(e, group.key),
|
|
7319
|
+
onPointerMove: handlePointerMove,
|
|
7320
|
+
onPointerUp: handlePointerUp,
|
|
7321
|
+
onPointerCancel: handlePointerUp,
|
|
7322
|
+
onDoubleClick: () => {
|
|
7323
|
+
onResize == null ? void 0 : onResize(group.key, void 0);
|
|
7324
|
+
onResizeEnd == null ? void 0 : onResizeEnd();
|
|
7325
|
+
},
|
|
7326
|
+
className: "group/handle absolute top-0 bottom-0 end-0 w-2.5 cursor-col-resize touch-none z-10 flex items-center justify-center",
|
|
7327
|
+
children: /* @__PURE__ */ jsx15("span", { className: "h-8 w-0.5 rounded-full bg-slate-300 group-hover/handle:bg-brand transition-colors" })
|
|
7229
7328
|
}
|
|
7230
7329
|
)
|
|
7231
|
-
]
|
|
7232
|
-
}
|
|
7233
|
-
group.
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
className: "self-end h-8 inline-flex items-center px-1 text-[11px] font-semibold text-rose-600 hover:text-rose-700 hover:underline cursor-pointer shrink-0 whitespace-nowrap",
|
|
7239
|
-
children: "\u05E0\u05E7\u05D4 \u05E1\u05D9\u05E0\u05D5\u05DF"
|
|
7240
|
-
}
|
|
7241
|
-
) : null
|
|
7242
|
-
] })
|
|
7243
|
-
},
|
|
7244
|
-
group.key
|
|
7245
|
-
);
|
|
7246
|
-
}) });
|
|
7330
|
+
]
|
|
7331
|
+
},
|
|
7332
|
+
group.key
|
|
7333
|
+
);
|
|
7334
|
+
})
|
|
7335
|
+
}
|
|
7336
|
+
);
|
|
7247
7337
|
}
|
|
7248
7338
|
|
|
7249
7339
|
// src/components/TableBlock/RelationButtonsBar.tsx
|
|
@@ -7265,9 +7355,40 @@ function RelationButtonsBar({
|
|
|
7265
7355
|
const buttonCols = useMemo7(() => getRelationButtonColumns(columns), [columns]);
|
|
7266
7356
|
const colsKey = useMemo7(() => buttonCols.map((c) => c.name).join("|"), [buttonCols]);
|
|
7267
7357
|
const [counts, setCounts] = useState14({});
|
|
7268
|
-
const requestIdRef =
|
|
7269
|
-
const actionRef =
|
|
7358
|
+
const requestIdRef = useRef13(0);
|
|
7359
|
+
const actionRef = useRef13(executeAction);
|
|
7270
7360
|
actionRef.current = executeAction;
|
|
7361
|
+
const widthsStorageKey = tableId ? `relation_buttons_widths_${tableId}` : "";
|
|
7362
|
+
const [widths, setWidths] = useState14({});
|
|
7363
|
+
const widthsRef = useRef13({});
|
|
7364
|
+
widthsRef.current = widths;
|
|
7365
|
+
useEffect12(() => {
|
|
7366
|
+
if (typeof window === "undefined" || !widthsStorageKey) return;
|
|
7367
|
+
try {
|
|
7368
|
+
const saved = localStorage.getItem(widthsStorageKey);
|
|
7369
|
+
setWidths(saved ? JSON.parse(saved) : {});
|
|
7370
|
+
} catch (e) {
|
|
7371
|
+
console.error(`Failed to load relation button widths for key "${widthsStorageKey}":`, e);
|
|
7372
|
+
}
|
|
7373
|
+
}, [widthsStorageKey]);
|
|
7374
|
+
const handleResize = useCallback12((colName, width) => {
|
|
7375
|
+
setWidths((prev) => {
|
|
7376
|
+
const next = __spreadValues({}, prev);
|
|
7377
|
+
if (width === void 0) delete next[colName];
|
|
7378
|
+
else next[colName] = width;
|
|
7379
|
+
return next;
|
|
7380
|
+
});
|
|
7381
|
+
}, []);
|
|
7382
|
+
const handleResizeEnd = useCallback12(() => {
|
|
7383
|
+
if (typeof window === "undefined" || !widthsStorageKey) return;
|
|
7384
|
+
setTimeout(() => {
|
|
7385
|
+
try {
|
|
7386
|
+
localStorage.setItem(widthsStorageKey, JSON.stringify(widthsRef.current));
|
|
7387
|
+
} catch (e) {
|
|
7388
|
+
console.error(`Failed to save relation button widths for key "${widthsStorageKey}":`, e);
|
|
7389
|
+
}
|
|
7390
|
+
}, 0);
|
|
7391
|
+
}, [widthsStorageKey]);
|
|
7271
7392
|
useEffect12(() => {
|
|
7272
7393
|
if (!colsKey || !tableId || !actionRef.current) return;
|
|
7273
7394
|
const myId = ++requestIdRef.current;
|
|
@@ -7282,7 +7403,12 @@ function RelationButtonsBar({
|
|
|
7282
7403
|
const groups = useMemo7(
|
|
7283
7404
|
() => buttonCols.map((col) => {
|
|
7284
7405
|
const v = columnFilters == null ? void 0 : columnFilters[col.name];
|
|
7285
|
-
|
|
7406
|
+
let activeId = null;
|
|
7407
|
+
if (isBooleanButtonsColumn(col)) {
|
|
7408
|
+
activeId = v === "true" || v === "false" ? v : null;
|
|
7409
|
+
} else {
|
|
7410
|
+
activeId = Array.isArray(v) && v.length === 1 ? String(v[0]) : null;
|
|
7411
|
+
}
|
|
7286
7412
|
return {
|
|
7287
7413
|
key: col.name,
|
|
7288
7414
|
title: col.name,
|
|
@@ -7292,6 +7418,19 @@ function RelationButtonsBar({
|
|
|
7292
7418
|
}),
|
|
7293
7419
|
[buttonCols, counts, columnFilters]
|
|
7294
7420
|
);
|
|
7421
|
+
const handleSelect = useCallback12(
|
|
7422
|
+
(colName, id) => {
|
|
7423
|
+
const col = buttonCols.find((c) => c.name === colName);
|
|
7424
|
+
if (id === void 0) {
|
|
7425
|
+
onApplyFilter(colName, void 0);
|
|
7426
|
+
} else if (isBooleanButtonsColumn(col)) {
|
|
7427
|
+
onApplyFilter(colName, id);
|
|
7428
|
+
} else {
|
|
7429
|
+
onApplyFilter(colName, [id]);
|
|
7430
|
+
}
|
|
7431
|
+
},
|
|
7432
|
+
[buttonCols, onApplyFilter]
|
|
7433
|
+
);
|
|
7295
7434
|
if (buttonCols.length === 0 || groups.every((g) => g.options.length === 0)) return null;
|
|
7296
7435
|
return /* @__PURE__ */ jsx16(
|
|
7297
7436
|
"div",
|
|
@@ -7303,7 +7442,10 @@ function RelationButtonsBar({
|
|
|
7303
7442
|
{
|
|
7304
7443
|
groups,
|
|
7305
7444
|
disabled,
|
|
7306
|
-
onSelect:
|
|
7445
|
+
onSelect: handleSelect,
|
|
7446
|
+
widths,
|
|
7447
|
+
onResize: handleResize,
|
|
7448
|
+
onResizeEnd: handleResizeEnd
|
|
7307
7449
|
}
|
|
7308
7450
|
)
|
|
7309
7451
|
}
|
|
@@ -7311,7 +7453,7 @@ function RelationButtonsBar({
|
|
|
7311
7453
|
}
|
|
7312
7454
|
|
|
7313
7455
|
// src/components/TableBlock/useDefaultColumnFilters.ts
|
|
7314
|
-
import { useEffect as useEffect13, useRef as
|
|
7456
|
+
import { useEffect as useEffect13, useRef as useRef14, useState as useState15 } from "react";
|
|
7315
7457
|
var RESOLVE_TIMEOUT_MS = 8e3;
|
|
7316
7458
|
function unwrap2(res) {
|
|
7317
7459
|
const body = (res == null ? void 0 : res.data) && typeof res.data === "object" && !Array.isArray(res.data) ? res.data : res;
|
|
@@ -7321,10 +7463,10 @@ function unwrap2(res) {
|
|
|
7321
7463
|
function useDefaultColumnFilters({ columns, tableId, executeAction, onResolved }) {
|
|
7322
7464
|
const hasDefaults = getDefaultFilterColumns(columns).length > 0;
|
|
7323
7465
|
const [ready, setReady] = useState15(() => !hasDefaults);
|
|
7324
|
-
const doneRef =
|
|
7325
|
-
const onResolvedRef =
|
|
7466
|
+
const doneRef = useRef14(false);
|
|
7467
|
+
const onResolvedRef = useRef14(onResolved);
|
|
7326
7468
|
onResolvedRef.current = onResolved;
|
|
7327
|
-
const actionRef =
|
|
7469
|
+
const actionRef = useRef14(executeAction);
|
|
7328
7470
|
actionRef.current = executeAction;
|
|
7329
7471
|
useEffect13(() => {
|
|
7330
7472
|
if (doneRef.current || !hasDefaults) return;
|
|
@@ -7385,7 +7527,7 @@ function TableBlockClient({
|
|
|
7385
7527
|
const { showError, addToast } = useToast();
|
|
7386
7528
|
const [isExporting, setIsExporting] = useState16(false);
|
|
7387
7529
|
const [isExportMenuOpen, setIsExportMenuOpen] = useState16(false);
|
|
7388
|
-
const exportMenuRef =
|
|
7530
|
+
const exportMenuRef = useRef15(null);
|
|
7389
7531
|
useEffect14(() => {
|
|
7390
7532
|
if (!isExportMenuOpen) return;
|
|
7391
7533
|
const handleClickOutside = (e) => {
|
|
@@ -7421,7 +7563,7 @@ function TableBlockClient({
|
|
|
7421
7563
|
return calculateMinColumnWidth(colName, false, col == null ? void 0 : col.type);
|
|
7422
7564
|
}
|
|
7423
7565
|
});
|
|
7424
|
-
const executeActionRef =
|
|
7566
|
+
const executeActionRef = useRef15(executeAction);
|
|
7425
7567
|
useEffect14(() => {
|
|
7426
7568
|
executeActionRef.current = executeAction;
|
|
7427
7569
|
}, [executeAction]);
|
|
@@ -7481,7 +7623,7 @@ function TableBlockClient({
|
|
|
7481
7623
|
return __spreadProps(__spreadValues({}, row), { id: String(row.id || ""), data: rowData });
|
|
7482
7624
|
});
|
|
7483
7625
|
};
|
|
7484
|
-
const mergeColumnDefs =
|
|
7626
|
+
const mergeColumnDefs = useCallback13((existingCols, incomingCols) => {
|
|
7485
7627
|
if (!incomingCols || incomingCols.length === 0) return existingCols || [];
|
|
7486
7628
|
if (!existingCols || existingCols.length === 0) return incomingCols;
|
|
7487
7629
|
const existingMap = new Map(existingCols.map((c) => [c.name, c]));
|
|
@@ -7508,11 +7650,11 @@ function TableBlockClient({
|
|
|
7508
7650
|
}
|
|
7509
7651
|
}, [schema == null ? void 0 : schema.columns, mergeColumnDefs]);
|
|
7510
7652
|
const [dirty, setDirty] = useState16({ added: [], modified: {}, deleted: [] });
|
|
7511
|
-
const dirtyRef =
|
|
7653
|
+
const dirtyRef = useRef15(dirty);
|
|
7512
7654
|
useEffect14(() => {
|
|
7513
7655
|
dirtyRef.current = dirty;
|
|
7514
7656
|
}, [dirty]);
|
|
7515
|
-
const mergeWithDirty =
|
|
7657
|
+
const mergeWithDirty = useCallback13((baseRecords) => {
|
|
7516
7658
|
const { added, modified, deleted } = dirtyRef.current;
|
|
7517
7659
|
const nonDeleted = (baseRecords || []).filter((r) => !deleted.includes(r.id));
|
|
7518
7660
|
const modifiedRecords = nonDeleted.map((r) => {
|
|
@@ -7553,15 +7695,15 @@ function TableBlockClient({
|
|
|
7553
7695
|
const [searchQuery, setSearchQuery] = useState16("");
|
|
7554
7696
|
const [columnFilters, setColumnFilters] = useState16({});
|
|
7555
7697
|
const [activeSearchCol, setActiveSearchCol] = useState16(null);
|
|
7556
|
-
const activeSearchRef =
|
|
7698
|
+
const activeSearchRef = useRef15(null);
|
|
7557
7699
|
const [activeRelationCol, setActiveRelationCol] = useState16(null);
|
|
7558
7700
|
const [relationTriggerRect, setRelationTriggerRect] = useState16(null);
|
|
7559
|
-
const filterButtonRefs =
|
|
7701
|
+
const filterButtonRefs = useRef15({});
|
|
7560
7702
|
const [relationOptions, setRelationOptions] = useState16({});
|
|
7561
7703
|
const [relationFilterOptions, setRelationFilterOptions] = useState16({});
|
|
7562
7704
|
const [loadingFilterCol, setLoadingFilterCol] = useState16(null);
|
|
7563
|
-
const relationDictionaryRef =
|
|
7564
|
-
const mergeRelationOptions =
|
|
7705
|
+
const relationDictionaryRef = useRef15({});
|
|
7706
|
+
const mergeRelationOptions = useCallback13((colName, newOptions) => {
|
|
7565
7707
|
if (!Array.isArray(newOptions) || newOptions.length === 0) return;
|
|
7566
7708
|
if (!relationDictionaryRef.current[colName]) {
|
|
7567
7709
|
relationDictionaryRef.current[colName] = /* @__PURE__ */ new Map();
|
|
@@ -7618,7 +7760,7 @@ function TableBlockClient({
|
|
|
7618
7760
|
}, 300);
|
|
7619
7761
|
return () => clearTimeout(timer);
|
|
7620
7762
|
}, [searchQuery]);
|
|
7621
|
-
const isSearchMountedRef =
|
|
7763
|
+
const isSearchMountedRef = useRef15(false);
|
|
7622
7764
|
useEffect14(() => {
|
|
7623
7765
|
if (!isSearchMountedRef.current) {
|
|
7624
7766
|
isSearchMountedRef.current = true;
|
|
@@ -7627,8 +7769,8 @@ function TableBlockClient({
|
|
|
7627
7769
|
setPage(1);
|
|
7628
7770
|
}, [debouncedSearch]);
|
|
7629
7771
|
const [isFetching, setIsFetching] = useState16(false);
|
|
7630
|
-
const fetchRequestIdRef =
|
|
7631
|
-
const fetchTableData =
|
|
7772
|
+
const fetchRequestIdRef = useRef15(0);
|
|
7773
|
+
const fetchTableData = useCallback13((targetPage, targetLimit, targetSearch, targetFiltersKey) => {
|
|
7632
7774
|
const tableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
7633
7775
|
const action = executeActionRef.current;
|
|
7634
7776
|
if (!tableId || !action) {
|
|
@@ -7819,10 +7961,10 @@ function TableBlockClient({
|
|
|
7819
7961
|
}
|
|
7820
7962
|
}
|
|
7821
7963
|
}, [initialRecords, mergeWithDirty, debouncedSearch, columnFilters, fetchTableData, page, limit, filtersKey, defaultFiltersReady]);
|
|
7822
|
-
const refetchTableData =
|
|
7964
|
+
const refetchTableData = useCallback13(() => {
|
|
7823
7965
|
return fetchTableData(page, limit, debouncedSearch, filtersKey);
|
|
7824
7966
|
}, [page, limit, debouncedSearch, filtersKey, fetchTableData]);
|
|
7825
|
-
const handleApplyColumnFilter =
|
|
7967
|
+
const handleApplyColumnFilter = useCallback13((colName, nextVal) => {
|
|
7826
7968
|
setColumnFilters((prev) => {
|
|
7827
7969
|
const next = __spreadValues({}, prev);
|
|
7828
7970
|
if (nextVal === void 0 || Array.isArray(nextVal) && nextVal.length === 0 || typeof nextVal === "string" && !nextVal.trim() || typeof nextVal === "object" && "values" in nextVal && Array.isArray(nextVal.values) && nextVal.values.length === 0) {
|
|
@@ -7848,7 +7990,7 @@ function TableBlockClient({
|
|
|
7848
7990
|
setPage((prev) => Math.min(totalPages, prev + 1));
|
|
7849
7991
|
};
|
|
7850
7992
|
const [selectedIds, setSelectedIds] = useState16(/* @__PURE__ */ new Set());
|
|
7851
|
-
const isExternalSyncRef =
|
|
7993
|
+
const isExternalSyncRef = useRef15(false);
|
|
7852
7994
|
useEffect14(() => {
|
|
7853
7995
|
if (selectedRowIds !== void 0) {
|
|
7854
7996
|
const nextSet = new Set(selectedRowIds);
|
|
@@ -7861,7 +8003,7 @@ function TableBlockClient({
|
|
|
7861
8003
|
});
|
|
7862
8004
|
}
|
|
7863
8005
|
}, [selectedRowIds]);
|
|
7864
|
-
const isFirstSelectionChangeRef =
|
|
8006
|
+
const isFirstSelectionChangeRef = useRef15(true);
|
|
7865
8007
|
useEffect14(() => {
|
|
7866
8008
|
if (isFirstSelectionChangeRef.current) {
|
|
7867
8009
|
isFirstSelectionChangeRef.current = false;
|
|
@@ -7879,7 +8021,7 @@ function TableBlockClient({
|
|
|
7879
8021
|
const [isSaveSuccess, setIsSaveSuccess] = useState16(false);
|
|
7880
8022
|
const [expandedRowIds, setExpandedRowIds] = useState16(/* @__PURE__ */ new Set());
|
|
7881
8023
|
const schemaColsString = useMemo8(() => JSON.stringify(localColumns || []), [localColumns]);
|
|
7882
|
-
const refetchRelation =
|
|
8024
|
+
const refetchRelation = useCallback13(async (colName, params) => {
|
|
7883
8025
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7884
8026
|
let parsedCols = [];
|
|
7885
8027
|
try {
|
|
@@ -7918,7 +8060,7 @@ function TableBlockClient({
|
|
|
7918
8060
|
}
|
|
7919
8061
|
return [];
|
|
7920
8062
|
}, [schemaColsString, executeAction, mergeRelationOptions]);
|
|
7921
|
-
const fetchRelationFilterOptions =
|
|
8063
|
+
const fetchRelationFilterOptions = useCallback13(async (colName) => {
|
|
7922
8064
|
var _a;
|
|
7923
8065
|
let parsedCols = [];
|
|
7924
8066
|
try {
|
|
@@ -7954,7 +8096,7 @@ function TableBlockClient({
|
|
|
7954
8096
|
setLoadingFilterCol(null);
|
|
7955
8097
|
}
|
|
7956
8098
|
}, [schemaColsString, schema == null ? void 0 : schema.tableMetaId, schema == null ? void 0 : schema.tableId, schema == null ? void 0 : schema.id, executeAction, mergeRelationOptions]);
|
|
7957
|
-
const requestedRelationIdsRef =
|
|
8099
|
+
const requestedRelationIdsRef = useRef15({});
|
|
7958
8100
|
useEffect14(() => {
|
|
7959
8101
|
if (!executeAction || !data || data.length === 0) return;
|
|
7960
8102
|
let parsedCols = [];
|
|
@@ -8045,7 +8187,7 @@ function TableBlockClient({
|
|
|
8045
8187
|
return normalizedColumns.filter((col) => !systemFields.includes(col.name));
|
|
8046
8188
|
}, [normalizedColumns]);
|
|
8047
8189
|
const [isColumnsDropdownOpen, setIsColumnsDropdownOpen] = useState16(false);
|
|
8048
|
-
const dropdownRef =
|
|
8190
|
+
const dropdownRef = useRef15(null);
|
|
8049
8191
|
useEffect14(() => {
|
|
8050
8192
|
const handleClickOutside = (e) => {
|
|
8051
8193
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
@@ -8288,7 +8430,7 @@ function TableBlockClient({
|
|
|
8288
8430
|
setData((prev) => [newRow, ...prev]);
|
|
8289
8431
|
setDirty((prev) => __spreadProps(__spreadValues({}, prev), { added: [newRow, ...prev.added] }));
|
|
8290
8432
|
};
|
|
8291
|
-
const handleCellChange =
|
|
8433
|
+
const handleCellChange = useCallback13((rowId, colName, value) => {
|
|
8292
8434
|
setData((prev) => prev.map(
|
|
8293
8435
|
(row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
|
|
8294
8436
|
));
|
|
@@ -8321,13 +8463,13 @@ function TableBlockClient({
|
|
|
8321
8463
|
});
|
|
8322
8464
|
}, [baseRecordsMap]);
|
|
8323
8465
|
const handleCellChangeWithCopy = useRelationCopyHandler({ columns: localColumns, handleCellChange });
|
|
8324
|
-
const triggerSaveSuccess =
|
|
8466
|
+
const triggerSaveSuccess = useCallback13(() => {
|
|
8325
8467
|
setIsSaveSuccess(true);
|
|
8326
8468
|
setTimeout(() => {
|
|
8327
8469
|
setIsSaveSuccess(false);
|
|
8328
8470
|
}, 2500);
|
|
8329
8471
|
}, []);
|
|
8330
|
-
const handleQuietCellChange =
|
|
8472
|
+
const handleQuietCellChange = useCallback13((rowId, colName, value) => {
|
|
8331
8473
|
setData((prev) => prev.map(
|
|
8332
8474
|
(row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
|
|
8333
8475
|
));
|
|
@@ -8351,12 +8493,12 @@ function TableBlockClient({
|
|
|
8351
8493
|
});
|
|
8352
8494
|
}
|
|
8353
8495
|
}, []);
|
|
8354
|
-
const toggleSelectAll =
|
|
8496
|
+
const toggleSelectAll = useCallback13((checked) => {
|
|
8355
8497
|
onRowToggle == null ? void 0 : onRowToggle("ALL", checked);
|
|
8356
8498
|
const next = checked ? new Set(filteredData.map((r) => r.id)) : /* @__PURE__ */ new Set();
|
|
8357
8499
|
setSelectedIds(next);
|
|
8358
8500
|
}, [filteredData, onRowToggle]);
|
|
8359
|
-
const toggleSelectRow =
|
|
8501
|
+
const toggleSelectRow = useCallback13((rowId, checked) => {
|
|
8360
8502
|
onRowToggle == null ? void 0 : onRowToggle(rowId, checked);
|
|
8361
8503
|
setSelectedIds((prev) => {
|
|
8362
8504
|
const next = new Set(prev);
|
|
@@ -8365,7 +8507,7 @@ function TableBlockClient({
|
|
|
8365
8507
|
return next;
|
|
8366
8508
|
});
|
|
8367
8509
|
}, [onRowToggle]);
|
|
8368
|
-
const handleToggleExpand =
|
|
8510
|
+
const handleToggleExpand = useCallback13((rowId) => {
|
|
8369
8511
|
setExpandedRowIds((prev) => {
|
|
8370
8512
|
const next = new Set(prev);
|
|
8371
8513
|
if (next.has(rowId)) next.delete(rowId);
|
|
@@ -8373,7 +8515,7 @@ function TableBlockClient({
|
|
|
8373
8515
|
return next;
|
|
8374
8516
|
});
|
|
8375
8517
|
}, []);
|
|
8376
|
-
const handleMarkForDeletion =
|
|
8518
|
+
const handleMarkForDeletion = useCallback13((fileId) => {
|
|
8377
8519
|
setPendingDeletions((prev) => [...prev, fileId]);
|
|
8378
8520
|
}, []);
|
|
8379
8521
|
const handleDeleteSelected = () => {
|
|
@@ -8602,7 +8744,7 @@ function TableBlockClient({
|
|
|
8602
8744
|
setIsSaving(false);
|
|
8603
8745
|
}
|
|
8604
8746
|
};
|
|
8605
|
-
const getRowRelationLabels =
|
|
8747
|
+
const getRowRelationLabels = useCallback13((rowVal, col) => {
|
|
8606
8748
|
const ids = normalizeRelationValue(rowVal);
|
|
8607
8749
|
if (ids.length === 0) return [];
|
|
8608
8750
|
const options = relationOptions[col.name] || [];
|
|
@@ -8621,7 +8763,7 @@ function TableBlockClient({
|
|
|
8621
8763
|
return "";
|
|
8622
8764
|
}).filter(Boolean);
|
|
8623
8765
|
}, [relationOptions]);
|
|
8624
|
-
const getUniqueRelationOptions =
|
|
8766
|
+
const getUniqueRelationOptions = useCallback13((col) => {
|
|
8625
8767
|
if (relationFilterOptions[col.name]) {
|
|
8626
8768
|
return relationFilterOptions[col.name];
|
|
8627
8769
|
}
|
|
@@ -9462,7 +9604,7 @@ function ExpandedSubTables({
|
|
|
9462
9604
|
) })
|
|
9463
9605
|
] }) });
|
|
9464
9606
|
}
|
|
9465
|
-
var TableRow =
|
|
9607
|
+
var TableRow = React15.memo(function TableRow2({
|
|
9466
9608
|
row,
|
|
9467
9609
|
isSelected,
|
|
9468
9610
|
rowStatus,
|
|
@@ -9495,7 +9637,7 @@ var TableRow = React14.memo(function TableRow2({
|
|
|
9495
9637
|
renderRowExtra
|
|
9496
9638
|
}) {
|
|
9497
9639
|
const lockedCopyTargets = getRelationCopyLockedTargets(schema == null ? void 0 : schema.columns);
|
|
9498
|
-
return /* @__PURE__ */ jsxs14(
|
|
9640
|
+
return /* @__PURE__ */ jsxs14(React15.Fragment, { children: [
|
|
9499
9641
|
/* @__PURE__ */ jsxs14("tr", { className: `transition-colors group hover:bg-blue-50 ${isSelected ? "bg-blue-50" : ""}`, children: [
|
|
9500
9642
|
/* @__PURE__ */ jsx17("td", { className: "border-b border-l border-slate-200 p-1.5 text-center bg-white group-hover:bg-transparent", style: { width: 80, minWidth: 80, maxWidth: 80 }, children: /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-center gap-1.5", children: [
|
|
9501
9643
|
rowStatus && (() => {
|
|
@@ -9647,7 +9789,7 @@ var TableRow = React14.memo(function TableRow2({
|
|
|
9647
9789
|
});
|
|
9648
9790
|
|
|
9649
9791
|
// src/components/TableBlock/formTracking/FormTrackingTableBlock.tsx
|
|
9650
|
-
import { useCallback as
|
|
9792
|
+
import { useCallback as useCallback14, useState as useState17 } from "react";
|
|
9651
9793
|
|
|
9652
9794
|
// src/components/TableBlock/formTracking/formTracking.types.ts
|
|
9653
9795
|
function getFormTrackingConfig(settings) {
|
|
@@ -9690,7 +9832,7 @@ function FormTrackingTableBlock(props) {
|
|
|
9690
9832
|
const tableId = (settings == null ? void 0 : settings.tableMetaId) || (settings == null ? void 0 : settings.tableId) || (settings == null ? void 0 : settings.id);
|
|
9691
9833
|
const [sentOverrides, setSentOverrides] = useState17({});
|
|
9692
9834
|
const [busyKey, setBusyKey] = useState17(null);
|
|
9693
|
-
const copyLink =
|
|
9835
|
+
const copyLink = useCallback14(
|
|
9694
9836
|
async (rowId, step) => {
|
|
9695
9837
|
if (!executeAction || !tableId) return;
|
|
9696
9838
|
setBusyKey(`${rowId}|${step.formId}|link`);
|
|
@@ -9716,7 +9858,7 @@ function FormTrackingTableBlock(props) {
|
|
|
9716
9858
|
},
|
|
9717
9859
|
[executeAction, tableId, addToast, showError]
|
|
9718
9860
|
);
|
|
9719
|
-
const setSent =
|
|
9861
|
+
const setSent = useCallback14(
|
|
9720
9862
|
async (rowId, step, value) => {
|
|
9721
9863
|
if (!executeAction || !tableId || !step.sentColumn) return;
|
|
9722
9864
|
setBusyKey(`${rowId}|${step.formId}|sent`);
|
|
@@ -9738,7 +9880,7 @@ function FormTrackingTableBlock(props) {
|
|
|
9738
9880
|
);
|
|
9739
9881
|
const firstFormStep = config == null ? void 0 : config.steps.find((s) => s.kind === "create");
|
|
9740
9882
|
const firstFormUrl = firstFormStep && tableId ? `${getPlatformOrigin()}/embed/form/${tableId}?form=${firstFormStep.formId}` : "";
|
|
9741
|
-
const copyFirstFormLink =
|
|
9883
|
+
const copyFirstFormLink = useCallback14(async () => {
|
|
9742
9884
|
if (!firstFormUrl) return;
|
|
9743
9885
|
try {
|
|
9744
9886
|
await navigator.clipboard.writeText(firstFormUrl);
|
|
@@ -9747,7 +9889,7 @@ function FormTrackingTableBlock(props) {
|
|
|
9747
9889
|
window.prompt(`\u05D4\u05E7\u05D9\u05E9\u05D5\u05E8 \u05DC"${firstFormStep == null ? void 0 : firstFormStep.label}" - \u05D4\u05E2\u05EA\u05E7 \u05D9\u05D3\u05E0\u05D9\u05EA:`, firstFormUrl);
|
|
9748
9890
|
}
|
|
9749
9891
|
}, [firstFormUrl, firstFormStep, addToast]);
|
|
9750
|
-
const renderRowExtra =
|
|
9892
|
+
const renderRowExtra = useCallback14(
|
|
9751
9893
|
(row) => {
|
|
9752
9894
|
var _a;
|
|
9753
9895
|
if (!config) return null;
|
|
@@ -9835,7 +9977,7 @@ function TableBlock(props) {
|
|
|
9835
9977
|
}
|
|
9836
9978
|
|
|
9837
9979
|
// src/components/PlacementBlock/PlacementBlock.tsx
|
|
9838
|
-
import { useState as useState18, useEffect as useEffect15, useRef as
|
|
9980
|
+
import { useState as useState18, useEffect as useEffect15, useRef as useRef16, useCallback as useCallback15, useMemo as useMemo10 } from "react";
|
|
9839
9981
|
import { AgGridReact } from "ag-grid-react";
|
|
9840
9982
|
import {
|
|
9841
9983
|
ModuleRegistry,
|
|
@@ -9844,7 +9986,7 @@ import {
|
|
|
9844
9986
|
import { Filter as Filter2 } from "lucide-react";
|
|
9845
9987
|
|
|
9846
9988
|
// src/components/PlacementBlock/PlacementSettings.tsx
|
|
9847
|
-
import
|
|
9989
|
+
import React17 from "react";
|
|
9848
9990
|
|
|
9849
9991
|
// src/components/PlacementBlock/placementColumns.ts
|
|
9850
9992
|
var RELATION_SEP = "::";
|
|
@@ -9966,7 +10108,7 @@ var SummaryRow = ({ label, value, hint }) => /* @__PURE__ */ jsxs16("div", { cla
|
|
|
9966
10108
|
] });
|
|
9967
10109
|
var PlacementStatusEditor = ({ config, onChange }) => {
|
|
9968
10110
|
var _a;
|
|
9969
|
-
const radioName = `placement-default-status-${
|
|
10111
|
+
const radioName = `placement-default-status-${React17.useId()}`;
|
|
9970
10112
|
const statuses = ((_a = config.statusColors) == null ? void 0 : _a.length) ? config.statusColors : DEFAULT_PLACEMENT_STATUS_COLORS;
|
|
9971
10113
|
const defaultStatusId = resolveDefaultStatusId(statuses, config.defaultReturnStatusId);
|
|
9972
10114
|
const setStatuses = (next, defId = defaultStatusId) => {
|
|
@@ -10449,7 +10591,7 @@ var CheckHeader = (props) => /* @__PURE__ */ jsx22("div", { className: "flex ite
|
|
|
10449
10591
|
}
|
|
10450
10592
|
) });
|
|
10451
10593
|
var RelationFilterHeader = (props) => {
|
|
10452
|
-
const btnRef =
|
|
10594
|
+
const btnRef = useRef16(null);
|
|
10453
10595
|
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col items-center justify-center w-full min-w-0 leading-tight select-none", title: props.displayName, children: [
|
|
10454
10596
|
/* @__PURE__ */ jsx22(
|
|
10455
10597
|
"button",
|
|
@@ -10497,9 +10639,9 @@ var PlacementBlock = (props) => {
|
|
|
10497
10639
|
const targetTableId = config == null ? void 0 : config.targetTableId;
|
|
10498
10640
|
const displayField = (config == null ? void 0 : config.sourceDisplayFieldId) || "name";
|
|
10499
10641
|
const assignmentField = config == null ? void 0 : config.targetAssignmentFieldId;
|
|
10500
|
-
const executeActionRef =
|
|
10642
|
+
const executeActionRef = useRef16(executeAction);
|
|
10501
10643
|
executeActionRef.current = executeAction;
|
|
10502
|
-
const legacyRef =
|
|
10644
|
+
const legacyRef = useRef16({ fetchSourceData, fetchTargetData, updateAssignment });
|
|
10503
10645
|
legacyRef.current = { fetchSourceData, fetchTargetData, updateAssignment };
|
|
10504
10646
|
const [sourceRows, setSourceRows] = useState18([]);
|
|
10505
10647
|
const [sourceColumns, setSourceColumns] = useState18([]);
|
|
@@ -10521,7 +10663,7 @@ var PlacementBlock = (props) => {
|
|
|
10521
10663
|
const [colFilters, setColFilters] = useState18({ source: {}, cand: {} });
|
|
10522
10664
|
const [filterPopover, setFilterPopover] = useState18(null);
|
|
10523
10665
|
const [targetFilters, setTargetFilters] = useState18({});
|
|
10524
|
-
const loadTable =
|
|
10666
|
+
const loadTable = useCallback15(async (tableId, kind) => {
|
|
10525
10667
|
const exec = executeActionRef.current;
|
|
10526
10668
|
if (exec) {
|
|
10527
10669
|
const res = await exec("FETCH_TABLE_DATA", { tableId, tableMetaId: tableId, limit: FETCH_LIMIT, skip: 0 });
|
|
@@ -10562,7 +10704,7 @@ var PlacementBlock = (props) => {
|
|
|
10562
10704
|
cancelled = true;
|
|
10563
10705
|
};
|
|
10564
10706
|
}, [sourceTableId, targetTableId, loadTable]);
|
|
10565
|
-
const displayValue =
|
|
10707
|
+
const displayValue = useCallback15((col, val) => {
|
|
10566
10708
|
var _a2, _b2, _c, _d, _e;
|
|
10567
10709
|
let text2 = cellText(val);
|
|
10568
10710
|
if (text2 && /^[a-fA-F0-9]{24}$/.test(text2)) {
|
|
@@ -10595,7 +10737,7 @@ var PlacementBlock = (props) => {
|
|
|
10595
10737
|
});
|
|
10596
10738
|
return maps;
|
|
10597
10739
|
}, [sourceRelOptions]);
|
|
10598
|
-
const relationLabelsOf =
|
|
10740
|
+
const relationLabelsOf = useCallback15((row, colName) => {
|
|
10599
10741
|
var _a2;
|
|
10600
10742
|
const map = relationLabelMaps[colName];
|
|
10601
10743
|
const ids = normalizeRelationValue((_a2 = row.data) == null ? void 0 : _a2[colName]);
|
|
@@ -10604,7 +10746,7 @@ var PlacementBlock = (props) => {
|
|
|
10604
10746
|
const txt = cellText(readColumnValue(row.data, colName));
|
|
10605
10747
|
return txt && !/^[a-fA-F0-9]{24}$/.test(txt) ? txt.split(", ").filter(Boolean) : [];
|
|
10606
10748
|
}, [relationLabelMaps]);
|
|
10607
|
-
const rowPassesColFilters =
|
|
10749
|
+
const rowPassesColFilters = useCallback15((row, filters) => {
|
|
10608
10750
|
return Object.entries(filters).every(([colName, f]) => {
|
|
10609
10751
|
if (!f) return true;
|
|
10610
10752
|
const labels = relationLabelsOf(row, colName);
|
|
@@ -10613,7 +10755,7 @@ var PlacementBlock = (props) => {
|
|
|
10613
10755
|
return true;
|
|
10614
10756
|
});
|
|
10615
10757
|
}, [relationLabelsOf]);
|
|
10616
|
-
const setColFilter =
|
|
10758
|
+
const setColFilter = useCallback15((grid, colName, payload) => {
|
|
10617
10759
|
setColFilters((prev) => {
|
|
10618
10760
|
const next = __spreadValues({}, prev[grid]);
|
|
10619
10761
|
if (payload === void 0) delete next[colName];
|
|
@@ -10621,10 +10763,10 @@ var PlacementBlock = (props) => {
|
|
|
10621
10763
|
return __spreadProps(__spreadValues({}, prev), { [grid]: next });
|
|
10622
10764
|
});
|
|
10623
10765
|
}, []);
|
|
10624
|
-
const openColFilter =
|
|
10766
|
+
const openColFilter = useCallback15((grid, colName, rect) => {
|
|
10625
10767
|
setFilterPopover((cur) => cur && cur.grid === grid && cur.colName === colName ? null : { grid, colName, rect });
|
|
10626
10768
|
}, []);
|
|
10627
|
-
const closeColFilter =
|
|
10769
|
+
const closeColFilter = useCallback15(() => setFilterPopover(null), []);
|
|
10628
10770
|
const filterColumns = useMemo10(() => {
|
|
10629
10771
|
const definedFilters = (config == null ? void 0 : config.filterFields) || [];
|
|
10630
10772
|
const legacyFilters = [config == null ? void 0 : config.targetFilterField1Id, config == null ? void 0 : config.targetFilterField2Id].filter(Boolean);
|
|
@@ -10679,7 +10821,7 @@ var PlacementBlock = (props) => {
|
|
|
10679
10821
|
setSelectedTargetId("");
|
|
10680
10822
|
}
|
|
10681
10823
|
}, [filteredTargetRows, selectedTargetId]);
|
|
10682
|
-
const appliedDefaultsKeyRef =
|
|
10824
|
+
const appliedDefaultsKeyRef = useRef16("");
|
|
10683
10825
|
useEffect15(() => {
|
|
10684
10826
|
const defaults = config == null ? void 0 : config.targetFilterDefaults;
|
|
10685
10827
|
if (isLoading || !defaults || targetRows.length === 0 || targetColumns.length === 0) return;
|
|
@@ -10698,7 +10840,7 @@ var PlacementBlock = (props) => {
|
|
|
10698
10840
|
const assignmentColumn = useMemo10(() => targetColumns.find((c) => c.name === assignmentField), [targetColumns, assignmentField]);
|
|
10699
10841
|
const isRelationField = ((_b = assignmentColumn == null ? void 0 : assignmentColumn.type) == null ? void 0 : _b.toUpperCase()) === "RELATION";
|
|
10700
10842
|
const assignmentLabel = (assignmentColumn == null ? void 0 : assignmentColumn.label) || (assignmentColumn == null ? void 0 : assignmentColumn.name) || assignmentField || "";
|
|
10701
|
-
const nameOf =
|
|
10843
|
+
const nameOf = useCallback15((row) => cellText(readColumnValue(row.data, displayField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD", [displayField]);
|
|
10702
10844
|
const assignedIds = useMemo10(() => {
|
|
10703
10845
|
var _a2;
|
|
10704
10846
|
const target = targetRows.find((r) => r.id === selectedTargetId);
|
|
@@ -10713,13 +10855,13 @@ var PlacementBlock = (props) => {
|
|
|
10713
10855
|
}).filter((id) => !!id && sourceRows.some((s) => s.id === id));
|
|
10714
10856
|
return Array.from(new Set(ids));
|
|
10715
10857
|
}, [selectedTargetId, targetRows, sourceRows, assignmentField, isRelationField, nameOf]);
|
|
10716
|
-
const assignedIdsRef =
|
|
10858
|
+
const assignedIdsRef = useRef16(assignedIds);
|
|
10717
10859
|
assignedIdsRef.current = assignedIds;
|
|
10718
10860
|
useEffect15(() => {
|
|
10719
10861
|
setCandidateIds(assignedIdsRef.current);
|
|
10720
10862
|
setCheckedIds(assignedIdsRef.current);
|
|
10721
10863
|
}, [selectedTargetId, sourceRows]);
|
|
10722
|
-
const toGridRow =
|
|
10864
|
+
const toGridRow = useCallback15((r, checked = false) => __spreadProps(__spreadValues({}, r.data), { id: r.id, __label: nameOf(r), __checked: checked, statusId: statusMap[r.id] || defaultStatusId }), [nameOf, statusMap, defaultStatusId]);
|
|
10723
10865
|
const candidateRows = useMemo10(() => candidateIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r), [candidateIds, sourceRows]);
|
|
10724
10866
|
const candidateGridData = useMemo10(() => {
|
|
10725
10867
|
const checked = new Set(checkedIds);
|
|
@@ -10734,7 +10876,7 @@ var PlacementBlock = (props) => {
|
|
|
10734
10876
|
return wanted.filter((name) => sourceColumns.some((c) => (c == null ? void 0 : c.name) === name && String(c == null ? void 0 : c.type).toUpperCase() === "RELATION"));
|
|
10735
10877
|
}, [config, sourceColumns]);
|
|
10736
10878
|
const hasRelationButtons = relationButtonColumns.length > 0;
|
|
10737
|
-
const handleRelationFilterChange =
|
|
10879
|
+
const handleRelationFilterChange = useCallback15((colName, id) => {
|
|
10738
10880
|
setSourceRelFilters((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: id }));
|
|
10739
10881
|
}, []);
|
|
10740
10882
|
const availableGridData = useMemo10(() => {
|
|
@@ -10742,7 +10884,7 @@ var PlacementBlock = (props) => {
|
|
|
10742
10884
|
const byButtons = active.length === 0 ? availableRows : availableRows.filter((r) => active.every(([name, v]) => rowMatchesRelationFilter(r, name, v)));
|
|
10743
10885
|
return byButtons.filter((r) => rowPassesColFilters(r, colFilters.source)).map((r) => toGridRow(r));
|
|
10744
10886
|
}, [availableRows, sourceRelFilters, relationButtonColumns, toGridRow, rowPassesColFilters, colFilters.source]);
|
|
10745
|
-
const persistAssignment =
|
|
10887
|
+
const persistAssignment = useCallback15(async (nextIds) => {
|
|
10746
10888
|
const exec = executeActionRef.current;
|
|
10747
10889
|
if (exec && targetTableId && assignmentField && selectedTargetId) {
|
|
10748
10890
|
const value = isRelationField ? nextIds : nextIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r).map(nameOf).join(", ");
|
|
@@ -10754,33 +10896,33 @@ var PlacementBlock = (props) => {
|
|
|
10754
10896
|
for (const id of nextIds.filter((i) => !assignedIds.includes(i))) await legacyRef.current.updateAssignment(selectedTargetId, id);
|
|
10755
10897
|
}
|
|
10756
10898
|
}, [targetTableId, assignmentField, selectedTargetId, isRelationField, sourceRows, nameOf, assignedIds]);
|
|
10757
|
-
const moveToCandidates =
|
|
10899
|
+
const moveToCandidates = useCallback15((id) => {
|
|
10758
10900
|
setCandidateIds((prev) => prev.includes(id) ? prev : [...prev, id]);
|
|
10759
10901
|
}, []);
|
|
10760
|
-
const moveToSource =
|
|
10902
|
+
const moveToSource = useCallback15((id) => {
|
|
10761
10903
|
setCandidateIds((prev) => prev.filter((x) => x !== id));
|
|
10762
10904
|
setCheckedIds((prev) => prev.filter((x) => x !== id));
|
|
10763
10905
|
setStatusMap((prev) => __spreadProps(__spreadValues({}, prev), { [id]: defaultStatusId }));
|
|
10764
10906
|
}, [defaultStatusId]);
|
|
10765
|
-
const moveToCandidatesRef =
|
|
10907
|
+
const moveToCandidatesRef = useRef16(moveToCandidates);
|
|
10766
10908
|
moveToCandidatesRef.current = moveToCandidates;
|
|
10767
|
-
const moveToSourceRef =
|
|
10909
|
+
const moveToSourceRef = useRef16(moveToSource);
|
|
10768
10910
|
moveToSourceRef.current = moveToSource;
|
|
10769
|
-
const toggleChecked =
|
|
10911
|
+
const toggleChecked = useCallback15((id) => {
|
|
10770
10912
|
setCheckedIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]);
|
|
10771
10913
|
}, []);
|
|
10772
10914
|
const allChecked = candidateIds.length > 0 && candidateIds.every((id) => checkedIds.includes(id));
|
|
10773
10915
|
const someChecked = candidateIds.some((id) => checkedIds.includes(id));
|
|
10774
|
-
const toggleAll =
|
|
10916
|
+
const toggleAll = useCallback15(() => {
|
|
10775
10917
|
setCheckedIds(allChecked ? [] : [...candidateIds]);
|
|
10776
10918
|
}, [allChecked, candidateIds]);
|
|
10777
|
-
const returnAll =
|
|
10919
|
+
const returnAll = useCallback15(() => {
|
|
10778
10920
|
setCandidateIds([]);
|
|
10779
10921
|
setCheckedIds([]);
|
|
10780
10922
|
}, []);
|
|
10781
10923
|
const checkedCandidates = useMemo10(() => candidateIds.filter((id) => checkedIds.includes(id)), [candidateIds, checkedIds]);
|
|
10782
10924
|
const isDirty = checkedCandidates.length !== assignedIds.length || checkedCandidates.some((id) => !assignedIds.includes(id));
|
|
10783
|
-
const submitAssignment =
|
|
10925
|
+
const submitAssignment = useCallback15(async () => {
|
|
10784
10926
|
if (!selectedTargetId) {
|
|
10785
10927
|
alert("\u05D0\u05E0\u05D0 \u05D1\u05D7\u05E8 \u05E7\u05D5\u05D3\u05DD \u05E8\u05E9\u05D5\u05DE\u05EA \u05D9\u05E2\u05D3 \u05DC\u05E4\u05E0\u05D9 \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5");
|
|
10786
10928
|
return;
|
|
@@ -10796,14 +10938,14 @@ var PlacementBlock = (props) => {
|
|
|
10796
10938
|
setIsSaving(false);
|
|
10797
10939
|
}
|
|
10798
10940
|
}, [selectedTargetId, persistAssignment, checkedCandidates]);
|
|
10799
|
-
const cycleStatus =
|
|
10941
|
+
const cycleStatus = useCallback15((recordId) => {
|
|
10800
10942
|
setStatusMap((prev) => {
|
|
10801
10943
|
const current = prev[recordId] || defaultStatusId;
|
|
10802
10944
|
const idx = statuses.findIndex((c) => c.id === current);
|
|
10803
10945
|
return __spreadProps(__spreadValues({}, prev), { [recordId]: statuses[(idx + 1) % statuses.length].id });
|
|
10804
10946
|
});
|
|
10805
10947
|
}, [statuses, defaultStatusId]);
|
|
10806
|
-
const cancelAssignment =
|
|
10948
|
+
const cancelAssignment = useCallback15(async () => {
|
|
10807
10949
|
if (!selectedTargetId || assignedIds.length === 0) return;
|
|
10808
10950
|
if (!window.confirm(`\u05DC\u05D1\u05D8\u05DC \u05D0\u05EA \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5 \u05D5\u05DC\u05DE\u05D7\u05D5\u05E7 \u05D0\u05EA \u05D4\u05E0\u05EA\u05D5\u05DF \u05DE\u05E9\u05D3\u05D4 "${assignmentLabel}"?`)) return;
|
|
10809
10951
|
const removed = new Set(assignedIds);
|
|
@@ -10819,7 +10961,7 @@ var PlacementBlock = (props) => {
|
|
|
10819
10961
|
setIsSaving(false);
|
|
10820
10962
|
}
|
|
10821
10963
|
}, [selectedTargetId, assignedIds, assignmentLabel, persistAssignment]);
|
|
10822
|
-
const makeColDefs =
|
|
10964
|
+
const makeColDefs = useCallback15((columns, fallbackName, grid, withCheckbox = false) => {
|
|
10823
10965
|
const gridFilters = colFilters[grid];
|
|
10824
10966
|
const defs = [];
|
|
10825
10967
|
if (withCheckbox) {
|
|
@@ -10871,10 +11013,10 @@ var PlacementBlock = (props) => {
|
|
|
10871
11013
|
var _a2;
|
|
10872
11014
|
return (_a2 = d.colId) != null ? _a2 : d.field;
|
|
10873
11015
|
}).filter(Boolean);
|
|
10874
|
-
const expandColumns =
|
|
11016
|
+
const expandColumns = useCallback15((api) => {
|
|
10875
11017
|
api == null ? void 0 : api.sizeColumnsToFit();
|
|
10876
11018
|
}, []);
|
|
10877
|
-
const shrinkColumns =
|
|
11019
|
+
const shrinkColumns = useCallback15((api, defs) => {
|
|
10878
11020
|
api == null ? void 0 : api.autoSizeColumns(scrollableColIds(defs));
|
|
10879
11021
|
}, []);
|
|
10880
11022
|
const popoverOptions = useMemo10(() => {
|
|
@@ -10888,9 +11030,9 @@ var PlacementBlock = (props) => {
|
|
|
10888
11030
|
() => filterPopover ? sourceColumns.find((c) => c.name === filterPopover.colName) : void 0,
|
|
10889
11031
|
[filterPopover, sourceColumns]
|
|
10890
11032
|
);
|
|
10891
|
-
const getRowId =
|
|
10892
|
-
const sourceContainerRef =
|
|
10893
|
-
const assignedContainerRef =
|
|
11033
|
+
const getRowId = useCallback15((p) => p.data.id, []);
|
|
11034
|
+
const sourceContainerRef = useRef16(null);
|
|
11035
|
+
const assignedContainerRef = useRef16(null);
|
|
10894
11036
|
const [sourceApi, setSourceApi] = useState18(null);
|
|
10895
11037
|
const [assignedApi, setAssignedApi] = useState18(null);
|
|
10896
11038
|
useEffect15(() => {
|
|
@@ -10925,7 +11067,7 @@ var PlacementBlock = (props) => {
|
|
|
10925
11067
|
[assignedIds, sourceRows, nameOf]
|
|
10926
11068
|
);
|
|
10927
11069
|
const activeTarget = targetRows.find((r) => r.id === selectedTargetId);
|
|
10928
|
-
const targetLabel =
|
|
11070
|
+
const targetLabel = useCallback15((r) => {
|
|
10929
11071
|
const col = targetColumns.find((c) => c.name === selectorField || c.id === selectorField);
|
|
10930
11072
|
return displayValue(col || { name: selectorField }, readColumnValue(r.data, selectorField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD";
|
|
10931
11073
|
}, [selectorField, targetColumns, displayValue]);
|
|
@@ -11092,7 +11234,7 @@ var PlacementBlock = (props) => {
|
|
|
11092
11234
|
};
|
|
11093
11235
|
|
|
11094
11236
|
// src/components/PaymentReportsBlock/PaymentReportsBlock.tsx
|
|
11095
|
-
import { useCallback as
|
|
11237
|
+
import { useCallback as useCallback17, useEffect as useEffect16, useMemo as useMemo14, useRef as useRef19, useState as useState23 } from "react";
|
|
11096
11238
|
|
|
11097
11239
|
// src/components/PaymentReportsBlock/PaymentReportsBlock.types.ts
|
|
11098
11240
|
var PAYMENT_REPORTS_REQUIRED = [
|
|
@@ -11291,7 +11433,7 @@ function displayCell(item, col, relationOptions, symbol) {
|
|
|
11291
11433
|
}
|
|
11292
11434
|
|
|
11293
11435
|
// src/components/PaymentReportsBlock/UnpaidReportsTab.tsx
|
|
11294
|
-
import { useMemo as useMemo11, useRef as
|
|
11436
|
+
import { useMemo as useMemo11, useRef as useRef17, useState as useState20 } from "react";
|
|
11295
11437
|
import { AgGridReact as AgGridReact2 } from "ag-grid-react";
|
|
11296
11438
|
import { ModuleRegistry as ModuleRegistry2, AllCommunityModule as AllCommunityModule2 } from "ag-grid-community";
|
|
11297
11439
|
|
|
@@ -11351,7 +11493,7 @@ var ConfirmModal = ({ title, message, confirmLabel, danger, busy, onConfirm, onC
|
|
|
11351
11493
|
);
|
|
11352
11494
|
|
|
11353
11495
|
// src/components/PaymentReportsBlock/useGridColumnWidths.ts
|
|
11354
|
-
import { useCallback as
|
|
11496
|
+
import { useCallback as useCallback16, useState as useState19 } from "react";
|
|
11355
11497
|
function useGridColumnWidths(storageKey) {
|
|
11356
11498
|
const [widths, setWidths] = useState19(() => {
|
|
11357
11499
|
if (typeof window === "undefined") return {};
|
|
@@ -11361,7 +11503,7 @@ function useGridColumnWidths(storageKey) {
|
|
|
11361
11503
|
return {};
|
|
11362
11504
|
}
|
|
11363
11505
|
});
|
|
11364
|
-
const onColumnResized =
|
|
11506
|
+
const onColumnResized = useCallback16(
|
|
11365
11507
|
(e) => {
|
|
11366
11508
|
var _a;
|
|
11367
11509
|
if (!e.finished || e.source !== "uiColumnResized" || !((_a = e.columns) == null ? void 0 : _a.length)) return;
|
|
@@ -11377,7 +11519,7 @@ function useGridColumnWidths(storageKey) {
|
|
|
11377
11519
|
},
|
|
11378
11520
|
[storageKey]
|
|
11379
11521
|
);
|
|
11380
|
-
const applyWidths =
|
|
11522
|
+
const applyWidths = useCallback16(
|
|
11381
11523
|
(defs) => defs.map((d) => {
|
|
11382
11524
|
const w = d.colId ? widths[d.colId] : void 0;
|
|
11383
11525
|
return w ? __spreadProps(__spreadValues({}, d), { width: w, flex: 0 }) : d;
|
|
@@ -11419,7 +11561,7 @@ var UnpaidReportsTab = ({
|
|
|
11419
11561
|
handlers
|
|
11420
11562
|
}) => {
|
|
11421
11563
|
var _a;
|
|
11422
|
-
const apiRef =
|
|
11564
|
+
const apiRef = useRef17(null);
|
|
11423
11565
|
const { onColumnResized, applyWidths } = useGridColumnWidths(`payment-reports:${config.reportsTableId}:unpaid`);
|
|
11424
11566
|
const [selectedIds, setSelectedIds] = useState20([]);
|
|
11425
11567
|
const [confirmOpen, setConfirmOpen] = useState20(false);
|
|
@@ -11621,10 +11763,10 @@ import { AgGridReact as AgGridReact3 } from "ag-grid-react";
|
|
|
11621
11763
|
import { ModuleRegistry as ModuleRegistry3, AllCommunityModule as AllCommunityModule3 } from "ag-grid-community";
|
|
11622
11764
|
|
|
11623
11765
|
// src/components/PaymentReportsBlock/ProofCell.tsx
|
|
11624
|
-
import { useRef as
|
|
11766
|
+
import { useRef as useRef18, useState as useState21 } from "react";
|
|
11625
11767
|
import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
11626
11768
|
var ProofCell = ({ files, editable, onUpload, onRemove }) => {
|
|
11627
|
-
const inputRef =
|
|
11769
|
+
const inputRef = useRef18(null);
|
|
11628
11770
|
const [busy, setBusy] = useState21(false);
|
|
11629
11771
|
const file = files[0];
|
|
11630
11772
|
const href = (file == null ? void 0 : file.fileUrl) || (file == null ? void 0 : file.url);
|
|
@@ -12058,9 +12200,9 @@ var PaymentReportsBlock = (props) => {
|
|
|
12058
12200
|
const [details, setDetails] = useState23(null);
|
|
12059
12201
|
const [confirm, setConfirm] = useState23(null);
|
|
12060
12202
|
const [confirmBusy, setConfirmBusy] = useState23(false);
|
|
12061
|
-
const toastOk =
|
|
12062
|
-
const toastErr =
|
|
12063
|
-
const load =
|
|
12203
|
+
const toastOk = useCallback17((message) => addToast({ type: "success", message }), [addToast]);
|
|
12204
|
+
const toastErr = useCallback17((e) => addToast({ type: "error", message: (e == null ? void 0 : e.message) || String(e) }), [addToast]);
|
|
12205
|
+
const load = useCallback17(
|
|
12064
12206
|
async (silent = false) => {
|
|
12065
12207
|
if (!config || missing.length) return;
|
|
12066
12208
|
if (!silent) setLoading(true);
|
|
@@ -12114,7 +12256,7 @@ var PaymentReportsBlock = (props) => {
|
|
|
12114
12256
|
return m;
|
|
12115
12257
|
}, [model.payments, symbol]);
|
|
12116
12258
|
const base = { reportsTableId: config == null ? void 0 : config.reportsTableId, paymentsTableId: config == null ? void 0 : config.paymentsTableId };
|
|
12117
|
-
const handlers =
|
|
12259
|
+
const handlers = useRef19(null);
|
|
12118
12260
|
handlers.current = {
|
|
12119
12261
|
onPay: async (reportIds) => {
|
|
12120
12262
|
var _a;
|
|
@@ -12304,11 +12446,11 @@ var PaymentReportsBlock = (props) => {
|
|
|
12304
12446
|
};
|
|
12305
12447
|
|
|
12306
12448
|
// src/components/WhatsAppComponent/WhatsAppComponent.tsx
|
|
12307
|
-
import
|
|
12449
|
+
import React28 from "react";
|
|
12308
12450
|
import { CheckCircle2 as CheckCircle24, AlertCircle as AlertCircle5, X as X12, Loader2 as Loader28, Phone as Phone4, Send as Send3, Image as ImageIcon3, FileText as FileText4, Video as Video3 } from "lucide-react";
|
|
12309
12451
|
|
|
12310
12452
|
// src/components/WhatsAppComponent/CreateTemplateModal.tsx
|
|
12311
|
-
import { useState as useState24, useEffect as useEffect17, useRef as
|
|
12453
|
+
import { useState as useState24, useEffect as useEffect17, useRef as useRef20, useMemo as useMemo15 } from "react";
|
|
12312
12454
|
import {
|
|
12313
12455
|
X as X9,
|
|
12314
12456
|
Plus,
|
|
@@ -12471,14 +12613,14 @@ function CreateTemplateModal({
|
|
|
12471
12613
|
const [fileBase64, setFileBase64] = useState24("");
|
|
12472
12614
|
const [buttons, setButtons] = useState24([]);
|
|
12473
12615
|
const [isAddButtonOpen, setIsAddButtonOpen] = useState24(false);
|
|
12474
|
-
const addButtonDropdownRef =
|
|
12616
|
+
const addButtonDropdownRef = useRef20(null);
|
|
12475
12617
|
const [isSubmitting, setIsSubmitting] = useState24(false);
|
|
12476
12618
|
const [submittingStep, setSubmittingStep] = useState24("");
|
|
12477
12619
|
const [submitError, setSubmitError] = useState24(null);
|
|
12478
12620
|
const [fileError, setFileError] = useState24(null);
|
|
12479
|
-
const textareaRef =
|
|
12480
|
-
const fileInputRef =
|
|
12481
|
-
const emojiPickerRef =
|
|
12621
|
+
const textareaRef = useRef20(null);
|
|
12622
|
+
const fileInputRef = useRef20(null);
|
|
12623
|
+
const emojiPickerRef = useRef20(null);
|
|
12482
12624
|
const [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState24(false);
|
|
12483
12625
|
useEffect17(() => {
|
|
12484
12626
|
function handleClickOutside(event) {
|
|
@@ -13543,7 +13685,7 @@ function CreateTemplateModal({
|
|
|
13543
13685
|
}
|
|
13544
13686
|
|
|
13545
13687
|
// src/components/WhatsAppComponent/hooks/useWhatsAppState.ts
|
|
13546
|
-
import { useState as useState25, useEffect as useEffect18, useRef as
|
|
13688
|
+
import { useState as useState25, useEffect as useEffect18, useRef as useRef21, useMemo as useMemo16, useCallback as useCallback18 } from "react";
|
|
13547
13689
|
|
|
13548
13690
|
// src/components/WhatsAppComponent/utils/recipientEngine.ts
|
|
13549
13691
|
var STORAGE_KEY_TEST_PHONE = "whatsapp_test_phone";
|
|
@@ -14865,12 +15007,12 @@ function useWhatsAppState(props) {
|
|
|
14865
15007
|
const [filters, setFilters] = useState25({});
|
|
14866
15008
|
const [selectedRowIds, setSelectedRowIds] = useState25([]);
|
|
14867
15009
|
const [autoSelectCount, setAutoSelectCount] = useState25(null);
|
|
14868
|
-
const isAutoSelectingRef =
|
|
14869
|
-
const isManualOverrideRef =
|
|
14870
|
-
const prevAutoSelectCountRef =
|
|
14871
|
-
const fetchedTableIdsRef =
|
|
14872
|
-
const fullyFetchedRelationKeysRef =
|
|
14873
|
-
const loadTableData =
|
|
15010
|
+
const isAutoSelectingRef = useRef21(false);
|
|
15011
|
+
const isManualOverrideRef = useRef21(false);
|
|
15012
|
+
const prevAutoSelectCountRef = useRef21(null);
|
|
15013
|
+
const fetchedTableIdsRef = useRef21(/* @__PURE__ */ new Set());
|
|
15014
|
+
const fullyFetchedRelationKeysRef = useRef21(/* @__PURE__ */ new Set());
|
|
15015
|
+
const loadTableData = useCallback18(async () => {
|
|
14874
15016
|
var _a2;
|
|
14875
15017
|
const tableId = (settings == null ? void 0 : settings.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableId);
|
|
14876
15018
|
if (!tableId || !executeAction) return;
|
|
@@ -15134,10 +15276,10 @@ function useWhatsAppState(props) {
|
|
|
15134
15276
|
});
|
|
15135
15277
|
const [broadcastSummary, setBroadcastSummary] = useState25(null);
|
|
15136
15278
|
const [rowStatusMap, setRowStatusMap] = useState25({});
|
|
15137
|
-
const clearBroadcastSummary =
|
|
15279
|
+
const clearBroadcastSummary = useCallback18(() => {
|
|
15138
15280
|
setBroadcastSummary(null);
|
|
15139
15281
|
}, []);
|
|
15140
|
-
const handleTestPhoneChange =
|
|
15282
|
+
const handleTestPhoneChange = useCallback18((val) => {
|
|
15141
15283
|
setTestPhoneNumber(val);
|
|
15142
15284
|
if (typeof window !== "undefined") {
|
|
15143
15285
|
try {
|
|
@@ -15147,7 +15289,7 @@ function useWhatsAppState(props) {
|
|
|
15147
15289
|
}
|
|
15148
15290
|
}
|
|
15149
15291
|
}, []);
|
|
15150
|
-
const getRelationOptionsForCol =
|
|
15292
|
+
const getRelationOptionsForCol = useCallback18(
|
|
15151
15293
|
(colName, parentColName) => {
|
|
15152
15294
|
var _a2, _b2, _c, _d;
|
|
15153
15295
|
if (parentColName) {
|
|
@@ -15438,7 +15580,7 @@ function useWhatsAppState(props) {
|
|
|
15438
15580
|
isManualOverrideRef.current = false;
|
|
15439
15581
|
prevAutoSelectCountRef.current = autoSelectCount;
|
|
15440
15582
|
}, [autoSelectCount, filteredData]);
|
|
15441
|
-
const embeddedTableExecuteAction =
|
|
15583
|
+
const embeddedTableExecuteAction = useCallback18(async (actionType, payload) => {
|
|
15442
15584
|
if (actionType === "FETCH_TABLE_DATA") {
|
|
15443
15585
|
const colFilters = (payload == null ? void 0 : payload.columnFilters) || (payload == null ? void 0 : payload.filters);
|
|
15444
15586
|
const searchQuery = payload == null ? void 0 : payload.search;
|
|
@@ -15484,7 +15626,7 @@ function useWhatsAppState(props) {
|
|
|
15484
15626
|
const activeFiltersCount = useMemo16(() => {
|
|
15485
15627
|
return Object.values(filters).filter((v) => v !== "").length;
|
|
15486
15628
|
}, [filters]);
|
|
15487
|
-
const handleSelectionChange =
|
|
15629
|
+
const handleSelectionChange = useCallback18((selectedIds) => {
|
|
15488
15630
|
setSelectedRowIds((prev) => {
|
|
15489
15631
|
if (prev.length === selectedIds.length && prev.every((id, idx) => id === selectedIds[idx])) {
|
|
15490
15632
|
return prev;
|
|
@@ -15498,13 +15640,13 @@ function useWhatsAppState(props) {
|
|
|
15498
15640
|
return selectedIds;
|
|
15499
15641
|
});
|
|
15500
15642
|
}, [autoSelectCount]);
|
|
15501
|
-
const handleRowToggle =
|
|
15643
|
+
const handleRowToggle = useCallback18((rowId, checked) => {
|
|
15502
15644
|
if (autoSelectCount !== null && autoSelectCount > 0) {
|
|
15503
15645
|
isManualOverrideRef.current = true;
|
|
15504
15646
|
setAutoSelectCount(null);
|
|
15505
15647
|
}
|
|
15506
15648
|
}, [autoSelectCount]);
|
|
15507
|
-
const toggleRowSelection =
|
|
15649
|
+
const toggleRowSelection = useCallback18((rowId, checked) => {
|
|
15508
15650
|
if (autoSelectCount !== null && autoSelectCount > 0) {
|
|
15509
15651
|
isManualOverrideRef.current = true;
|
|
15510
15652
|
setAutoSelectCount(null);
|
|
@@ -15528,7 +15670,7 @@ function useWhatsAppState(props) {
|
|
|
15528
15670
|
const [isDropdownOpen, setIsDropdownOpen] = useState25(false);
|
|
15529
15671
|
const [isDeleting, setIsDeleting] = useState25(false);
|
|
15530
15672
|
const [feedback, setFeedback] = useState25(null);
|
|
15531
|
-
const loadTemplates =
|
|
15673
|
+
const loadTemplates = useCallback18(async () => {
|
|
15532
15674
|
var _a2, _b2;
|
|
15533
15675
|
if (!executeAction) {
|
|
15534
15676
|
setIsLoading(false);
|
|
@@ -15623,7 +15765,7 @@ function useWhatsAppState(props) {
|
|
|
15623
15765
|
setHeaderMediaUrl("");
|
|
15624
15766
|
}
|
|
15625
15767
|
}, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
|
|
15626
|
-
const handleHeaderMediaUrlChange =
|
|
15768
|
+
const handleHeaderMediaUrlChange = useCallback18(
|
|
15627
15769
|
(newUrl) => {
|
|
15628
15770
|
setHeaderMediaUrl(newUrl);
|
|
15629
15771
|
if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
|
|
@@ -15642,7 +15784,7 @@ function useWhatsAppState(props) {
|
|
|
15642
15784
|
},
|
|
15643
15785
|
[selectedTemplate == null ? void 0 : selectedTemplate.name]
|
|
15644
15786
|
);
|
|
15645
|
-
const handleResetHeaderMediaUrl =
|
|
15787
|
+
const handleResetHeaderMediaUrl = useCallback18(() => {
|
|
15646
15788
|
if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
|
|
15647
15789
|
try {
|
|
15648
15790
|
localStorage.removeItem(`whatsapp_template_media_${selectedTemplate.name}`);
|
|
@@ -15657,7 +15799,7 @@ function useWhatsAppState(props) {
|
|
|
15657
15799
|
setHeaderMediaUrl(defaultUrl || "");
|
|
15658
15800
|
}, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
|
|
15659
15801
|
const [isUploadingMedia, setIsUploadingMedia] = useState25(false);
|
|
15660
|
-
const handleFileUpload =
|
|
15802
|
+
const handleFileUpload = useCallback18(
|
|
15661
15803
|
async (file, templateName) => {
|
|
15662
15804
|
const tplName = templateName || (selectedTemplate == null ? void 0 : selectedTemplate.name) || "";
|
|
15663
15805
|
if (!file) return;
|
|
@@ -15914,7 +16056,7 @@ function useWhatsAppState(props) {
|
|
|
15914
16056
|
setIsSendingTest(false);
|
|
15915
16057
|
}
|
|
15916
16058
|
};
|
|
15917
|
-
const handleSendMessages =
|
|
16059
|
+
const handleSendMessages = useCallback18(async () => {
|
|
15918
16060
|
var _a2, _b2;
|
|
15919
16061
|
if (isSendDisabled || isSendingBroadcast) return;
|
|
15920
16062
|
const recipients = preparedRecipients;
|
|
@@ -16220,7 +16362,7 @@ function useWhatsAppState(props) {
|
|
|
16220
16362
|
}
|
|
16221
16363
|
|
|
16222
16364
|
// src/components/WhatsAppComponent/ui/TemplateSelectionBlock.tsx
|
|
16223
|
-
import { useRef as
|
|
16365
|
+
import { useRef as useRef22 } from "react";
|
|
16224
16366
|
import {
|
|
16225
16367
|
FileText as FileText3,
|
|
16226
16368
|
Trash2 as Trash23,
|
|
@@ -16263,7 +16405,7 @@ function TemplateSelectionBlock({
|
|
|
16263
16405
|
isUploadingMedia = false,
|
|
16264
16406
|
handleFileUpload
|
|
16265
16407
|
}) {
|
|
16266
|
-
const fileInputRef =
|
|
16408
|
+
const fileInputRef = useRef22(null);
|
|
16267
16409
|
return /* @__PURE__ */ jsxs27("div", { className: "col-span-12 lg:col-span-5 min-h-[26rem] h-full flex flex-col bg-slate-50/70 border border-slate-200 rounded-2xl p-3.5 relative", children: [
|
|
16268
16410
|
/* @__PURE__ */ jsxs27("div", { className: "space-y-1.5 shrink-0", children: [
|
|
16269
16411
|
/* @__PURE__ */ jsxs27("div", { className: "flex items-center justify-between pb-1.5 border-b border-slate-200/70 shrink-0 gap-2", children: [
|
|
@@ -17230,7 +17372,7 @@ function SettingsAndActionsBlock({
|
|
|
17230
17372
|
}
|
|
17231
17373
|
|
|
17232
17374
|
// src/components/WhatsAppComponent/inbox/useInboxState.ts
|
|
17233
|
-
import { useState as useState26, useEffect as useEffect19, useCallback as
|
|
17375
|
+
import { useState as useState26, useEffect as useEffect19, useCallback as useCallback19, useRef as useRef23 } from "react";
|
|
17234
17376
|
function useInboxState(orgId, actions) {
|
|
17235
17377
|
const [conversations, setConversations] = useState26([]);
|
|
17236
17378
|
const [activeConversationId, setActiveConversationId] = useState26(null);
|
|
@@ -17238,11 +17380,11 @@ function useInboxState(orgId, actions) {
|
|
|
17238
17380
|
const [isLoading, setIsLoading] = useState26(false);
|
|
17239
17381
|
const [isSending, setIsSending] = useState26(false);
|
|
17240
17382
|
const [error, setError] = useState26(null);
|
|
17241
|
-
const actionsRef =
|
|
17383
|
+
const actionsRef = useRef23(actions);
|
|
17242
17384
|
useEffect19(() => {
|
|
17243
17385
|
actionsRef.current = actions;
|
|
17244
17386
|
});
|
|
17245
|
-
const fetchConversations =
|
|
17387
|
+
const fetchConversations = useCallback19(async () => {
|
|
17246
17388
|
if (!orgId) return;
|
|
17247
17389
|
const res = await actionsRef.current.getConversations(orgId);
|
|
17248
17390
|
if (res.success && res.data) {
|
|
@@ -17251,7 +17393,7 @@ function useInboxState(orgId, actions) {
|
|
|
17251
17393
|
setError(res.error);
|
|
17252
17394
|
}
|
|
17253
17395
|
}, [orgId]);
|
|
17254
|
-
const fetchMessages =
|
|
17396
|
+
const fetchMessages = useCallback19(async (conversationId, silent = false) => {
|
|
17255
17397
|
if (!silent) setIsLoading(true);
|
|
17256
17398
|
const res = await actionsRef.current.getMessages(conversationId);
|
|
17257
17399
|
if (res.success && res.data) {
|
|
@@ -17363,12 +17505,12 @@ function ConversationList({ conversations, activeId, onSelect }) {
|
|
|
17363
17505
|
}
|
|
17364
17506
|
|
|
17365
17507
|
// src/components/WhatsAppComponent/inbox/ChatWindow.tsx
|
|
17366
|
-
import { useState as useState27, useRef as
|
|
17508
|
+
import { useState as useState27, useRef as useRef24, useEffect as useEffect20 } from "react";
|
|
17367
17509
|
import { Send as Send2, User as User2, Loader2 as Loader27 } from "lucide-react";
|
|
17368
17510
|
import { jsx as jsx37, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
17369
17511
|
function ChatWindow({ activeConversation, messages, isLoading, isSending, onSendMessage }) {
|
|
17370
17512
|
const [inputText, setInputText] = useState27("");
|
|
17371
|
-
const messagesTopRef =
|
|
17513
|
+
const messagesTopRef = useRef24(null);
|
|
17372
17514
|
const scrollToTop = () => {
|
|
17373
17515
|
var _a;
|
|
17374
17516
|
(_a = messagesTopRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
|
|
@@ -17489,7 +17631,7 @@ function WhatsAppComponent(props) {
|
|
|
17489
17631
|
var _a;
|
|
17490
17632
|
const { className = "", settings, orgId, componentId, executeAction } = props;
|
|
17491
17633
|
const state = useWhatsAppState(props);
|
|
17492
|
-
const [activeTab, setActiveTab] =
|
|
17634
|
+
const [activeTab, setActiveTab] = React28.useState("broadcast");
|
|
17493
17635
|
return /* @__PURE__ */ jsxs33(
|
|
17494
17636
|
"div",
|
|
17495
17637
|
{
|
|
@@ -17899,7 +18041,7 @@ import { Loader2 as Loader29, CheckCircle2 as CheckCircle25 } from "lucide-react
|
|
|
17899
18041
|
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
17900
18042
|
|
|
17901
18043
|
// src/components/FormBlock/StyledFormBlock.tsx
|
|
17902
|
-
import { useState as useState29, useEffect as useEffect22, useId, useRef as
|
|
18044
|
+
import { useState as useState29, useEffect as useEffect22, useId, useRef as useRef25 } from "react";
|
|
17903
18045
|
import { Loader2 as Loader210, CheckCircle2 as CheckCircle26 } from "lucide-react";
|
|
17904
18046
|
|
|
17905
18047
|
// src/components/FormBlock/formDesign.ts
|
|
@@ -18166,16 +18308,16 @@ function StyledFormBlock({
|
|
|
18166
18308
|
const [isSubmitted, setIsSubmitted] = useState29(false);
|
|
18167
18309
|
const [formError, setFormError] = useState29(null);
|
|
18168
18310
|
const [missingNames, setMissingNames] = useState29([]);
|
|
18169
|
-
const errorRef =
|
|
18311
|
+
const errorRef = useRef25(null);
|
|
18170
18312
|
const [columns, setColumns] = useState29((schema == null ? void 0 : schema.columns) || []);
|
|
18171
18313
|
const [isLoadingSchema, setIsLoadingSchema] = useState29(false);
|
|
18172
18314
|
const [dragName, setDragName] = useState29(null);
|
|
18173
18315
|
const [drop, setDrop] = useState29(null);
|
|
18174
18316
|
const [resizing, setResizing] = useState29(null);
|
|
18175
|
-
const resizeRef =
|
|
18176
|
-
const gridRef =
|
|
18177
|
-
const relationDictRef =
|
|
18178
|
-
const relationRequestedRef =
|
|
18317
|
+
const resizeRef = useRef25(null);
|
|
18318
|
+
const gridRef = useRef25(null);
|
|
18319
|
+
const relationDictRef = useRef25({});
|
|
18320
|
+
const relationRequestedRef = useRef25(/* @__PURE__ */ new Set());
|
|
18179
18321
|
const [, bumpRelationLabels] = useState29(0);
|
|
18180
18322
|
const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
|
|
18181
18323
|
useEffect22(() => {
|
|
@@ -18756,7 +18898,7 @@ function StyledFormBlock({
|
|
|
18756
18898
|
}
|
|
18757
18899
|
|
|
18758
18900
|
// src/themes/ThemeScope.tsx
|
|
18759
|
-
import * as
|
|
18901
|
+
import * as React31 from "react";
|
|
18760
18902
|
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
18761
18903
|
var UNIVERSE_THEME_IDS = ["classic", "clean", "ocean", "warm"];
|
|
18762
18904
|
function resolveUniverseTheme(value) {
|
|
@@ -18767,7 +18909,7 @@ function withThemeScope(Component) {
|
|
|
18767
18909
|
var _a, _b, _c;
|
|
18768
18910
|
const p = props;
|
|
18769
18911
|
const theme = resolveUniverseTheme((_c = (_a = p.settings) == null ? void 0 : _a.theme) != null ? _c : (_b = p.config) == null ? void 0 : _b.theme);
|
|
18770
|
-
return /* @__PURE__ */ jsx42("div", { "data-theme": theme, style: { display: "contents" }, children:
|
|
18912
|
+
return /* @__PURE__ */ jsx42("div", { "data-theme": theme, style: { display: "contents" }, children: React31.createElement(Component, props) });
|
|
18771
18913
|
}
|
|
18772
18914
|
ThemeScoped.displayName = `ThemeScoped(${Component.displayName || Component.name || "Component"})`;
|
|
18773
18915
|
return ThemeScoped;
|
|
@@ -18782,12 +18924,16 @@ var UNIVERSE_COMPONENTS = {
|
|
|
18782
18924
|
PAYMENT_REPORTS: withThemeScope(PaymentReportsBlock)
|
|
18783
18925
|
};
|
|
18784
18926
|
export {
|
|
18927
|
+
BOOLEAN_BUTTON_FALSE_ID,
|
|
18928
|
+
BOOLEAN_BUTTON_TRUE_ID,
|
|
18785
18929
|
COLUMN_CAPABILITIES,
|
|
18786
18930
|
COLUMN_DEFAULT_INPUT_CONFIG,
|
|
18787
18931
|
COLUMN_TYPES,
|
|
18788
18932
|
COLUMN_TYPE_LABELS,
|
|
18789
18933
|
ColumnHeaderTitle,
|
|
18790
18934
|
CreateTemplateModal,
|
|
18935
|
+
DEFAULT_BOOLEAN_FALSE_LABEL,
|
|
18936
|
+
DEFAULT_BOOLEAN_TRUE_LABEL,
|
|
18791
18937
|
DEFAULT_FILTER_COLUMN_TYPES,
|
|
18792
18938
|
DEFAULT_PLACEMENT_STATUS_COLORS,
|
|
18793
18939
|
DatePickerCell,
|
|
@@ -18861,6 +19007,7 @@ export {
|
|
|
18861
19007
|
formatTimeInput,
|
|
18862
19008
|
formatTimeIso,
|
|
18863
19009
|
generateWhatsAppLink,
|
|
19010
|
+
getBooleanButtonLabels,
|
|
18864
19011
|
getColumnDefaultFilter,
|
|
18865
19012
|
getDefaultFilterColumns,
|
|
18866
19013
|
getDeterministicPastelBadge,
|
|
@@ -18878,6 +19025,7 @@ export {
|
|
|
18878
19025
|
hasConsecutiveVariables,
|
|
18879
19026
|
hasFloatingVariables,
|
|
18880
19027
|
hasInsufficientContextBetweenVariables,
|
|
19028
|
+
isBooleanButtonsColumn,
|
|
18881
19029
|
isDuplicateTemplate,
|
|
18882
19030
|
isDuplicateTemplateName,
|
|
18883
19031
|
isPerRecordSourceColumn,
|