blixify-ui-web 1.2.60 → 1.2.63
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/lib/components/action/radioList/index.d.ts +2 -0
- package/lib/components/action/radioList/index.d.ts.map +1 -1
- package/lib/components/action/radioList/index.js +13 -7
- package/lib/components/action/radioList/index.js.map +1 -1
- package/lib/components/data/dataTemplate/dataStateModel.d.ts +9 -0
- package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +404 -184
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +4 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/data/listModule.d.ts.map +1 -1
- package/lib/components/data/listModule.js +7 -1
- package/lib/components/data/listModule.js.map +1 -1
- package/lib/components/data/moduleUtils.d.ts +1 -0
- package/lib/components/data/moduleUtils.d.ts.map +1 -1
- package/lib/components/data/moduleUtils.js +144 -114
- package/lib/components/data/moduleUtils.js.map +1 -1
- package/lib/components/data/readModule.d.ts.map +1 -1
- package/lib/components/data/readModule.js +24 -6
- package/lib/components/data/readModule.js.map +1 -1
- package/lib/components/data/testSchema.js +1 -1
- package/lib/components/data/testSchema.js.map +1 -1
- package/lib/components/data/updateModule.d.ts +3 -0
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +44 -17
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/data/utils.d.ts +2 -0
- package/lib/components/data/utils.d.ts.map +1 -1
- package/lib/components/data/utils.js +42 -1
- package/lib/components/data/utils.js.map +1 -1
- package/lib/components/display/flexTable/index.d.ts +14 -0
- package/lib/components/display/flexTable/index.d.ts.map +1 -1
- package/lib/components/display/flexTable/index.js +97 -17
- package/lib/components/display/flexTable/index.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts +8 -0
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +428 -107
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/components/display/notification/index.d.ts +2 -0
- package/lib/components/display/notification/index.d.ts.map +1 -1
- package/lib/components/display/notification/index.js +2 -1
- package/lib/components/display/notification/index.js.map +1 -1
- package/lib/components/display/scrollShadow/index.d.ts +9 -0
- package/lib/components/display/scrollShadow/index.d.ts.map +1 -0
- package/lib/components/display/scrollShadow/index.js +66 -0
- package/lib/components/display/scrollShadow/index.js.map +1 -0
- package/lib/components/display/stepper/index.d.ts +3 -0
- package/lib/components/display/stepper/index.d.ts.map +1 -1
- package/lib/components/display/stepper/index.js +28 -11
- package/lib/components/display/stepper/index.js.map +1 -1
- package/lib/components/display/table/index.d.ts.map +1 -1
- package/lib/components/display/table/index.js +3 -2
- package/lib/components/display/table/index.js.map +1 -1
- package/lib/components/input/datePicker/index.d.ts.map +1 -1
- package/lib/components/input/datePicker/index.js +5 -5
- package/lib/components/input/datePicker/index.js.map +1 -1
- package/lib/components/input/select/index.d.ts.map +1 -1
- package/lib/components/input/select/index.js +10 -9
- package/lib/components/input/select/index.js.map +1 -1
- package/lib/components/input/textArea/index.d.ts.map +1 -1
- package/lib/components/input/textArea/index.js +19 -3
- package/lib/components/input/textArea/index.js.map +1 -1
- package/lib/components/input/textInput/index.d.ts.map +1 -1
- package/lib/components/input/textInput/index.js +23 -10
- package/lib/components/input/textInput/index.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -102,6 +102,7 @@ var iconButton_1 = require("../../action/iconButton");
|
|
|
102
102
|
var link_1 = require("../../structure/link");
|
|
103
103
|
var button_1 = require("../../action/button");
|
|
104
104
|
var modal_1 = require("../modal");
|
|
105
|
+
var scrollShadow_1 = require("../scrollShadow");
|
|
105
106
|
// INFO: resolve dotted key paths (e.g. "group.subKey") against a row object.
|
|
106
107
|
// Required because flatColumns uses "parent.child" keys for groupData sub-columns.
|
|
107
108
|
var resolveValue = function (row, key) {
|
|
@@ -157,6 +158,52 @@ var handleCheckModalEditEmpty = function (value) {
|
|
|
157
158
|
}
|
|
158
159
|
return false;
|
|
159
160
|
};
|
|
161
|
+
// INFO: literal class maps so Tailwind emits them. Keys match the Tag palette
|
|
162
|
+
// (tag/utils.ts) so a column's listSelectionColour drives both the chip in the
|
|
163
|
+
// read view and the solid fill in the table. Yellow gets dark text — white on
|
|
164
|
+
// yellow-500 fails contrast.
|
|
165
|
+
var FILL_CLASS = {
|
|
166
|
+
default: "bg-primary-500 text-white",
|
|
167
|
+
red: "bg-red-500 text-white",
|
|
168
|
+
blue: "bg-blue-500 text-white",
|
|
169
|
+
green: "bg-green-500 text-white",
|
|
170
|
+
yellow: "bg-yellow-400 text-yellow-950",
|
|
171
|
+
indigo: "bg-indigo-500 text-white",
|
|
172
|
+
dark: "bg-gray-800 text-white",
|
|
173
|
+
};
|
|
174
|
+
// INFO: group band (tinted) and the accent bar its member rows carry
|
|
175
|
+
var BAND_CLASS = {
|
|
176
|
+
default: "bg-primary-50 text-primary-800 border-primary-500",
|
|
177
|
+
red: "bg-red-50 text-red-800 border-red-500",
|
|
178
|
+
blue: "bg-blue-50 text-blue-800 border-blue-500",
|
|
179
|
+
green: "bg-green-50 text-green-800 border-green-500",
|
|
180
|
+
yellow: "bg-yellow-50 text-yellow-800 border-yellow-500",
|
|
181
|
+
indigo: "bg-indigo-50 text-indigo-800 border-indigo-500",
|
|
182
|
+
dark: "bg-gray-100 text-gray-800 border-gray-700",
|
|
183
|
+
none: "bg-gray-50 text-gray-700 border-gray-300",
|
|
184
|
+
};
|
|
185
|
+
var ACCENT_CLASS = {
|
|
186
|
+
default: "border-primary-500",
|
|
187
|
+
red: "border-red-500",
|
|
188
|
+
blue: "border-blue-500",
|
|
189
|
+
green: "border-green-500",
|
|
190
|
+
yellow: "border-yellow-500",
|
|
191
|
+
indigo: "border-indigo-500",
|
|
192
|
+
dark: "border-gray-700",
|
|
193
|
+
none: "border-gray-300",
|
|
194
|
+
};
|
|
195
|
+
// INFO: the colour a list column assigns to a value, or undefined when the
|
|
196
|
+
// column carries no palette — undefined means "render as before"
|
|
197
|
+
var handleGetListColour = function (col, value) {
|
|
198
|
+
var column = col;
|
|
199
|
+
if (!Array.isArray(column.listSelection) ||
|
|
200
|
+
!Array.isArray(column.listSelectionColour))
|
|
201
|
+
return undefined;
|
|
202
|
+
var index = column.listSelection.indexOf(value);
|
|
203
|
+
if (index < 0)
|
|
204
|
+
return undefined;
|
|
205
|
+
return column.listSelectionColour[index] || undefined;
|
|
206
|
+
};
|
|
160
207
|
var NewTable = function (props) {
|
|
161
208
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
162
209
|
var columns = (_b = (_a = props.columns) !== null && _a !== void 0 ? _a : props.header) !== null && _b !== void 0 ? _b : [];
|
|
@@ -219,18 +266,52 @@ var NewTable = function (props) {
|
|
|
219
266
|
var _y = (0, react_2.useState)(""), editDataRowId = _y[0], setEditDataRowId = _y[1];
|
|
220
267
|
var _z = (0, react_2.useState)(""), editDataHeaderKey = _z[0], setEditDataHeaderKey = _z[1];
|
|
221
268
|
var _0 = (0, react_2.useState)(false), modalEditVisible = _0[0], setModalEditVisible = _0[1];
|
|
222
|
-
var _1 = (0, react_2.useState)(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
269
|
+
var _1 = (0, react_2.useState)([]), collapsedGroupIds = _1[0], setCollapsedGroupIds = _1[1];
|
|
270
|
+
// INFO: sheet-style row selection — Shift-click extends from the last
|
|
271
|
+
// clicked row, a mouse-down-and-drag down the checkbox column paints a
|
|
272
|
+
// range. The drag applies the start row itself, so the click that lands on
|
|
273
|
+
// mouse-up must be swallowed or it would toggle that row straight back.
|
|
274
|
+
var lastSelectedRowRef = (0, react_2.useRef)(null);
|
|
275
|
+
var dragSelectRef = (0, react_2.useRef)(null);
|
|
276
|
+
var suppressNextClickRef = (0, react_2.useRef)(false);
|
|
277
|
+
var _2 = (0, react_2.useState)(false), isDragSelecting = _2[0], setIsDragSelecting = _2[1];
|
|
278
|
+
var _3 = (0, react_2.useState)(0), copiedCount = _3[0], setCopiedCount = _3[1];
|
|
279
|
+
// INFO: the open colour palette for a filled list cell — which cell, and
|
|
280
|
+
// where to anchor the popover (viewport coordinates, so it escapes the
|
|
281
|
+
// table's overflow container)
|
|
282
|
+
var _4 = (0, react_2.useState)(null), paletteCell = _4[0], setPaletteCell = _4[1];
|
|
283
|
+
(0, react_2.useEffect)(function () {
|
|
284
|
+
if (!paletteCell)
|
|
285
|
+
return;
|
|
286
|
+
var handleClose = function () { return setPaletteCell(null); };
|
|
287
|
+
var handleKey = function (e) {
|
|
288
|
+
if (e.key === "Escape")
|
|
289
|
+
setPaletteCell(null);
|
|
290
|
+
};
|
|
291
|
+
// INFO: no scroll listener — opening the palette can itself scroll the
|
|
292
|
+
// table (the row switches to edit mode and its first input takes focus),
|
|
293
|
+
// and closing on that scroll would shut the palette as it appears
|
|
294
|
+
document.addEventListener("mousedown", handleClose);
|
|
295
|
+
document.addEventListener("keydown", handleKey);
|
|
296
|
+
window.addEventListener("resize", handleClose);
|
|
297
|
+
return function () {
|
|
298
|
+
document.removeEventListener("mousedown", handleClose);
|
|
299
|
+
document.removeEventListener("keydown", handleKey);
|
|
300
|
+
window.removeEventListener("resize", handleClose);
|
|
301
|
+
};
|
|
302
|
+
}, [paletteCell]);
|
|
303
|
+
var _5 = (0, react_2.useState)({}), editDataValue = _5[0], setEditDataValue = _5[1];
|
|
304
|
+
var _6 = (0, react_2.useState)(false), editDataIsLoading = _6[0], setEditDataIsLoading = _6[1];
|
|
305
|
+
var _7 = (0, react_2.useState)(false), addData = _7[0], setAddData = _7[1];
|
|
306
|
+
var _8 = (0, react_2.useState)({}), addDataValue = _8[0], setAddDataValue = _8[1];
|
|
307
|
+
var _9 = (0, react_2.useState)({}), referencesOptions = _9[0], setReferencesOptions = _9[1];
|
|
227
308
|
// INFO: seeded options sit under the local map so a cell's own search
|
|
228
309
|
// results still win per key
|
|
229
310
|
var mergedReferencesOptions = __assign(__assign({}, ((_g = props.referencesOptions) !== null && _g !== void 0 ? _g : {})), referencesOptions);
|
|
230
|
-
var
|
|
231
|
-
var
|
|
311
|
+
var _10 = (0, react_2.useState)({}), referencesDetails = _10[0], setReferencesDetails = _10[1];
|
|
312
|
+
var _11 = (0, react_2.useState)(false), referenceLoading = _11[0], setReferenceLoading = _11[1];
|
|
232
313
|
// INFO: measured pixel widths for pinned columns without an explicit width.
|
|
233
|
-
var
|
|
314
|
+
var _12 = (0, react_2.useState)({}), measuredPinWidths = _12[0], setMeasuredPinWidths = _12[1];
|
|
234
315
|
var editDataValueRef = (0, react_2.useRef)({});
|
|
235
316
|
var editDataRowIdRef = (0, react_2.useRef)("");
|
|
236
317
|
var editDataInputRefs = (0, react_2.useRef)([]);
|
|
@@ -258,6 +339,10 @@ var NewTable = function (props) {
|
|
|
258
339
|
? "text-primary-300 font-medium"
|
|
259
340
|
: "text-primary-600 font-medium";
|
|
260
341
|
var cellPadding = "px-4 py-2";
|
|
342
|
+
// INFO: an inline input carries its own vertical padding, so the cell around
|
|
343
|
+
// it keeps only enough to clear the hover border — this is what holds an
|
|
344
|
+
// editable row to roughly the height of a read-only one
|
|
345
|
+
var editCellPadding = "px-4 py-0.5";
|
|
261
346
|
var tableHeaderBgColor = props.tableHeaderBgColor
|
|
262
347
|
? props.tableHeaderBgColor
|
|
263
348
|
: props.darkMode
|
|
@@ -610,9 +695,134 @@ var NewTable = function (props) {
|
|
|
610
695
|
var handleFilterModal = function (id) {
|
|
611
696
|
setFilterModal(id);
|
|
612
697
|
};
|
|
698
|
+
var handleSelectRange = function (fromIndex, toIndex, mode, base) {
|
|
699
|
+
if (!props.handleSelectedIds)
|
|
700
|
+
return;
|
|
701
|
+
var _a = fromIndex <= toIndex ? [fromIndex, toIndex] : [toIndex, fromIndex], low = _a[0], high = _a[1];
|
|
702
|
+
var rangeIds = props.data
|
|
703
|
+
.slice(low, high + 1)
|
|
704
|
+
.map(function (eachRow) { return eachRow.id; });
|
|
705
|
+
if (mode === "remove") {
|
|
706
|
+
props.handleSelectedIds(base.filter(function (eachId) { return !rangeIds.includes(eachId); }));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
var next = __spreadArray([], base, true);
|
|
710
|
+
rangeIds.forEach(function (eachId) {
|
|
711
|
+
if (next.includes(eachId))
|
|
712
|
+
return;
|
|
713
|
+
if (props.maxSelectedCount && next.length >= props.maxSelectedCount)
|
|
714
|
+
return;
|
|
715
|
+
next.push(eachId);
|
|
716
|
+
});
|
|
717
|
+
props.handleSelectedIds(next);
|
|
718
|
+
};
|
|
719
|
+
var handleDragSelectStart = function (rowId, e) {
|
|
720
|
+
var _a;
|
|
721
|
+
if (props.singleSelect ||
|
|
722
|
+
props.selectAll ||
|
|
723
|
+
!props.handleSelectedIds ||
|
|
724
|
+
e.button !== 0 ||
|
|
725
|
+
e.shiftKey)
|
|
726
|
+
return;
|
|
727
|
+
// INFO: stop the browser from starting a text selection as the pointer
|
|
728
|
+
// sweeps down the column
|
|
729
|
+
e.preventDefault();
|
|
730
|
+
var startIndex = props.data.findIndex(function (eachRow) { return eachRow.id === rowId; });
|
|
731
|
+
if (startIndex < 0)
|
|
732
|
+
return;
|
|
733
|
+
var base = (_a = props.selectedIds) !== null && _a !== void 0 ? _a : [];
|
|
734
|
+
var mode = base.includes(rowId) ? "remove" : "add";
|
|
735
|
+
dragSelectRef.current = { startIndex: startIndex, mode: mode, base: base };
|
|
736
|
+
suppressNextClickRef.current = true;
|
|
737
|
+
lastSelectedRowRef.current = rowId;
|
|
738
|
+
setIsDragSelecting(true);
|
|
739
|
+
handleSelectRange(startIndex, startIndex, mode, base);
|
|
740
|
+
};
|
|
741
|
+
var handleDragSelectOver = function (rowId) {
|
|
742
|
+
var drag = dragSelectRef.current;
|
|
743
|
+
if (!drag)
|
|
744
|
+
return;
|
|
745
|
+
var overIndex = props.data.findIndex(function (eachRow) { return eachRow.id === rowId; });
|
|
746
|
+
if (overIndex < 0)
|
|
747
|
+
return;
|
|
748
|
+
handleSelectRange(drag.startIndex, overIndex, drag.mode, drag.base);
|
|
749
|
+
};
|
|
750
|
+
(0, react_2.useEffect)(function () {
|
|
751
|
+
if (!isDragSelecting)
|
|
752
|
+
return;
|
|
753
|
+
var handleEnd = function () {
|
|
754
|
+
dragSelectRef.current = null;
|
|
755
|
+
setIsDragSelecting(false);
|
|
756
|
+
};
|
|
757
|
+
document.addEventListener("mouseup", handleEnd);
|
|
758
|
+
return function () { return document.removeEventListener("mouseup", handleEnd); };
|
|
759
|
+
}, [isDragSelecting]);
|
|
760
|
+
// INFO: Esc drops the whole selection, the way it drops a range in a sheet.
|
|
761
|
+
// When the colour palette is open Esc closes that instead (its own handler).
|
|
762
|
+
(0, react_2.useEffect)(function () {
|
|
763
|
+
var _a, _b;
|
|
764
|
+
var hasSelection = props.selectAll || ((_b = (_a = props.selectedIds) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
765
|
+
if (!hasSelection || paletteCell)
|
|
766
|
+
return;
|
|
767
|
+
var handleKey = function (e) {
|
|
768
|
+
var _a, _b;
|
|
769
|
+
if (e.key !== "Escape")
|
|
770
|
+
return;
|
|
771
|
+
(_a = props.handleSelectAll) === null || _a === void 0 ? void 0 : _a.call(props, false);
|
|
772
|
+
(_b = props.handleSelectedIds) === null || _b === void 0 ? void 0 : _b.call(props, []);
|
|
773
|
+
lastSelectedRowRef.current = null;
|
|
774
|
+
};
|
|
775
|
+
document.addEventListener("keydown", handleKey);
|
|
776
|
+
return function () { return document.removeEventListener("keydown", handleKey); };
|
|
777
|
+
}, [props.selectAll, props.selectedIds, paletteCell]);
|
|
778
|
+
// INFO: visible columns of the selected rows as TSV — header row first —
|
|
779
|
+
// so a paste into Excel or Sheets lands one value per cell
|
|
780
|
+
var handleCopySelection = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
781
|
+
var columns, rowIndexes, lines, err_1;
|
|
782
|
+
return __generator(this, function (_a) {
|
|
783
|
+
switch (_a.label) {
|
|
784
|
+
case 0:
|
|
785
|
+
columns = flatColumns.filter(function (eachCol) { return !(eachCol.key === "update" && !eachCol.type); });
|
|
786
|
+
rowIndexes = props.data
|
|
787
|
+
.map(function (_eachRow, index) { return index; })
|
|
788
|
+
.filter(function (index) {
|
|
789
|
+
var _a;
|
|
790
|
+
return props.selectAll ||
|
|
791
|
+
((_a = props.selectedIds) !== null && _a !== void 0 ? _a : []).includes(props.data[index].id);
|
|
792
|
+
});
|
|
793
|
+
lines = __spreadArray([
|
|
794
|
+
columns.map(function (eachCol) { var _a; return (_a = eachCol.title) !== null && _a !== void 0 ? _a : eachCol.key; }).join("\t")
|
|
795
|
+
], rowIndexes.map(function (index) {
|
|
796
|
+
return columns
|
|
797
|
+
.map(function (eachCol) {
|
|
798
|
+
var _a;
|
|
799
|
+
return resolveValueToString(eachCol.key, (_a = props.spaceData) === null || _a === void 0 ? void 0 : _a[index], props.data[index]).replace(/[\t\n\r]+/g, " ");
|
|
800
|
+
})
|
|
801
|
+
.join("\t");
|
|
802
|
+
}), true);
|
|
803
|
+
_a.label = 1;
|
|
804
|
+
case 1:
|
|
805
|
+
_a.trys.push([1, 3, , 4]);
|
|
806
|
+
return [4 /*yield*/, navigator.clipboard.writeText(lines.join("\n"))];
|
|
807
|
+
case 2:
|
|
808
|
+
_a.sent();
|
|
809
|
+
setCopiedCount(rowIndexes.length);
|
|
810
|
+
setTimeout(function () { return setCopiedCount(0); }, 1500);
|
|
811
|
+
return [3 /*break*/, 4];
|
|
812
|
+
case 3:
|
|
813
|
+
err_1 = _a.sent();
|
|
814
|
+
return [3 /*break*/, 4];
|
|
815
|
+
case 4: return [2 /*return*/];
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}); };
|
|
613
819
|
var handleSelectRow = function (rowId, e) {
|
|
614
820
|
var _a, _b;
|
|
615
821
|
e.stopPropagation();
|
|
822
|
+
if (suppressNextClickRef.current) {
|
|
823
|
+
suppressNextClickRef.current = false;
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
616
826
|
// INFO: deactivate "select all pages" mode before doing individual row toggle
|
|
617
827
|
if (props.selectAll) {
|
|
618
828
|
(_a = props.handleSelectAll) === null || _a === void 0 ? void 0 : _a.call(props, false);
|
|
@@ -625,6 +835,15 @@ var NewTable = function (props) {
|
|
|
625
835
|
}
|
|
626
836
|
else {
|
|
627
837
|
var current = (_b = props.selectedIds) !== null && _b !== void 0 ? _b : [];
|
|
838
|
+
if (e.shiftKey && lastSelectedRowRef.current) {
|
|
839
|
+
var fromIndex = props.data.findIndex(function (eachRow) { return eachRow.id === lastSelectedRowRef.current; });
|
|
840
|
+
var toIndex = props.data.findIndex(function (eachRow) { return eachRow.id === rowId; });
|
|
841
|
+
if (fromIndex >= 0 && toIndex >= 0) {
|
|
842
|
+
handleSelectRange(fromIndex, toIndex, "add", current);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
lastSelectedRowRef.current = rowId;
|
|
628
847
|
var idx = current.indexOf(rowId);
|
|
629
848
|
// INFO: allow deselect, block new selection when maxSelectedCount is reached
|
|
630
849
|
if (idx < 0 &&
|
|
@@ -833,7 +1052,7 @@ var NewTable = function (props) {
|
|
|
833
1052
|
var editingRow = editDataRowId === rowId;
|
|
834
1053
|
return (react_2.default.createElement("td", { key: col.key + String(colIndex),
|
|
835
1054
|
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
836
|
-
className: "".concat(
|
|
1055
|
+
className: "".concat(editCellPadding, " ").concat(getPinProps(col.key, false) ? "" : "whitespace-nowrap", " text-sm ").concat(cellFontColor, " ").concat((_c = (_b = getPinProps(col.key, false, rowBgClass, isHoverable)) === null || _b === void 0 ? void 0 : _b.className) !== null && _c !== void 0 ? _c : ""), style: (_d = getPinProps(col.key, false, rowBgClass, isHoverable)) === null || _d === void 0 ? void 0 : _d.style },
|
|
837
1056
|
react_2.default.createElement("div", { className: "w-max p-[1px]", onClick: function (e) {
|
|
838
1057
|
e.stopPropagation();
|
|
839
1058
|
handleEditDataOnClick(rowId, col.key, rowData);
|
|
@@ -948,12 +1167,164 @@ var NewTable = function (props) {
|
|
|
948
1167
|
// INFO: true when maxSelectedCount is set and the current selection has reached the limit
|
|
949
1168
|
var isMaxReached = !!props.maxSelectedCount &&
|
|
950
1169
|
((_j = (_h = props.selectedIds) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0) >= props.maxSelectedCount;
|
|
1170
|
+
// INFO: one desktop row. groupAccent carries the group's colour so member
|
|
1171
|
+
// rows show the band's colour as a bar down their left edge.
|
|
1172
|
+
var renderDesktopRow = function (row, index, groupAccent) {
|
|
1173
|
+
var _a, _b, _c, _d, _e;
|
|
1174
|
+
var spaceRow = (_a = props.spaceData) === null || _a === void 0 ? void 0 : _a[index];
|
|
1175
|
+
var isSelected = ((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.includes(row.id)) !== null && _c !== void 0 ? _c : false) ||
|
|
1176
|
+
((_d = props.selectAll) !== null && _d !== void 0 ? _d : false);
|
|
1177
|
+
var rowBgClass = isSelected ? selectedRowBg : bgColor;
|
|
1178
|
+
var isRowHoverable = !!props.onClickRow && !isSelected;
|
|
1179
|
+
return (react_2.default.createElement("tr", { key: row.id, onClick: function (e) {
|
|
1180
|
+
if (props.onClickRow) {
|
|
1181
|
+
props.onClickRow(row.id, row, spaceRow);
|
|
1182
|
+
}
|
|
1183
|
+
e.preventDefault();
|
|
1184
|
+
}, className: "group ".concat(isSelected
|
|
1185
|
+
? selectedRowBg
|
|
1186
|
+
: props.onClickRow
|
|
1187
|
+
? "cursor-pointer ".concat(rowHoverBg)
|
|
1188
|
+
: editDataIsLoading && editDataRowId === row.id
|
|
1189
|
+
? "animate-pulse"
|
|
1190
|
+
: "", " ").concat(groupAccent
|
|
1191
|
+
? "border-l-4 ".concat((_e = ACCENT_CLASS[groupAccent]) !== null && _e !== void 0 ? _e : ACCENT_CLASS.default)
|
|
1192
|
+
: "") },
|
|
1193
|
+
props.checkbox && (react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? "".concat(rowBgClass, " ").concat(isRowHoverable ? (props.darkMode ? "group-hover:bg-gray-700" : "group-hover:bg-gray-100") : "") : ""), style: hasPinColumns
|
|
1194
|
+
? {
|
|
1195
|
+
position: "sticky",
|
|
1196
|
+
left: 0,
|
|
1197
|
+
zIndex: 1,
|
|
1198
|
+
width: CHECKBOX_WIDTH,
|
|
1199
|
+
minWidth: CHECKBOX_WIDTH,
|
|
1200
|
+
}
|
|
1201
|
+
: undefined, onClick: function (e) { return handleSelectRow(row.id, e); }, onMouseDown: function (e) { return handleDragSelectStart(row.id, e); }, onMouseEnter: function () { return handleDragSelectOver(row.id); } }, renderCheckbox(isSelected, function () { }, undefined, isMaxReached && !isSelected
|
|
1202
|
+
? "opacity-50 cursor-not-allowed"
|
|
1203
|
+
: ""))),
|
|
1204
|
+
flatColumns.map(function (col, colIndex) {
|
|
1205
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1206
|
+
var cellValue = spaceRow
|
|
1207
|
+
? spaceRow[col.key]
|
|
1208
|
+
: resolveValue(row, col.key);
|
|
1209
|
+
// INFO: first col with type "string" is never made editable
|
|
1210
|
+
var resolvedColType = (_a = col.type) !== null && _a !== void 0 ? _a : "string";
|
|
1211
|
+
var isActionColumn = col.key === "update" && !col.type;
|
|
1212
|
+
var isModalEdit = ((_b = props.editable) === null || _b === void 0 ? void 0 : _b.active) &&
|
|
1213
|
+
!isActionColumn &&
|
|
1214
|
+
utils_1.supportedModalEditList.includes(resolvedColType);
|
|
1215
|
+
var isObjectEdit = ((_c = props.editable) === null || _c === void 0 ? void 0 : _c.active) &&
|
|
1216
|
+
!isActionColumn &&
|
|
1217
|
+
resolvedColType === "object" &&
|
|
1218
|
+
!!props.onObjectEdit;
|
|
1219
|
+
var isEditable = ((_d = props.editable) === null || _d === void 0 ? void 0 : _d.active) &&
|
|
1220
|
+
!isActionColumn &&
|
|
1221
|
+
!(((_f = (_e = props.selectedIds) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0 ||
|
|
1222
|
+
props.selectAll) &&
|
|
1223
|
+
utils_1.supportedInlineEditList.includes(resolvedColType);
|
|
1224
|
+
var rowData = editDataRowId === row.id ? editDataValue : row;
|
|
1225
|
+
// INFO: a list column with a palette paints the whole cell —
|
|
1226
|
+
// a status column then reads like a heat map instead of a
|
|
1227
|
+
// row of chips. Editable tables open the palette on click.
|
|
1228
|
+
var rawListValue = resolveValue(row, col.key);
|
|
1229
|
+
var fillColour = resolvedColType === "list" && !isActionColumn
|
|
1230
|
+
? handleGetListColour(col, rawListValue)
|
|
1231
|
+
: undefined;
|
|
1232
|
+
if (fillColour) {
|
|
1233
|
+
var canPickColour = !!((_g = props.editable) === null || _g === void 0 ? void 0 : _g.active) &&
|
|
1234
|
+
!(((_j = (_h = props.selectedIds) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0) > 0 ||
|
|
1235
|
+
props.selectAll);
|
|
1236
|
+
return (react_2.default.createElement("td", { key: col.key, className: "p-0 align-middle ".concat((_l = (_k = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _k === void 0 ? void 0 : _k.className) !== null && _l !== void 0 ? _l : ""), style: (_m = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _m === void 0 ? void 0 : _m.style },
|
|
1237
|
+
react_2.default.createElement("div", { "data-testid": "table-fill-".concat(col.key), "data-colour": fillColour, role: canPickColour ? "button" : undefined, tabIndex: canPickColour ? 0 : undefined, onClick: canPickColour
|
|
1238
|
+
? function (e) {
|
|
1239
|
+
e.stopPropagation();
|
|
1240
|
+
var rect = e.currentTarget.getBoundingClientRect();
|
|
1241
|
+
handleEditDataOnClick(row.id, col.key, row);
|
|
1242
|
+
setPaletteCell({
|
|
1243
|
+
rowId: row.id,
|
|
1244
|
+
key: col.key,
|
|
1245
|
+
top: rect.bottom + 4,
|
|
1246
|
+
left: rect.left,
|
|
1247
|
+
width: rect.width,
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
: undefined, className: "flex h-full min-h-[40px] items-center justify-center px-3 text-sm font-medium ".concat((_o = FILL_CLASS[fillColour]) !== null && _o !== void 0 ? _o : FILL_CLASS.default, " ").concat(canPickColour ? "cursor-pointer hover:brightness-95" : "") }, String(rawListValue))));
|
|
1251
|
+
}
|
|
1252
|
+
if (isObjectEdit) {
|
|
1253
|
+
return (react_2.default.createElement("td", { key: col.key, className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " whitespace-nowrap") },
|
|
1254
|
+
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-object-edit-".concat(col.key), onClick: function (e) {
|
|
1255
|
+
var _a;
|
|
1256
|
+
e.stopPropagation();
|
|
1257
|
+
(_a = props.onObjectEdit) === null || _a === void 0 ? void 0 : _a.call(props, row.id, col.key, row);
|
|
1258
|
+
} },
|
|
1259
|
+
handleCheckModalEditEmpty(cellValue) ? (react_2.default.createElement("span", { className: "text-gray-400 italic" }, "Add")) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord)),
|
|
1260
|
+
react_2.default.createElement(outline_1.PencilIcon, { className: "w-3.5 h-3.5 text-gray-400 opacity-0 group-hover/modaledit:opacity-100 flex-shrink-0" }))));
|
|
1261
|
+
}
|
|
1262
|
+
if (isModalEdit) {
|
|
1263
|
+
return (react_2.default.createElement("td", { key: col.key, className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " whitespace-nowrap") },
|
|
1264
|
+
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-modal-edit-".concat(col.key), onClick: function (e) {
|
|
1265
|
+
e.stopPropagation();
|
|
1266
|
+
handleModalEditOnClick(row.id, col.key, row);
|
|
1267
|
+
} },
|
|
1268
|
+
handleCheckModalEditEmpty(cellValue) ? (react_2.default.createElement("span", { className: "text-gray-400 italic" }, "Add")) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord)),
|
|
1269
|
+
react_2.default.createElement(outline_1.PencilIcon, { className: "w-3.5 h-3.5 text-gray-400 opacity-0 group-hover/modaledit:opacity-100 flex-shrink-0" }))));
|
|
1270
|
+
}
|
|
1271
|
+
if (isEditable) {
|
|
1272
|
+
var bareOverride = (_q = (_p = props.bareSettings) === null || _p === void 0 ? void 0 : _p.bareListDescription) === null || _q === void 0 ? void 0 : _q.call(_p, col.key, cellValue);
|
|
1273
|
+
if (!bareOverride)
|
|
1274
|
+
return renderEditDataInputs(colIndex, col, rowData, row.id, rowBgClass, isRowHoverable);
|
|
1275
|
+
}
|
|
1276
|
+
return (
|
|
1277
|
+
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
1278
|
+
react_2.default.createElement("td", { key: col.key, "data-pin-key": leftPinned.includes(col.key) ||
|
|
1279
|
+
rightPinned.includes(col.key)
|
|
1280
|
+
? col.key
|
|
1281
|
+
: undefined, className: "".concat(cellPadding, " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((_s = (_r = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _r === void 0 ? void 0 : _r.className) !== null && _s !== void 0 ? _s : ""), style: (_t = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _t === void 0 ? void 0 : _t.style }, props.newTabUrl && props.onClickRow ? (react_2.default.createElement(link_1.Link, { href: props.newTabUrl +
|
|
1282
|
+
row.id +
|
|
1283
|
+
((_u = props.addNewTabUrl) !== null && _u !== void 0 ? _u : ""), className: "w-full block", linkType: props.linkType, custom: props.custom }, (0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))));
|
|
1284
|
+
}),
|
|
1285
|
+
renderActionColumnCell(row.id)));
|
|
1286
|
+
};
|
|
1287
|
+
// INFO: with groups, each group is a tinted band row (chevron, title, count)
|
|
1288
|
+
// followed by its member rows; collapsing a band hides them. Without groups,
|
|
1289
|
+
// the plain row list.
|
|
1290
|
+
var renderDesktopRows = function () {
|
|
1291
|
+
if (!props.groups || props.groups.length === 0) {
|
|
1292
|
+
return props.data.map(function (row, index) { return renderDesktopRow(row, index); });
|
|
1293
|
+
}
|
|
1294
|
+
var indexById = new Map(props.data.map(function (row, index) { return [row.id, index]; }));
|
|
1295
|
+
var columnCount = flatColumns.length + (props.checkbox ? 1 : 0) + 1;
|
|
1296
|
+
return props.groups.map(function (group) {
|
|
1297
|
+
var _a, _b;
|
|
1298
|
+
var colourKey = (_a = group.colour) !== null && _a !== void 0 ? _a : "none";
|
|
1299
|
+
var isCollapsed = collapsedGroupIds.includes(group.id);
|
|
1300
|
+
var memberIndexes = group.rowIds
|
|
1301
|
+
.map(function (rowId) { return indexById.get(rowId); })
|
|
1302
|
+
.filter(function (rowIndex) { return rowIndex !== undefined; });
|
|
1303
|
+
return (react_2.default.createElement(react_2.default.Fragment, { key: "group-".concat(group.id) },
|
|
1304
|
+
react_2.default.createElement("tr", { "data-testid": "table-group-".concat(group.id), "data-collapsed": isCollapsed ? "true" : "false", className: "border-l-4 ".concat((_b = BAND_CLASS[colourKey]) !== null && _b !== void 0 ? _b : BAND_CLASS.none) },
|
|
1305
|
+
react_2.default.createElement("td", { colSpan: columnCount, className: "px-3 py-2" },
|
|
1306
|
+
react_2.default.createElement("button", { type: "button", className: "flex w-full items-center gap-x-2 text-left text-xs font-semibold uppercase tracking-wide", onClick: function (e) {
|
|
1307
|
+
e.stopPropagation();
|
|
1308
|
+
setCollapsedGroupIds(function (previous) {
|
|
1309
|
+
return previous.includes(group.id)
|
|
1310
|
+
? previous.filter(function (eachId) { return eachId !== group.id; })
|
|
1311
|
+
: __spreadArray(__spreadArray([], previous, true), [group.id], false);
|
|
1312
|
+
});
|
|
1313
|
+
} },
|
|
1314
|
+
isCollapsed ? (react_2.default.createElement(solid_1.ChevronRightIcon, { className: "h-4 w-4" })) : (react_2.default.createElement(solid_1.ChevronDownIcon, { className: "h-4 w-4" })),
|
|
1315
|
+
react_2.default.createElement("span", null, group.title),
|
|
1316
|
+
react_2.default.createElement("span", { className: "rounded-full bg-white/70 px-2 py-0.5 text-[11px] font-medium normal-case tracking-normal" }, memberIndexes.length)))),
|
|
1317
|
+
!isCollapsed &&
|
|
1318
|
+
memberIndexes.map(function (rowIndex) {
|
|
1319
|
+
return renderDesktopRow(props.data[rowIndex], rowIndex, colourKey);
|
|
1320
|
+
})));
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
951
1323
|
var renderFloatingActionBar = function () {
|
|
952
1324
|
var _a, _b, _c, _d, _e;
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
if (visibleBtns.length === 0)
|
|
1325
|
+
var visibleBtns = ((_a = props.multiActionFloatingBtns) !== null && _a !== void 0 ? _a : []).filter(function (btn) { return !btn.hide; });
|
|
1326
|
+
var canCopy = props.enableCopy !== false;
|
|
1327
|
+
if (visibleBtns.length === 0 && !canCopy)
|
|
957
1328
|
return null;
|
|
958
1329
|
var hasSelection = props.selectAll || ((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0;
|
|
959
1330
|
if (!hasSelection)
|
|
@@ -972,11 +1343,12 @@ var NewTable = function (props) {
|
|
|
972
1343
|
var renderCloseBtn = function () { return (react_2.default.createElement(iconButton_1.IconButton, { icon: react_2.default.createElement(solid_1.XMarkIcon, { className: "w-4 h-4" }), className: "!p-1 shrink-0 ".concat(props.darkMode
|
|
973
1344
|
? "hover:bg-gray-700 text-gray-400 hover:text-gray-200"
|
|
974
1345
|
: "hover:bg-gray-100 text-gray-400 hover:text-gray-600"), onClick: function () { return handleSelectAllPages(false); } })); };
|
|
975
|
-
var
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1346
|
+
var actionBtnClassName = "px-2 py-1 text-xs sm:text-sm whitespace-nowrap ".concat(props.darkMode ? "!text-gray-300 hover:!text-primary-300" : "!text-gray-600 hover:!text-primary-600");
|
|
1347
|
+
var renderActionBtns = function () { return (react_2.default.createElement(react_2.default.Fragment, null,
|
|
1348
|
+
visibleBtns.map(function (btn) { return (react_2.default.createElement(textButton_1.TextButton, { key: btn.id, text: btn.btnText, className: actionBtnClassName, onClick: function () { return btn.onClick(btn.id); } })); }),
|
|
1349
|
+
canCopy && (react_2.default.createElement(textButton_1.TextButton, { key: "copy", id: "dtw-copy-selection", text: copiedCount > 0 ? "Copied ".concat(copiedCount) : "Copy", className: actionBtnClassName, onClick: function () {
|
|
1350
|
+
handleCopySelection();
|
|
1351
|
+
} })))); };
|
|
980
1352
|
var pillBase = "shadow-xl ".concat(borderRadius, " ").concat(bgColor, " border-2 ").concat(props.darkMode ? "border-primary-300" : "border-primary-500");
|
|
981
1353
|
return (react_2.default.createElement("div", { className: "fixed ".concat(props.multiActionFloatingOffset || "bottom-10", " inset-x-4 z-10 flex justify-center pointer-events-none") },
|
|
982
1354
|
react_2.default.createElement("div", { className: "sm:hidden flex flex-col w-full px-4 py-2.5 pointer-events-auto ".concat(pillBase) },
|
|
@@ -1312,6 +1684,41 @@ var NewTable = function (props) {
|
|
|
1312
1684
|
return (react_2.default.createElement("div", { className: "pb-44" },
|
|
1313
1685
|
react_2.default.createElement("div", { className: "pb-48" }, (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.renderFilterElements) === null || _b === void 0 ? void 0 : _b.call(_a, filterModal))));
|
|
1314
1686
|
}, onClose: function () { return setFilterModal(""); } }),
|
|
1687
|
+
paletteCell &&
|
|
1688
|
+
(function () {
|
|
1689
|
+
var _a;
|
|
1690
|
+
var column = flatColumns.find(function (eachCol) { return eachCol.key === paletteCell.key; });
|
|
1691
|
+
var row = props.data.find(function (eachRow) { return eachRow.id === paletteCell.rowId; });
|
|
1692
|
+
if (!column || !row)
|
|
1693
|
+
return null;
|
|
1694
|
+
var current = resolveValue(row, column.key);
|
|
1695
|
+
return (react_2.default.createElement("div", { "data-testid": "table-fill-palette", role: "listbox", className: "fixed z-50 grid grid-cols-2 gap-1.5 rounded-lg border border-gray-200 bg-white p-2 shadow-xl", style: {
|
|
1696
|
+
top: paletteCell.top,
|
|
1697
|
+
left: paletteCell.left,
|
|
1698
|
+
minWidth: Math.max(paletteCell.width, 200),
|
|
1699
|
+
}, onMouseDown: function (e) { return e.stopPropagation(); } }, ((_a = column.listSelection) !== null && _a !== void 0 ? _a : []).map(function (option, index) {
|
|
1700
|
+
var _a, _b;
|
|
1701
|
+
var colour = (_a = column.listSelectionColour) === null || _a === void 0 ? void 0 : _a[index];
|
|
1702
|
+
var fillClass = colour
|
|
1703
|
+
? ((_b = FILL_CLASS[colour]) !== null && _b !== void 0 ? _b : FILL_CLASS.default)
|
|
1704
|
+
: "bg-gray-100 text-gray-700";
|
|
1705
|
+
return (react_2.default.createElement("button", { key: option, type: "button", role: "option", "aria-selected": option === current, "data-testid": "table-fill-option-".concat(option), className: "rounded-md px-3 py-2 text-center text-sm font-medium ".concat(fillClass, " hover:brightness-95 ").concat(option === current
|
|
1706
|
+
? "ring-2 ring-primary-500 ring-offset-1"
|
|
1707
|
+
: ""), onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1708
|
+
var _a;
|
|
1709
|
+
return __generator(this, function (_b) {
|
|
1710
|
+
switch (_b.label) {
|
|
1711
|
+
case 0:
|
|
1712
|
+
setPaletteCell(null);
|
|
1713
|
+
return [4 /*yield*/, handleEditDataOnBlur(column.key, __assign(__assign({}, row), (_a = {}, _a[column.key] = option, _a)))];
|
|
1714
|
+
case 1:
|
|
1715
|
+
_b.sent();
|
|
1716
|
+
return [2 /*return*/];
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}); } }, option));
|
|
1720
|
+
})));
|
|
1721
|
+
})(),
|
|
1315
1722
|
react_2.default.createElement(modal_1.Modal, { open: modalEditVisible, title: (_r = (_q = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; })) === null || _q === void 0 ? void 0 : _q.title) !== null && _r !== void 0 ? _r : "Edit", onClose: handleModalEditClose, renderContent: function () {
|
|
1316
1723
|
var _a, _b, _c, _d;
|
|
1317
1724
|
var selectedCol = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; });
|
|
@@ -1352,14 +1759,14 @@ var NewTable = function (props) {
|
|
|
1352
1759
|
var _a, _b;
|
|
1353
1760
|
return (react_2.default.createElement("div", null, (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.renderAddColumnElements) === null || _b === void 0 ? void 0 : _b.call(_a, addColumnModal, function (id) { return handleAddColumnModal(id); })));
|
|
1354
1761
|
}, onClose: function () { return handleAddColumnModal(""); } }),
|
|
1355
|
-
react_2.default.createElement(
|
|
1762
|
+
react_2.default.createElement(scrollShadow_1.ScrollShadow, { className: "w-full overflow-x-auto ".concat(borderRadius, " border ").concat(borderColor, " ").concat(bgColor, " shadow-sm"), shadowFrom: props.darkMode ? "from-gray-900" : "from-white" },
|
|
1356
1763
|
(props.selectAll || ((_t = (_s = props.selectedIds) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) > 0) &&
|
|
1357
1764
|
(!props.multiActionFloatingBtns ||
|
|
1358
1765
|
(props.multiActionFloatingBtns &&
|
|
1359
1766
|
props.multiActionFloatingBtns.length <= 0)) && (react_2.default.createElement("div", { className: "sticky left-0 flex flex-row items-center px-4 py-3 gap-x-2" },
|
|
1360
1767
|
renderSelectedCount(),
|
|
1361
1768
|
props.multiActionButton)),
|
|
1362
|
-
react_2.default.createElement("table", { className: "w-full", ref: tableRef },
|
|
1769
|
+
react_2.default.createElement("table", { className: "w-full ".concat(isDragSelecting ? "select-none" : ""), ref: tableRef },
|
|
1363
1770
|
renderTableHeader(),
|
|
1364
1771
|
react_2.default.createElement("tbody", { className: "divide-y ".concat(dividerColor) },
|
|
1365
1772
|
props.loading &&
|
|
@@ -1367,93 +1774,7 @@ var NewTable = function (props) {
|
|
|
1367
1774
|
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
1368
1775
|
flatColumns.map(function (col) { return (react_2.default.createElement("td", { key: col.key, className: cellPadding },
|
|
1369
1776
|
react_2.default.createElement("div", { className: "h-5 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }))); }),
|
|
1370
|
-
!props.loading &&
|
|
1371
|
-
props.data.map(function (row, index) {
|
|
1372
|
-
var _a, _b, _c, _d;
|
|
1373
|
-
var spaceRow = (_a = props.spaceData) === null || _a === void 0 ? void 0 : _a[index];
|
|
1374
|
-
var isSelected = ((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.includes(row.id)) !== null && _c !== void 0 ? _c : false) ||
|
|
1375
|
-
((_d = props.selectAll) !== null && _d !== void 0 ? _d : false);
|
|
1376
|
-
var rowBgClass = isSelected ? selectedRowBg : bgColor;
|
|
1377
|
-
var isRowHoverable = !!props.onClickRow && !isSelected;
|
|
1378
|
-
return (react_2.default.createElement("tr", { key: row.id, onClick: function (e) {
|
|
1379
|
-
if (props.onClickRow) {
|
|
1380
|
-
props.onClickRow(row.id, row, spaceRow);
|
|
1381
|
-
}
|
|
1382
|
-
e.preventDefault();
|
|
1383
|
-
}, className: "group ".concat(isSelected
|
|
1384
|
-
? selectedRowBg
|
|
1385
|
-
: props.onClickRow
|
|
1386
|
-
? "cursor-pointer ".concat(rowHoverBg)
|
|
1387
|
-
: editDataIsLoading && editDataRowId === row.id
|
|
1388
|
-
? "animate-pulse"
|
|
1389
|
-
: "") },
|
|
1390
|
-
props.checkbox && (react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? "".concat(rowBgClass, " ").concat(isRowHoverable ? (props.darkMode ? "group-hover:bg-gray-700" : "group-hover:bg-gray-100") : "") : ""), style: hasPinColumns
|
|
1391
|
-
? {
|
|
1392
|
-
position: "sticky",
|
|
1393
|
-
left: 0,
|
|
1394
|
-
zIndex: 1,
|
|
1395
|
-
width: CHECKBOX_WIDTH,
|
|
1396
|
-
minWidth: CHECKBOX_WIDTH,
|
|
1397
|
-
}
|
|
1398
|
-
: undefined, onClick: function (e) { return handleSelectRow(row.id, e); } }, renderCheckbox(isSelected, function () { }, undefined, isMaxReached && !isSelected
|
|
1399
|
-
? "opacity-50 cursor-not-allowed"
|
|
1400
|
-
: ""))),
|
|
1401
|
-
flatColumns.map(function (col, colIndex) {
|
|
1402
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1403
|
-
var cellValue = spaceRow
|
|
1404
|
-
? spaceRow[col.key]
|
|
1405
|
-
: resolveValue(row, col.key);
|
|
1406
|
-
// INFO: first col with type "string" is never made editable
|
|
1407
|
-
var resolvedColType = (_a = col.type) !== null && _a !== void 0 ? _a : "string";
|
|
1408
|
-
var isActionColumn = col.key === "update" && !col.type;
|
|
1409
|
-
var isModalEdit = ((_b = props.editable) === null || _b === void 0 ? void 0 : _b.active) &&
|
|
1410
|
-
!isActionColumn &&
|
|
1411
|
-
utils_1.supportedModalEditList.includes(resolvedColType);
|
|
1412
|
-
var isObjectEdit = ((_c = props.editable) === null || _c === void 0 ? void 0 : _c.active) &&
|
|
1413
|
-
!isActionColumn &&
|
|
1414
|
-
resolvedColType === "object" &&
|
|
1415
|
-
!!props.onObjectEdit;
|
|
1416
|
-
var isEditable = ((_d = props.editable) === null || _d === void 0 ? void 0 : _d.active) &&
|
|
1417
|
-
!isActionColumn &&
|
|
1418
|
-
!(((_f = (_e = props.selectedIds) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0 ||
|
|
1419
|
-
props.selectAll) &&
|
|
1420
|
-
utils_1.supportedInlineEditList.includes(resolvedColType);
|
|
1421
|
-
var rowData = editDataRowId === row.id ? editDataValue : row;
|
|
1422
|
-
if (isObjectEdit) {
|
|
1423
|
-
return (react_2.default.createElement("td", { key: col.key, className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " whitespace-nowrap") },
|
|
1424
|
-
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-object-edit-".concat(col.key), onClick: function (e) {
|
|
1425
|
-
var _a;
|
|
1426
|
-
e.stopPropagation();
|
|
1427
|
-
(_a = props.onObjectEdit) === null || _a === void 0 ? void 0 : _a.call(props, row.id, col.key, row);
|
|
1428
|
-
} },
|
|
1429
|
-
handleCheckModalEditEmpty(cellValue) ? (react_2.default.createElement("span", { className: "text-gray-400 italic" }, "Add")) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord)),
|
|
1430
|
-
react_2.default.createElement(outline_1.PencilIcon, { className: "w-3.5 h-3.5 text-gray-400 opacity-0 group-hover/modaledit:opacity-100 flex-shrink-0" }))));
|
|
1431
|
-
}
|
|
1432
|
-
if (isModalEdit) {
|
|
1433
|
-
return (react_2.default.createElement("td", { key: col.key, className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " whitespace-nowrap") },
|
|
1434
|
-
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-modal-edit-".concat(col.key), onClick: function (e) {
|
|
1435
|
-
e.stopPropagation();
|
|
1436
|
-
handleModalEditOnClick(row.id, col.key, row);
|
|
1437
|
-
} },
|
|
1438
|
-
handleCheckModalEditEmpty(cellValue) ? (react_2.default.createElement("span", { className: "text-gray-400 italic" }, "Add")) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord)),
|
|
1439
|
-
react_2.default.createElement(outline_1.PencilIcon, { className: "w-3.5 h-3.5 text-gray-400 opacity-0 group-hover/modaledit:opacity-100 flex-shrink-0" }))));
|
|
1440
|
-
}
|
|
1441
|
-
if (isEditable) {
|
|
1442
|
-
var bareOverride = (_h = (_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareListDescription) === null || _h === void 0 ? void 0 : _h.call(_g, col.key, cellValue);
|
|
1443
|
-
if (!bareOverride)
|
|
1444
|
-
return renderEditDataInputs(colIndex, col, rowData, row.id, rowBgClass, isRowHoverable);
|
|
1445
|
-
}
|
|
1446
|
-
return (
|
|
1447
|
-
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
1448
|
-
react_2.default.createElement("td", { key: col.key, "data-pin-key": leftPinned.includes(col.key) ||
|
|
1449
|
-
rightPinned.includes(col.key)
|
|
1450
|
-
? col.key
|
|
1451
|
-
: undefined, className: "".concat(cellPadding, " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((_k = (_j = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _j === void 0 ? void 0 : _j.className) !== null && _k !== void 0 ? _k : ""), style: (_l = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _l === void 0 ? void 0 : _l.style }, props.newTabUrl && props.onClickRow ? (react_2.default.createElement(link_1.Link, { href: props.newTabUrl +
|
|
1452
|
-
row.id +
|
|
1453
|
-
((_m = props.addNewTabUrl) !== null && _m !== void 0 ? _m : ""), className: "w-full block", linkType: props.linkType, custom: props.custom }, (0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))));
|
|
1454
|
-
}),
|
|
1455
|
-
renderActionColumnCell(row.id)));
|
|
1456
|
-
}),
|
|
1777
|
+
!props.loading && renderDesktopRows(),
|
|
1457
1778
|
!props.loading && addData && renderAddDataRow())),
|
|
1458
1779
|
!props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (_u = props.emptyTitle) !== null && _u !== void 0 ? _u : "No items")),
|
|
1459
1780
|
renderAddableSection()),
|