blixify-ui-web 1.2.11 → 1.2.12
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/iconButton/index.d.ts +1 -0
- package/lib/components/action/iconButton/index.d.ts.map +1 -1
- package/lib/components/action/iconButton/index.js +2 -1
- package/lib/components/action/iconButton/index.js.map +1 -1
- package/lib/components/data/dataTemplate/flexFilterModel.d.ts +18 -0
- package/lib/components/data/dataTemplate/flexFilterModel.d.ts.map +1 -0
- package/lib/components/data/dataTemplate/flexFilterModel.js +50 -0
- package/lib/components/data/dataTemplate/flexFilterModel.js.map +1 -0
- package/lib/components/data/dataTemplate/flexFilterModule.d.ts +53 -0
- package/lib/components/data/dataTemplate/flexFilterModule.d.ts.map +1 -0
- package/lib/components/data/dataTemplate/flexFilterModule.js +373 -0
- package/lib/components/data/dataTemplate/flexFilterModule.js.map +1 -0
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +226 -87
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +2 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/data/listModule.d.ts +9 -2
- package/lib/components/data/listModule.d.ts.map +1 -1
- package/lib/components/data/listModule.js +134 -12
- package/lib/components/data/listModule.js.map +1 -1
- package/lib/components/data/testSchema.d.ts +26 -0
- package/lib/components/data/testSchema.d.ts.map +1 -1
- package/lib/components/data/testSchema.js +407 -1
- package/lib/components/data/testSchema.js.map +1 -1
- package/lib/components/display/detailList/index.d.ts +1 -0
- package/lib/components/display/detailList/index.d.ts.map +1 -1
- package/lib/components/display/detailList/index.js +2 -2
- package/lib/components/display/detailList/index.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts +54 -3
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +769 -74
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -10,6 +10,65 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
13
72
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
73
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
74
|
if (ar || !(i in from)) {
|
|
@@ -25,14 +84,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
85
|
exports.NewTable = void 0;
|
|
27
86
|
var solid_1 = require("@heroicons/react/24/solid");
|
|
87
|
+
var solid_2 = require("@heroicons/react/24/solid");
|
|
88
|
+
var solid_3 = require("@heroicons/react/20/solid");
|
|
89
|
+
var outline_1 = require("@heroicons/react/24/outline");
|
|
28
90
|
var react_1 = require("@headlessui/react");
|
|
29
|
-
var
|
|
91
|
+
var axios_1 = __importDefault(require("axios"));
|
|
92
|
+
var react_2 = __importStar(require("react"));
|
|
30
93
|
var collapse_1 = require("../../advanced/collapse");
|
|
31
94
|
var popUp_1 = require("../../advanced/popUp");
|
|
32
95
|
var readModule_1 = require("../../data/readModule");
|
|
96
|
+
var updateModule_1 = require("../../data/updateModule");
|
|
97
|
+
var utils_1 = require("../../data/utils");
|
|
33
98
|
var detailList_1 = require("../detailList");
|
|
34
99
|
var textButton_1 = require("../../action/textButton");
|
|
35
100
|
var iconButton_1 = require("../../action/iconButton");
|
|
101
|
+
var link_1 = require("../../structure/link");
|
|
102
|
+
var modal_1 = require("../modal");
|
|
36
103
|
// INFO: resolve dotted key paths (e.g. "group.subKey") against a row object.
|
|
37
104
|
// Required because flatColumns uses "parent.child" keys for groupData sub-columns.
|
|
38
105
|
var resolveValue = function (row, key) {
|
|
@@ -44,23 +111,19 @@ var resolveValue = function (row, key) {
|
|
|
44
111
|
return value;
|
|
45
112
|
};
|
|
46
113
|
var NewTable = function (props) {
|
|
47
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48
|
-
var bg = props.darkMode ? "bg-gray-900" : "bg-white";
|
|
49
|
-
var borderRadius = "rounded-2xl";
|
|
50
|
-
var borderColor = props.darkMode ? "border-gray-700" : "border-gray-100";
|
|
51
|
-
var divider = props.darkMode ? "divide-gray-800" : "divide-gray-100";
|
|
52
|
-
var selectedRowBg = props.darkMode ? "bg-primary-900" : "bg-primary-50";
|
|
53
|
-
var cellFontColor = props.darkMode ? "text-gray-200" : "text-gray-700";
|
|
54
|
-
var cellPadding = "px-4 py-2";
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
55
115
|
var columns = (_b = (_a = props.columns) !== null && _a !== void 0 ? _a : props.header) !== null && _b !== void 0 ? _b : [];
|
|
56
116
|
var defaultLimit = 10;
|
|
57
117
|
var defaultPageSize = 5;
|
|
58
118
|
// INFO: flatten groupData columns so both mobile and desktop share the same
|
|
59
119
|
// resolved column list — groupData parent becomes individual sub-columns.
|
|
120
|
+
// Also filters out id/_id columns unless showId is explicitly enabled.
|
|
60
121
|
var flatColumns = [];
|
|
61
122
|
columns.forEach(function (col) {
|
|
62
123
|
if (col.hide)
|
|
63
124
|
return;
|
|
125
|
+
if (!props.showId && (col.key === "id" || col.key === "_id"))
|
|
126
|
+
return;
|
|
64
127
|
var groupData = col.groupData;
|
|
65
128
|
if (groupData && groupData.length > 0) {
|
|
66
129
|
groupData.forEach(function (sub) {
|
|
@@ -71,6 +134,291 @@ var NewTable = function (props) {
|
|
|
71
134
|
flatColumns.push(col);
|
|
72
135
|
}
|
|
73
136
|
});
|
|
137
|
+
// INFO: compute sticky left/right offsets for pinned columns.
|
|
138
|
+
var DEFAULT_PIN_WIDTH = 150;
|
|
139
|
+
var CHECKBOX_WIDTH = 66;
|
|
140
|
+
// INFO: keys that belong to grouped columns — these cannot be pinned.
|
|
141
|
+
var groupedKeys = new Set();
|
|
142
|
+
columns.forEach(function (col) {
|
|
143
|
+
var groupData = col.groupData;
|
|
144
|
+
if (groupData && groupData.length > 0) {
|
|
145
|
+
groupData.forEach(function (sub) { return groupedKeys.add("".concat(col.key, ".").concat(sub.key)); });
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
var leftPinned = ((_d = (_c = props.pinColumns) === null || _c === void 0 ? void 0 : _c.left) !== null && _d !== void 0 ? _d : []).filter(function (key) { return !groupedKeys.has(key); });
|
|
149
|
+
var rightPinned = ((_f = (_e = props.pinColumns) === null || _e === void 0 ? void 0 : _e.right) !== null && _f !== void 0 ? _f : []).filter(function (key) { return !groupedKeys.has(key); });
|
|
150
|
+
var hasPinColumns = leftPinned.length > 0 || rightPinned.length > 0;
|
|
151
|
+
// INFO: reorder flatColumns so left-pinned come first, right-pinned come last.
|
|
152
|
+
if (hasPinColumns) {
|
|
153
|
+
var leftCols = leftPinned
|
|
154
|
+
.map(function (key) { return flatColumns.find(function (c) { return c.key === key; }); })
|
|
155
|
+
.filter(Boolean);
|
|
156
|
+
var rightCols = rightPinned
|
|
157
|
+
.map(function (key) { return flatColumns.find(function (c) { return c.key === key; }); })
|
|
158
|
+
.filter(Boolean);
|
|
159
|
+
var middleCols = flatColumns.filter(function (c) { return !leftPinned.includes(c.key) && !rightPinned.includes(c.key); });
|
|
160
|
+
flatColumns.length = 0;
|
|
161
|
+
flatColumns.push.apply(flatColumns, __spreadArray(__spreadArray(__spreadArray([], leftCols, false), middleCols, false), rightCols, false));
|
|
162
|
+
}
|
|
163
|
+
var _p = (0, react_2.useState)(props.fixedPagination ? true : false), isFixed = _p[0], setIsFixed = _p[1];
|
|
164
|
+
//=====================================================================================
|
|
165
|
+
// SECTION: Advanced Settings
|
|
166
|
+
//=====================================================================================
|
|
167
|
+
var _q = (0, react_2.useState)(""), filterModal = _q[0], setFilterModal = _q[1];
|
|
168
|
+
var _r = (0, react_2.useState)(""), addColumnModal = _r[0], setAddColumnModal = _r[1];
|
|
169
|
+
//=====================================================================================
|
|
170
|
+
// SECTION: Editable & Addable cells
|
|
171
|
+
//=====================================================================================
|
|
172
|
+
var _s = (0, react_2.useState)(""), editDataRowId = _s[0], setEditDataRowId = _s[1];
|
|
173
|
+
var _t = (0, react_2.useState)(""), editDataHeaderKey = _t[0], setEditDataHeaderKey = _t[1];
|
|
174
|
+
var _u = (0, react_2.useState)({}), editDataValue = _u[0], setEditDataValue = _u[1];
|
|
175
|
+
var _v = (0, react_2.useState)(false), editDataIsLoading = _v[0], setEditDataIsLoading = _v[1];
|
|
176
|
+
var _w = (0, react_2.useState)(false), addData = _w[0], setAddData = _w[1];
|
|
177
|
+
var _x = (0, react_2.useState)({}), addDataValue = _x[0], setAddDataValue = _x[1];
|
|
178
|
+
var _y = (0, react_2.useState)({}), referencesOptions = _y[0], setReferencesOptions = _y[1];
|
|
179
|
+
var _z = (0, react_2.useState)({}), referencesDetails = _z[0], setReferencesDetails = _z[1];
|
|
180
|
+
var _0 = (0, react_2.useState)(false), referenceLoading = _0[0], setReferenceLoading = _0[1];
|
|
181
|
+
var editDataValueRef = (0, react_2.useRef)({});
|
|
182
|
+
var editDataRowIdRef = (0, react_2.useRef)("");
|
|
183
|
+
var editDataInputRefs = (0, react_2.useRef)([]);
|
|
184
|
+
var addDataValueRef = (0, react_2.useRef)({});
|
|
185
|
+
var addDataInputRefs = (0, react_2.useRef)([]);
|
|
186
|
+
// INFO: holds the original row snapshot at the moment editing starts —
|
|
187
|
+
// never mutated during editing so we can diff against it on blur.
|
|
188
|
+
var originalDataRef = (0, react_2.useRef)({});
|
|
189
|
+
//=====================================================================================
|
|
190
|
+
// SECTION: Style & Classname
|
|
191
|
+
//=====================================================================================
|
|
192
|
+
var bgColor = props.darkMode
|
|
193
|
+
? props.darkModeBg || "bg-gray-900"
|
|
194
|
+
: "bg-white";
|
|
195
|
+
var borderRadius = "rounded-2xl";
|
|
196
|
+
var borderColor = props.darkMode ? "border-gray-700" : "border-gray-100";
|
|
197
|
+
var selectedRowBg = props.darkMode ? "bg-primary-900" : "bg-primary-50";
|
|
198
|
+
var rowHoverBg = props.darkMode ? "hover:bg-gray-700" : "hover:bg-gray-100";
|
|
199
|
+
var dividerColor = props.darkMode ? "divide-gray-700" : "divide-gray-100";
|
|
200
|
+
var cellFontColor = props.darkMode ? "text-gray-200" : "text-gray-700";
|
|
201
|
+
var titleFontColor = props.darkMode
|
|
202
|
+
? "text-primary-300 font-medium"
|
|
203
|
+
: "text-primary-600 font-medium";
|
|
204
|
+
var cellPadding = "px-4 py-2";
|
|
205
|
+
var tableHeaderBgColor = props.tableHeaderBgColor
|
|
206
|
+
? props.tableHeaderBgColor
|
|
207
|
+
: props.darkMode
|
|
208
|
+
? "bg-gray-800"
|
|
209
|
+
: "bg-gray-50";
|
|
210
|
+
var tableHeaderFontColor = props.tableHeaderTextColor
|
|
211
|
+
? props.tableHeaderTextColor
|
|
212
|
+
: props.darkMode
|
|
213
|
+
? "text-gray-300"
|
|
214
|
+
: "text-gray-500";
|
|
215
|
+
// INFO: when selection is active, cancel any open add row and clear edit state —
|
|
216
|
+
// selecting rows and editing/adding simultaneously would be confusing UX.
|
|
217
|
+
(0, react_2.useEffect)(function () {
|
|
218
|
+
var hasSelection = (props.selectedIds && props.selectedIds.length > 0) || props.selectAll;
|
|
219
|
+
if (!hasSelection)
|
|
220
|
+
return;
|
|
221
|
+
// clear add row
|
|
222
|
+
addDataValueRef.current = {};
|
|
223
|
+
setAddData(false);
|
|
224
|
+
setAddDataValue({});
|
|
225
|
+
// clear edit state
|
|
226
|
+
editDataRowIdRef.current = "";
|
|
227
|
+
editDataValueRef.current = {};
|
|
228
|
+
setEditDataRowId("");
|
|
229
|
+
setEditDataValue({});
|
|
230
|
+
setEditDataHeaderKey("");
|
|
231
|
+
}, [props.selectedIds, props.selectAll]);
|
|
232
|
+
(0, react_2.useEffect)(function () {
|
|
233
|
+
if (!props.fixedPagination)
|
|
234
|
+
return;
|
|
235
|
+
var handleScroll = function () {
|
|
236
|
+
var paginationEl = document.querySelector(".pagination-container");
|
|
237
|
+
var paginationPosition = paginationEl === null || paginationEl === void 0 ? void 0 : paginationEl.getBoundingClientRect().top;
|
|
238
|
+
if (paginationPosition) {
|
|
239
|
+
// INFO: when scrollY is less than the pagination's natural position,
|
|
240
|
+
// keep it fixed at the bottom of the viewport.
|
|
241
|
+
if (window.scrollY < paginationPosition) {
|
|
242
|
+
setIsFixed(true);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
setIsFixed(false);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
window.addEventListener("scroll", handleScroll);
|
|
250
|
+
return function () { return window.removeEventListener("scroll", handleScroll); };
|
|
251
|
+
}, [props.fixedPagination]);
|
|
252
|
+
var handleCancelAdd = function () {
|
|
253
|
+
addDataValueRef.current = {};
|
|
254
|
+
setAddData(false);
|
|
255
|
+
setAddDataValue({});
|
|
256
|
+
};
|
|
257
|
+
var handleValidateAddColumns = function () {
|
|
258
|
+
var filtered = props.showId
|
|
259
|
+
? flatColumns
|
|
260
|
+
: flatColumns.filter(function (c) { return c.key !== "id" && c.key !== "_id"; });
|
|
261
|
+
if (filtered.length === 0)
|
|
262
|
+
return false;
|
|
263
|
+
return filtered.every(function (col) { return !col.type || utils_1.supportedTableAddList.includes(col.type); });
|
|
264
|
+
};
|
|
265
|
+
var handleConvertColumnToDataStructure = function (cols) {
|
|
266
|
+
return cols.map(function (col) {
|
|
267
|
+
var _a;
|
|
268
|
+
return (__assign(__assign({}, col), { id: col.key, name: col.title, type: (_a = col.type) !== null && _a !== void 0 ? _a : "string" }));
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
var handleCreateFormInputRefs = function (type) {
|
|
272
|
+
// INFO: one ref per column so indices always align with flatColumns.map colIndex
|
|
273
|
+
var refs = flatColumns.map(function () { return (0, react_2.createRef)(); });
|
|
274
|
+
if (type === "add")
|
|
275
|
+
addDataInputRefs.current = refs;
|
|
276
|
+
else
|
|
277
|
+
editDataInputRefs.current = refs;
|
|
278
|
+
};
|
|
279
|
+
var handleCheckFormInputRefs = function (type) { return __awaiter(void 0, void 0, void 0, function () {
|
|
280
|
+
var refs, valid;
|
|
281
|
+
return __generator(this, function (_a) {
|
|
282
|
+
switch (_a.label) {
|
|
283
|
+
case 0:
|
|
284
|
+
refs = type === "add" ? addDataInputRefs.current : editDataInputRefs.current;
|
|
285
|
+
valid = true;
|
|
286
|
+
return [4 /*yield*/, Promise.all(refs.map(function (ref) { return __awaiter(void 0, void 0, void 0, function () {
|
|
287
|
+
var ok;
|
|
288
|
+
var _a;
|
|
289
|
+
return __generator(this, function (_b) {
|
|
290
|
+
switch (_b.label) {
|
|
291
|
+
case 0:
|
|
292
|
+
if (!((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.handleSubmit)) return [3 /*break*/, 2];
|
|
293
|
+
return [4 /*yield*/, ref.current.handleSubmit()];
|
|
294
|
+
case 1:
|
|
295
|
+
ok = _b.sent();
|
|
296
|
+
if (!ok)
|
|
297
|
+
valid = false;
|
|
298
|
+
_b.label = 2;
|
|
299
|
+
case 2: return [2 /*return*/, null];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}); }))];
|
|
303
|
+
case 1:
|
|
304
|
+
_a.sent();
|
|
305
|
+
return [2 /*return*/, valid];
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}); };
|
|
309
|
+
var handleGenerateClonedData = function () {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
return (0, updateModule_1.handleClonedDataAttribute)(addData ? addDataValueRef.current : editDataValueRef.current, handleConvertColumnToDataStructure(flatColumns), (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.server) !== null && _b !== void 0 ? _b : "mongoServer");
|
|
312
|
+
};
|
|
313
|
+
var handleUpdateChangeData = function (data) {
|
|
314
|
+
if (addData) {
|
|
315
|
+
addDataValueRef.current = data;
|
|
316
|
+
setAddDataValue(data);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
editDataValueRef.current = data;
|
|
320
|
+
setEditDataValue(data);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var handleOnChangeText = function (e) {
|
|
324
|
+
var cloned = handleGenerateClonedData();
|
|
325
|
+
cloned[e.target.id] = e.target.value;
|
|
326
|
+
handleUpdateChangeData(cloned);
|
|
327
|
+
};
|
|
328
|
+
var handleOnChangeSelect = function (id, value) {
|
|
329
|
+
var cloned = handleGenerateClonedData();
|
|
330
|
+
cloned[id] = value;
|
|
331
|
+
handleUpdateChangeData(cloned);
|
|
332
|
+
};
|
|
333
|
+
var handleOnChangeDate = function (id, value) {
|
|
334
|
+
var cloned = handleGenerateClonedData();
|
|
335
|
+
cloned[id] = value;
|
|
336
|
+
handleUpdateChangeData(cloned);
|
|
337
|
+
};
|
|
338
|
+
var handleOnChangeAddress = function (id, address) {
|
|
339
|
+
var cloned = handleGenerateClonedData();
|
|
340
|
+
cloned[id] = address;
|
|
341
|
+
handleUpdateChangeData(cloned);
|
|
342
|
+
};
|
|
343
|
+
var handleEditDataOnClick = function (rowId, headerKey, rowData) {
|
|
344
|
+
if (editDataRowIdRef.current !== rowId) {
|
|
345
|
+
editDataRowIdRef.current = rowId;
|
|
346
|
+
editDataValueRef.current = rowData;
|
|
347
|
+
originalDataRef.current = rowData;
|
|
348
|
+
setEditDataRowId(rowId);
|
|
349
|
+
setEditDataValue(rowData);
|
|
350
|
+
handleCreateFormInputRefs("edit");
|
|
351
|
+
}
|
|
352
|
+
setEditDataHeaderKey(headerKey);
|
|
353
|
+
};
|
|
354
|
+
var handleEditDataOnBlur = function (columnId, updateData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
355
|
+
var currentRowId, valid, isDiff;
|
|
356
|
+
var _a, _b;
|
|
357
|
+
return __generator(this, function (_c) {
|
|
358
|
+
switch (_c.label) {
|
|
359
|
+
case 0:
|
|
360
|
+
currentRowId = editDataRowIdRef.current;
|
|
361
|
+
return [4 /*yield*/, handleCheckFormInputRefs("edit")];
|
|
362
|
+
case 1:
|
|
363
|
+
valid = _c.sent();
|
|
364
|
+
if (!valid)
|
|
365
|
+
return [2 /*return*/];
|
|
366
|
+
if (!((_a = props.editable) === null || _a === void 0 ? void 0 : _a.onUpdateData))
|
|
367
|
+
return [2 /*return*/];
|
|
368
|
+
isDiff = JSON.stringify(updateData === null || updateData === void 0 ? void 0 : updateData[columnId]) !==
|
|
369
|
+
JSON.stringify((_b = originalDataRef === null || originalDataRef === void 0 ? void 0 : originalDataRef.current) === null || _b === void 0 ? void 0 : _b[columnId]);
|
|
370
|
+
if (!isDiff)
|
|
371
|
+
return [2 /*return*/];
|
|
372
|
+
setEditDataIsLoading(true);
|
|
373
|
+
return [4 /*yield*/, props.editable.onUpdateData(currentRowId, columnId, updateData)];
|
|
374
|
+
case 2:
|
|
375
|
+
_c.sent();
|
|
376
|
+
setEditDataIsLoading(false);
|
|
377
|
+
// INFO: only clear if the same row and column are still active
|
|
378
|
+
if (editDataHeaderKey === columnId &&
|
|
379
|
+
editDataRowIdRef.current === currentRowId) {
|
|
380
|
+
editDataRowIdRef.current = "";
|
|
381
|
+
editDataValueRef.current = {};
|
|
382
|
+
setEditDataRowId("");
|
|
383
|
+
setEditDataValue({});
|
|
384
|
+
setEditDataHeaderKey("");
|
|
385
|
+
}
|
|
386
|
+
return [2 /*return*/];
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}); };
|
|
390
|
+
var handleDragStart = function (e, id) {
|
|
391
|
+
e.dataTransfer.setData("itemId", id);
|
|
392
|
+
};
|
|
393
|
+
var handleDragOver = function (e) {
|
|
394
|
+
e.preventDefault();
|
|
395
|
+
};
|
|
396
|
+
var handleDrop = function (e, id) {
|
|
397
|
+
var _a, _b;
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
var data = e.dataTransfer.getData("itemId");
|
|
400
|
+
if (data && id && data !== id) {
|
|
401
|
+
var clonedHeader = JSON.parse(JSON.stringify(columns));
|
|
402
|
+
var selectedIndex = clonedHeader.findIndex(function (item) { return item.key === data; });
|
|
403
|
+
var selectedItem = clonedHeader.splice(selectedIndex, 1)[0];
|
|
404
|
+
var placingIndex = clonedHeader.findIndex(function (item) { return item.key === id; });
|
|
405
|
+
clonedHeader.splice(placingIndex, 0, selectedItem);
|
|
406
|
+
(_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onDragColumn) === null || _b === void 0 ? void 0 : _b.call(_a, data, id, clonedHeader);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var handleSort = function (id, type) {
|
|
410
|
+
var _a, _b;
|
|
411
|
+
(_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onSortColumn) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
412
|
+
sortId: id,
|
|
413
|
+
type: type === "new" ? "asc" : type,
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
var handleAddColumnModal = function (id) {
|
|
417
|
+
setAddColumnModal(id);
|
|
418
|
+
};
|
|
419
|
+
var handleFilterModal = function (id) {
|
|
420
|
+
setFilterModal(id);
|
|
421
|
+
};
|
|
74
422
|
var handleSelectRow = function (rowId, e) {
|
|
75
423
|
var _a, _b;
|
|
76
424
|
e.stopPropagation();
|
|
@@ -139,6 +487,82 @@ var NewTable = function (props) {
|
|
|
139
487
|
(_a = props.handleSelectAll) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
140
488
|
(_b = props.handleSelectedIds) === null || _b === void 0 ? void 0 : _b.call(props, []);
|
|
141
489
|
};
|
|
490
|
+
// INFO: returns sticky style, border, and background class for a pinned column cell.
|
|
491
|
+
// Returns undefined when the column is not pinned.
|
|
492
|
+
var getPinProps = function (colKey, isHeader, rowBg, isHoverable) {
|
|
493
|
+
var _a;
|
|
494
|
+
if (!hasPinColumns)
|
|
495
|
+
return undefined;
|
|
496
|
+
// INFO: extract numeric px value from a Tailwind width class (e.g. "w-[200px]" → 200, "w-48" → 192).
|
|
497
|
+
var parsePinWidth = function (key) {
|
|
498
|
+
var col = flatColumns.find(function (c) { return c.key === key; });
|
|
499
|
+
if (!(col === null || col === void 0 ? void 0 : col.width))
|
|
500
|
+
return DEFAULT_PIN_WIDTH;
|
|
501
|
+
var arbMatch = col.width.match(/\[(\d+)px\]/);
|
|
502
|
+
if (arbMatch)
|
|
503
|
+
return parseInt(arbMatch[1], 10);
|
|
504
|
+
var stdMatch = col.width.match(/w-(\d+)/);
|
|
505
|
+
if (stdMatch)
|
|
506
|
+
return parseInt(stdMatch[1], 10) * 4;
|
|
507
|
+
return DEFAULT_PIN_WIDTH;
|
|
508
|
+
};
|
|
509
|
+
var style;
|
|
510
|
+
var borderClass = "";
|
|
511
|
+
var leftIdx = leftPinned.indexOf(colKey);
|
|
512
|
+
var rightIdx = rightPinned.indexOf(colKey);
|
|
513
|
+
var pinBase = "sticky z-[2] relative whitespace-normal break-words";
|
|
514
|
+
var afterBase = "after:absolute after:top-0 after:bottom-0 after:w-px after:pointer-events-none";
|
|
515
|
+
var afterColor = props.darkMode
|
|
516
|
+
? "after:bg-gray-700"
|
|
517
|
+
: "after:bg-gray-200";
|
|
518
|
+
if (leftIdx >= 0) {
|
|
519
|
+
var baseOffset = props.checkbox &&
|
|
520
|
+
(props.data.length > 0 ||
|
|
521
|
+
(props.spaceData && ((_a = props.spaceData) === null || _a === void 0 ? void 0 : _a.length) > 0))
|
|
522
|
+
? CHECKBOX_WIDTH
|
|
523
|
+
: 0;
|
|
524
|
+
// INFO: offset = sum of widths of all preceding left-pinned columns
|
|
525
|
+
var left = leftPinned
|
|
526
|
+
.slice(0, leftIdx)
|
|
527
|
+
.reduce(function (sum, key) { return sum + parsePinWidth(key); }, baseOffset);
|
|
528
|
+
var colWidth = parsePinWidth(colKey);
|
|
529
|
+
style = {
|
|
530
|
+
left: left,
|
|
531
|
+
width: colWidth,
|
|
532
|
+
minWidth: colWidth,
|
|
533
|
+
maxWidth: colWidth,
|
|
534
|
+
overflowWrap: "break-word",
|
|
535
|
+
};
|
|
536
|
+
borderClass = "".concat(pinBase, " ").concat(afterBase, " after:right-0 ").concat(afterColor);
|
|
537
|
+
}
|
|
538
|
+
else if (rightIdx >= 0) {
|
|
539
|
+
// INFO: offset = sum of widths of all right-pinned columns after this one
|
|
540
|
+
var right = rightPinned
|
|
541
|
+
.slice(rightIdx + 1)
|
|
542
|
+
.reduce(function (sum, key) { return sum + parsePinWidth(key); }, 0);
|
|
543
|
+
var colWidth = parsePinWidth(colKey);
|
|
544
|
+
style = {
|
|
545
|
+
right: right,
|
|
546
|
+
width: colWidth,
|
|
547
|
+
minWidth: colWidth,
|
|
548
|
+
maxWidth: colWidth,
|
|
549
|
+
overflowWrap: "break-word",
|
|
550
|
+
};
|
|
551
|
+
borderClass = "".concat(pinBase, " ").concat(afterBase, " after:left-0 ").concat(afterColor);
|
|
552
|
+
}
|
|
553
|
+
if (!style)
|
|
554
|
+
return undefined;
|
|
555
|
+
var bg = isHeader ? tableHeaderBgColor : (rowBg !== null && rowBg !== void 0 ? rowBg : bgColor);
|
|
556
|
+
var hoverClass = !isHeader && isHoverable
|
|
557
|
+
? props.darkMode
|
|
558
|
+
? "group-hover:bg-gray-700"
|
|
559
|
+
: "group-hover:bg-gray-100"
|
|
560
|
+
: "";
|
|
561
|
+
return {
|
|
562
|
+
style: style,
|
|
563
|
+
className: "".concat(bg, " ").concat(hoverClass, " ").concat(borderClass),
|
|
564
|
+
};
|
|
565
|
+
};
|
|
142
566
|
var renderCheckAllSelected = function () {
|
|
143
567
|
var _a, _b;
|
|
144
568
|
var currentPageData = [];
|
|
@@ -174,6 +598,117 @@ var NewTable = function (props) {
|
|
|
174
598
|
}
|
|
175
599
|
return false;
|
|
176
600
|
};
|
|
601
|
+
var renderFormCell = function (data, ds, ref, cellInput) {
|
|
602
|
+
return (0, updateModule_1.renderDataTemplateForm)(data, [ds],
|
|
603
|
+
// INFO: empty refs array when not actively editing this row
|
|
604
|
+
ref !== null ? [ref] : [], {
|
|
605
|
+
handleOnChangeAddress: handleOnChangeAddress,
|
|
606
|
+
handleOnChangeText: handleOnChangeText,
|
|
607
|
+
handleOnChangeSelect: handleOnChangeSelect,
|
|
608
|
+
handleOnChangeDate: handleOnChangeDate,
|
|
609
|
+
}, false, cellInput, undefined, {
|
|
610
|
+
dbModule: axios_1.default,
|
|
611
|
+
devSettings: props.devSettings,
|
|
612
|
+
referencesOptions: referencesOptions,
|
|
613
|
+
referencesDetails: referencesDetails,
|
|
614
|
+
referenceLoading: referenceLoading,
|
|
615
|
+
setReferenceLoading: setReferenceLoading,
|
|
616
|
+
setReferencesOptions: setReferencesOptions,
|
|
617
|
+
setReferencesDetails: setReferencesDetails,
|
|
618
|
+
});
|
|
619
|
+
};
|
|
620
|
+
var renderEditDataInputs = function (colIndex, col, rowData, rowId, rowBgClass, isHoverable) {
|
|
621
|
+
var _a, _b, _c, _d;
|
|
622
|
+
var tempDS = __assign(__assign({}, col), { id: col.key, name: col.title, type: (_a = col.type) !== null && _a !== void 0 ? _a : "string" });
|
|
623
|
+
var editingRow = editDataRowId === rowId;
|
|
624
|
+
return (react_2.default.createElement("td", { key: col.key + String(colIndex),
|
|
625
|
+
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
626
|
+
className: "".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 },
|
|
627
|
+
react_2.default.createElement("div", { className: "w-max mb-1", onClick: function (e) {
|
|
628
|
+
e.stopPropagation();
|
|
629
|
+
handleEditDataOnClick(rowId, col.key, rowData);
|
|
630
|
+
} }, renderFormCell(rowData, tempDS, editingRow ? editDataInputRefs.current[colIndex] : null, {
|
|
631
|
+
active: true,
|
|
632
|
+
onBlur: function (updateData) {
|
|
633
|
+
return handleEditDataOnBlur(col.key, updateData !== null && updateData !== void 0 ? updateData : rowData);
|
|
634
|
+
},
|
|
635
|
+
}))));
|
|
636
|
+
};
|
|
637
|
+
var renderActionColumnHeader = function () {
|
|
638
|
+
var _a;
|
|
639
|
+
if (((_a = props.deleteable) === null || _a === void 0 ? void 0 : _a.active) || (addData && handleValidateAddColumns())) {
|
|
640
|
+
return (react_2.default.createElement("th", { key: "actions", className: "".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide") }, "Actions"));
|
|
641
|
+
}
|
|
642
|
+
return null;
|
|
643
|
+
};
|
|
644
|
+
var renderDeleteButton = function (rowId) {
|
|
645
|
+
var _a;
|
|
646
|
+
if (!((_a = props.deleteable) === null || _a === void 0 ? void 0 : _a.active))
|
|
647
|
+
return null;
|
|
648
|
+
return (react_2.default.createElement("button", { onClick: function (e) {
|
|
649
|
+
var _a;
|
|
650
|
+
e.preventDefault();
|
|
651
|
+
e.stopPropagation();
|
|
652
|
+
(_a = props.deleteable) === null || _a === void 0 ? void 0 : _a.onDeleteData(rowId);
|
|
653
|
+
}, className: "text-red-500 hover:text-red-700 hover:bg-red-50 p-1 rounded" },
|
|
654
|
+
react_2.default.createElement(outline_1.TrashIcon, { className: "h-4 w-4" })));
|
|
655
|
+
};
|
|
656
|
+
var renderActionColumnCell = function (rowId) {
|
|
657
|
+
var _a;
|
|
658
|
+
if (((_a = props.deleteable) === null || _a === void 0 ? void 0 : _a.active) && !addData) {
|
|
659
|
+
return (react_2.default.createElement("td", { className: "".concat(cellPadding, " text-sm") }, renderDeleteButton(rowId)));
|
|
660
|
+
}
|
|
661
|
+
return null;
|
|
662
|
+
};
|
|
663
|
+
var renderAddDataRow = function () {
|
|
664
|
+
var filteredCols = props.showId
|
|
665
|
+
? flatColumns
|
|
666
|
+
: flatColumns.filter(function (c) { return c.key !== "id" && c.key !== "_id"; });
|
|
667
|
+
var colsAsDS = handleConvertColumnToDataStructure(filteredCols);
|
|
668
|
+
return (react_2.default.createElement("tr", null,
|
|
669
|
+
props.checkbox && react_2.default.createElement("td", null),
|
|
670
|
+
colsAsDS.map(function (ds, index) {
|
|
671
|
+
var _a;
|
|
672
|
+
var originalType = (_a = filteredCols[index]) === null || _a === void 0 ? void 0 : _a.type;
|
|
673
|
+
if (originalType && utils_1.supportedTableAddList.includes(originalType)) {
|
|
674
|
+
return (react_2.default.createElement("td", { key: ds.id + String(index), className: "px-4 py-4 whitespace-nowrap align-top" },
|
|
675
|
+
react_2.default.createElement("div", null, renderFormCell(addDataValue, ds, addDataInputRefs.current[index], { active: true, onBlur: function () { } }))));
|
|
676
|
+
}
|
|
677
|
+
return react_2.default.createElement("td", { key: ds.id + String(index) });
|
|
678
|
+
}),
|
|
679
|
+
react_2.default.createElement("td", { className: "".concat(cellPadding, " text-sm") },
|
|
680
|
+
react_2.default.createElement("div", { className: "flex flex-row gap-2" },
|
|
681
|
+
react_2.default.createElement(iconButton_1.IconButton, { icon: react_2.default.createElement(solid_1.CheckIcon, { className: "w-5 h-5 text-green-500" }), onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
682
|
+
var valid;
|
|
683
|
+
var _a;
|
|
684
|
+
return __generator(this, function (_b) {
|
|
685
|
+
switch (_b.label) {
|
|
686
|
+
case 0: return [4 /*yield*/, handleCheckFormInputRefs("add")];
|
|
687
|
+
case 1:
|
|
688
|
+
valid = _b.sent();
|
|
689
|
+
if (valid) {
|
|
690
|
+
(_a = props.addable) === null || _a === void 0 ? void 0 : _a.onAddData(addDataValueRef.current);
|
|
691
|
+
handleCancelAdd();
|
|
692
|
+
}
|
|
693
|
+
return [2 /*return*/];
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}); } }),
|
|
697
|
+
react_2.default.createElement(iconButton_1.IconButton, { icon: react_2.default.createElement(solid_1.XMarkIcon, { className: "h-5 w-5 text-red-500" }), onClick: handleCancelAdd })))));
|
|
698
|
+
};
|
|
699
|
+
var renderAddableSection = function () {
|
|
700
|
+
var _a;
|
|
701
|
+
if (!((_a = props.addable) === null || _a === void 0 ? void 0 : _a.active) || addData)
|
|
702
|
+
return null;
|
|
703
|
+
var canAdd = handleValidateAddColumns();
|
|
704
|
+
return (react_2.default.createElement("div", { className: "sticky left-0 w-full flex justify-center border-t ".concat(borderColor, " ").concat(bgColor, " px-4 py-3") },
|
|
705
|
+
react_2.default.createElement(textButton_1.TextButton, { text: "Create New Item", onClick: function () {
|
|
706
|
+
if (canAdd) {
|
|
707
|
+
handleCreateFormInputRefs("add");
|
|
708
|
+
setAddData(true);
|
|
709
|
+
}
|
|
710
|
+
}, disable: !canAdd, className: "text-sm" })));
|
|
711
|
+
};
|
|
177
712
|
var renderSelectAll = function () {
|
|
178
713
|
var _a, _b;
|
|
179
714
|
if (!props.checkbox || props.singleSelect || ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) <= 0)
|
|
@@ -217,8 +752,8 @@ var NewTable = function (props) {
|
|
|
217
752
|
.multiActionFloatingBtns.filter(function (btn) { return !btn.hide; })
|
|
218
753
|
.map(function (btn) { return (react_2.default.createElement(textButton_1.TextButton, { key: btn.id, text: btn.btnText, className: "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"), onClick: function () { return btn.onClick(btn.id); } })); });
|
|
219
754
|
};
|
|
220
|
-
var pillBase = "shadow-xl ".concat(borderRadius, " ").concat(
|
|
221
|
-
return (react_2.default.createElement("div", { className: "fixed bottom-
|
|
755
|
+
var pillBase = "shadow-xl ".concat(borderRadius, " ").concat(bgColor, " border ").concat(props.darkMode ? "border-primary-300" : "border-primary-500");
|
|
756
|
+
return (react_2.default.createElement("div", { className: "fixed bottom-10 inset-x-4 z-10 flex justify-center" },
|
|
222
757
|
react_2.default.createElement("div", { className: "sm:hidden flex flex-col w-full px-4 py-2.5 ".concat(pillBase) },
|
|
223
758
|
react_2.default.createElement("div", { className: "flex items-center justify-between" },
|
|
224
759
|
renderSelectedCount(),
|
|
@@ -230,6 +765,104 @@ var NewTable = function (props) {
|
|
|
230
765
|
react_2.default.createElement("div", { className: "flex items-center overflow-x-auto mx-1 border-l ".concat(props.darkMode ? "border-gray-500" : "") }, renderActionBtns()),
|
|
231
766
|
renderCloseBtn())));
|
|
232
767
|
};
|
|
768
|
+
// INFO: determines whether any column uses groupData — if so, a two-row
|
|
769
|
+
// thead with colSpan/rowSpan is rendered for proper visual grouping.
|
|
770
|
+
var hasGroupHeaders = columns.some(function (col) {
|
|
771
|
+
return !col.hide &&
|
|
772
|
+
col.groupData &&
|
|
773
|
+
col.groupData.length > 0;
|
|
774
|
+
});
|
|
775
|
+
var renderTableHeader = function () {
|
|
776
|
+
var advSettings = props.advSettings;
|
|
777
|
+
var cursorClassname = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? "cursor-pointer" : "";
|
|
778
|
+
var draggable = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? true : false;
|
|
779
|
+
var droppable = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? true : false;
|
|
780
|
+
var sortClassname = "flex-shrink-0 h-4 w-4 ml-3 cursor-pointer";
|
|
781
|
+
var renderHeaderIcons = function (col) {
|
|
782
|
+
var _a, _b, _c;
|
|
783
|
+
var sortIcon = null;
|
|
784
|
+
var filterIcon = null;
|
|
785
|
+
var sortColumnEnabled = (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortOptions) === null || _a === void 0 ? void 0 : _a.some(function (eachOption) { return eachOption.key === col.key; });
|
|
786
|
+
var filterColumnEnabled = utils_1.supportedAQList.includes((_b = col.type) !== null && _b !== void 0 ? _b : "");
|
|
787
|
+
if (sortColumnEnabled && (advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortEnabled)) {
|
|
788
|
+
if (col.key !== ((_c = advSettings.sortId) === null || _c === void 0 ? void 0 : _c.sortId)) {
|
|
789
|
+
sortIcon = (react_2.default.createElement(solid_2.ArrowsUpDownIcon, { className: sortClassname, onClick: function () { return handleSort(col.key, "new"); } }));
|
|
790
|
+
}
|
|
791
|
+
else if (col.key === advSettings.sortId.sortId) {
|
|
792
|
+
if (advSettings.sortId.type === "desc") {
|
|
793
|
+
sortIcon = (react_2.default.createElement(solid_2.BarsArrowDownIcon, { className: sortClassname, onClick: function () { return handleSort(col.key, "asc"); } }));
|
|
794
|
+
}
|
|
795
|
+
else if (advSettings.sortId.type === "asc") {
|
|
796
|
+
sortIcon = (react_2.default.createElement(solid_2.BarsArrowUpIcon, { className: sortClassname, onClick: function () { return handleSort(col.key, "desc"); } }));
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (filterColumnEnabled && (advSettings === null || advSettings === void 0 ? void 0 : advSettings.filterEnabled)) {
|
|
801
|
+
filterIcon = (react_2.default.createElement(outline_1.FunnelIcon, { className: sortClassname, onClick: function () { return handleFilterModal(col.key); } }));
|
|
802
|
+
}
|
|
803
|
+
return (react_2.default.createElement(react_2.default.Fragment, null,
|
|
804
|
+
sortIcon,
|
|
805
|
+
filterIcon,
|
|
806
|
+
col.type === "math" && (react_2.default.createElement(outline_1.PencilIcon, { className: sortClassname, onClick: function () { return handleAddColumnModal(col.key); } }))));
|
|
807
|
+
};
|
|
808
|
+
var renderAddColumnHeader = function () {
|
|
809
|
+
if (!(advSettings === null || advSettings === void 0 ? void 0 : advSettings.addColumnEnabled))
|
|
810
|
+
return null;
|
|
811
|
+
return (react_2.default.createElement("th", { key: "addColumns", className: "".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname) },
|
|
812
|
+
react_2.default.createElement("div", { className: "flex flex-row items-center" },
|
|
813
|
+
react_2.default.createElement(iconButton_1.IconButton, { icon: react_2.default.createElement(solid_3.PlusIcon, { className: "h-5 w-5 text-gray" }), onClick: function () { return handleAddColumnModal("new"); } }))));
|
|
814
|
+
};
|
|
815
|
+
if (!hasGroupHeaders) {
|
|
816
|
+
return (react_2.default.createElement("thead", null,
|
|
817
|
+
react_2.default.createElement("tr", { className: "border-b ".concat(dividerColor, " ").concat(tableHeaderBgColor, " ").concat(tableHeaderFontColor) },
|
|
818
|
+
props.checkbox && (react_2.default.createElement("th", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? tableHeaderBgColor : ""), style: hasPinColumns
|
|
819
|
+
? { position: "sticky", left: 0, zIndex: 3 }
|
|
820
|
+
: undefined }, renderSelectAll())),
|
|
821
|
+
flatColumns.map(function (col) {
|
|
822
|
+
var _a, _b, _c, _d;
|
|
823
|
+
return (react_2.default.createElement("th", { key: col.key, className: "".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname, " ").concat((_b = (_a = getPinProps(col.key, true)) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""), style: (_c = getPinProps(col.key, true)) === null || _c === void 0 ? void 0 : _c.style, draggable: draggable, onDragStart: function (e) { return handleDragStart(e, col.key); }, onDrop: droppable ? function (e) { return handleDrop(e, col.key); } : undefined, onDragOver: handleDragOver },
|
|
824
|
+
react_2.default.createElement("div", { className: "flex flex-row items-center ".concat((_d = col.width) !== null && _d !== void 0 ? _d : "") },
|
|
825
|
+
col.title,
|
|
826
|
+
renderHeaderIcons(col))));
|
|
827
|
+
}),
|
|
828
|
+
renderAddColumnHeader(),
|
|
829
|
+
renderActionColumnHeader())));
|
|
830
|
+
}
|
|
831
|
+
// INFO: two-row header — first row has parent group titles (colSpan) and
|
|
832
|
+
// non-group columns (rowSpan=2); second row has sub-column titles.
|
|
833
|
+
var visibleColumns = columns.filter(function (col) {
|
|
834
|
+
return !col.hide && (props.showId || (col.key !== "id" && col.key !== "_id"));
|
|
835
|
+
});
|
|
836
|
+
return (react_2.default.createElement("thead", null,
|
|
837
|
+
react_2.default.createElement("tr", { className: "border-b ".concat(dividerColor, " ").concat(tableHeaderBgColor, " ").concat(tableHeaderFontColor) },
|
|
838
|
+
props.checkbox && (react_2.default.createElement("th", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? tableHeaderBgColor : ""), style: hasPinColumns
|
|
839
|
+
? { position: "sticky", left: 0, zIndex: 3 }
|
|
840
|
+
: undefined, rowSpan: 2 }, renderSelectAll())),
|
|
841
|
+
visibleColumns.map(function (col) {
|
|
842
|
+
var _a, _b, _c, _d;
|
|
843
|
+
var groupData = col.groupData;
|
|
844
|
+
if (groupData && groupData.length > 0) {
|
|
845
|
+
return (react_2.default.createElement("th", { key: col.key, colSpan: groupData.length, className: "".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide border-b") }, col.title));
|
|
846
|
+
}
|
|
847
|
+
return (react_2.default.createElement("th", { key: col.key, rowSpan: 2, className: "".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname, " ").concat((_b = (_a = getPinProps(col.key, true)) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""), style: (_c = getPinProps(col.key, true)) === null || _c === void 0 ? void 0 : _c.style, draggable: draggable, onDragStart: function (e) { return handleDragStart(e, col.key); }, onDrop: droppable ? function (e) { return handleDrop(e, col.key); } : undefined, onDragOver: handleDragOver },
|
|
848
|
+
react_2.default.createElement("div", { className: "flex flex-row items-center ".concat((_d = col.width) !== null && _d !== void 0 ? _d : "") },
|
|
849
|
+
col.title,
|
|
850
|
+
renderHeaderIcons(col))));
|
|
851
|
+
}),
|
|
852
|
+
renderAddColumnHeader(),
|
|
853
|
+
renderActionColumnHeader()),
|
|
854
|
+
react_2.default.createElement("tr", { className: "border-b ".concat(dividerColor, " ").concat(tableHeaderBgColor, " ").concat(tableHeaderFontColor) }, visibleColumns.map(function (col) {
|
|
855
|
+
var groupData = col.groupData;
|
|
856
|
+
if (!groupData || groupData.length === 0)
|
|
857
|
+
return null;
|
|
858
|
+
return groupData.map(function (sub) {
|
|
859
|
+
var _a;
|
|
860
|
+
var subKey = "".concat(col.key, ".").concat(sub.key);
|
|
861
|
+
return (react_2.default.createElement("th", { key: subKey, className: "".concat(cellPadding, " text-left text-xs font-medium uppercase tracking-wide") },
|
|
862
|
+
react_2.default.createElement("div", { className: "flex flex-row items-center ".concat((_a = sub.width) !== null && _a !== void 0 ? _a : "") }, sub.title)));
|
|
863
|
+
});
|
|
864
|
+
}))));
|
|
865
|
+
};
|
|
233
866
|
var renderPageNumber = function (type) {
|
|
234
867
|
var _a, _b, _c, _d;
|
|
235
868
|
var pageNumberList = [];
|
|
@@ -245,7 +878,7 @@ var NewTable = function (props) {
|
|
|
245
878
|
var _loop_1 = function (i) {
|
|
246
879
|
var pageNumberClassName = basePageNumberClassname +
|
|
247
880
|
(props.pageIndex === i
|
|
248
|
-
? "border rounded-xl ".concat(selectedBorderColor, " ").concat(selectedFontColor, " ").concat(
|
|
881
|
+
? "border rounded-xl ".concat(selectedBorderColor, " ").concat(selectedFontColor, " ").concat(bgColor)
|
|
249
882
|
: "".concat(cellFontColor));
|
|
250
883
|
pageNumberList.push(react_2.default.createElement("div", { key: i, "aria-current": "page", className: pageNumberClassName, onClick: props.pageIndex !== i
|
|
251
884
|
? function () { var _a; return (_a = props.handleUpdatePageIndex) === null || _a === void 0 ? void 0 : _a.call(props, i); }
|
|
@@ -297,87 +930,149 @@ var NewTable = function (props) {
|
|
|
297
930
|
}
|
|
298
931
|
return react_2.default.createElement("p", { className: "text-xs ".concat(cellFontColor) }, text);
|
|
299
932
|
};
|
|
300
|
-
var renderCheckbox = function (checked, onChange, onClick, extraClassName) { return (react_2.default.createElement("input", { type: "checkbox", checked: checked, onChange: onChange, onClick: onClick, className: "rounded ".concat(props.darkMode ? "border-gray-400" : "border-gray-500", " ").concat(
|
|
933
|
+
var renderCheckbox = function (checked, onChange, onClick, extraClassName) { return (react_2.default.createElement("input", { type: "checkbox", checked: checked, onChange: onChange, onClick: onClick, className: "rounded ".concat(props.darkMode ? "border-gray-400" : "border-gray-500", " ").concat(bgColor, " focus:ring-0 focus:ring-offset-0 focus:outline-offset-0 checked:text-primary-400 ").concat(extraClassName !== null && extraClassName !== void 0 ? extraClassName : "") })); };
|
|
301
934
|
if (props.mobileView) {
|
|
302
935
|
var isIdLike_1 = function (c) {
|
|
303
936
|
return /^id$/i.test(c.key) || /^_id$/i.test(c.key);
|
|
304
937
|
};
|
|
305
|
-
var titleCol_1 = (
|
|
938
|
+
var titleCol_1 = (_g = flatColumns.find(function (c) { return !isIdLike_1(c); })) !== null && _g !== void 0 ? _g : flatColumns[0];
|
|
306
939
|
var expandHeaderBg_1 = props.darkMode ? "bg-gray-700" : "bg-gray-100";
|
|
307
940
|
var expandHeaderFontColor_1 = props.darkMode ? "text-white" : "";
|
|
308
941
|
var headerBgColor_1 = props.darkMode ? "bg-gray-900" : "";
|
|
309
942
|
var headerFontColor_1 = props.darkMode ? "text-white" : "";
|
|
310
|
-
var renderHeaderText_1 = function (col, row) {
|
|
311
|
-
var value = resolveValue(row, col.key);
|
|
312
|
-
if (value === undefined || value === null)
|
|
313
|
-
return "";
|
|
314
|
-
if (value instanceof Date)
|
|
315
|
-
return value.toLocaleDateString();
|
|
316
|
-
if (typeof value === "object") {
|
|
317
|
-
if ("name" in value)
|
|
318
|
-
return String(value.name);
|
|
319
|
-
return JSON.stringify(value);
|
|
320
|
-
}
|
|
321
|
-
return String(value);
|
|
322
|
-
};
|
|
323
943
|
return (react_2.default.createElement("div", null,
|
|
324
|
-
react_2.default.createElement("div", { className: "w-full overflow-hidden border ".concat(borderRadius, " ").concat(borderColor, " ").concat(
|
|
944
|
+
react_2.default.createElement("div", { className: "w-full overflow-hidden border ".concat(borderRadius, " ").concat(borderColor, " ").concat(bgColor, " shadow-sm divide-y ").concat(dividerColor, " ").concat((_h = props.className) !== null && _h !== void 0 ? _h : "") },
|
|
325
945
|
react_2.default.createElement("div", { className: "p-3 flex justify-between" },
|
|
326
946
|
renderSelectAll(),
|
|
327
947
|
renderSelectedCount()),
|
|
328
|
-
props.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
948
|
+
props.loading &&
|
|
949
|
+
Array.from({ length: 3 }).map(function (_, i) { return (react_2.default.createElement("div", { key: "skeleton-".concat(i), className: "p-4" },
|
|
950
|
+
react_2.default.createElement("div", { className: "h-5 w-3/4 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }),
|
|
951
|
+
!props.loading && props.data.length === 0 && (react_2.default.createElement("p", { className: "p-4 text-center text-sm ".concat(cellFontColor) }, (_j = props.emptyTitle) !== null && _j !== void 0 ? _j : "No items")),
|
|
952
|
+
!props.loading &&
|
|
953
|
+
props.data.map(function (row, index) {
|
|
954
|
+
var _a, _b, _c, _d, _e;
|
|
955
|
+
var spaceRow = (_a = props.spaceData) === null || _a === void 0 ? void 0 : _a[index];
|
|
956
|
+
var cardTitle = titleCol_1
|
|
957
|
+
? spaceRow
|
|
958
|
+
? spaceRow[titleCol_1.key]
|
|
959
|
+
: resolveValue(row, titleCol_1.key) || row.id
|
|
960
|
+
: "";
|
|
961
|
+
var isSelected = ((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.includes(row.id)) !== null && _c !== void 0 ? _c : false) ||
|
|
962
|
+
((_d = props.selectAll) !== null && _d !== void 0 ? _d : false);
|
|
963
|
+
var detailList = flatColumns.map(function (col) { return ({
|
|
964
|
+
id: col.key,
|
|
965
|
+
title: col.title,
|
|
966
|
+
text: (0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, spaceRow ? spaceRow[col.key] : resolveValue(row, col.key), props.bareSettings, true, props.disableEllipsisOnLongWord),
|
|
967
|
+
}); });
|
|
968
|
+
if (props.onClickRow || props.newTabUrl) {
|
|
969
|
+
detailList.push({
|
|
970
|
+
id: "".concat(row.id, "-more-details-btn"),
|
|
971
|
+
title: "",
|
|
972
|
+
text: props.newTabUrl ? (react_2.default.createElement(link_1.Link, { href: props.newTabUrl + row.id + ((_e = props.addNewTabUrl) !== null && _e !== void 0 ? _e : ""), className: "flex items-center", linkType: props.linkType, custom: props.custom },
|
|
973
|
+
react_2.default.createElement(textButton_1.TextButton, { text: "More details", className: "text-sm", onClick: function () { } }),
|
|
974
|
+
react_2.default.createElement(solid_1.ChevronRightIcon, { className: "ml-1 w-3 h-3 text-primary-500" }))) : (react_2.default.createElement("div", { className: "flex items-center" },
|
|
975
|
+
react_2.default.createElement(textButton_1.TextButton, { text: "More details", className: "text-sm", onClick: function (e) {
|
|
976
|
+
var _a;
|
|
977
|
+
e.stopPropagation();
|
|
978
|
+
(_a = props.onClickRow) === null || _a === void 0 ? void 0 : _a.call(props, row.id, row, spaceRow);
|
|
979
|
+
} }),
|
|
980
|
+
react_2.default.createElement(solid_1.ChevronRightIcon, { className: "ml-1 w-3 h-3 text-primary-500" }))),
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
return (react_2.default.createElement("div", { key: row.id },
|
|
984
|
+
react_2.default.createElement(collapse_1.Collapse, { title: cardTitle, titleClassName: "text-sm font-medium !p-0 ".concat(props.onClickRow ? titleFontColor : ""), icon: props.checkbox ? renderCheckbox(isSelected, function () { }, function (e) { return handleSelectRow(row.id, e); }, "w-4 h-4 cursor-pointer") : (react_2.default.createElement(solid_1.ListBulletIcon, { className: "w-4 h-4 ".concat(props.darkMode ? "text-gray-400" : "text-gray-500") })), defaultValue: false, collapseContainerCss: "".concat(isSelected ? selectedRowBg : expandHeaderBg_1, " ").concat(expandHeaderFontColor_1), notCollapseContainerCss: "".concat(isSelected ? selectedRowBg : headerBgColor_1, " ").concat(headerFontColor_1), content: react_2.default.createElement("div", null,
|
|
985
|
+
react_2.default.createElement(detailList_1.DetailList, { title: "", list: detailList, size: "compact", darkMode: props.darkMode })) })));
|
|
986
|
+
})),
|
|
987
|
+
!props.hidePagination && props.paginationType && (react_2.default.createElement("div", { className: "mt-2 flex items-center justify-between ".concat(props.fixedPagination
|
|
988
|
+
? "pagination-container w-full sm:px-6 ".concat(borderColor, " ").concat(isFixed
|
|
989
|
+
? "fixed bottom-0 left-0 z-10"
|
|
990
|
+
: "sticky top-0 left-0")
|
|
991
|
+
: "") },
|
|
342
992
|
renderPageResult(),
|
|
343
993
|
renderPagination())),
|
|
344
994
|
renderFloatingActionBar()));
|
|
345
995
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
react_2.default.createElement(
|
|
353
|
-
|
|
996
|
+
return (react_2.default.createElement("div", { className: "w-full ".concat((_k = props.className) !== null && _k !== void 0 ? _k : "") },
|
|
997
|
+
react_2.default.createElement(modal_1.Modal, { open: filterModal ? true : false, title: "Filter Options", renderContent: function () {
|
|
998
|
+
var _a, _b;
|
|
999
|
+
return (react_2.default.createElement("div", { className: "pb-44" },
|
|
1000
|
+
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))));
|
|
1001
|
+
}, onClose: function () { return setFilterModal(""); } }),
|
|
1002
|
+
react_2.default.createElement(modal_1.Modal, { open: addColumnModal ? true : false, title: "Add Columns", renderContent: function () {
|
|
1003
|
+
var _a, _b;
|
|
1004
|
+
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); })));
|
|
1005
|
+
}, onClose: function () { return handleAddColumnModal(""); } }),
|
|
1006
|
+
react_2.default.createElement("div", { className: "w-full overflow-x-auto ".concat(borderRadius, " border ").concat(borderColor, " ").concat(bgColor, " shadow-sm") },
|
|
1007
|
+
(props.selectAll || ((_m = (_l = props.selectedIds) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0) > 0) &&
|
|
1008
|
+
(!props.multiActionFloatingBtns ||
|
|
1009
|
+
(props.multiActionFloatingBtns &&
|
|
1010
|
+
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" },
|
|
354
1011
|
renderSelectedCount(),
|
|
355
1012
|
props.multiActionButton)),
|
|
356
1013
|
react_2.default.createElement("table", { className: "w-full" },
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return (react_2.default.createElement("
|
|
363
|
-
react_2.default.createElement("div", { className: "
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
1014
|
+
renderTableHeader(),
|
|
1015
|
+
react_2.default.createElement("tbody", { className: "divide-y ".concat(dividerColor) },
|
|
1016
|
+
props.loading &&
|
|
1017
|
+
Array.from({ length: 3 }).map(function (_, i) { return (react_2.default.createElement("tr", { key: "skeleton-".concat(i) },
|
|
1018
|
+
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
1019
|
+
flatColumns.map(function (col) { return (react_2.default.createElement("td", { key: col.key, className: cellPadding },
|
|
1020
|
+
react_2.default.createElement("div", { className: "h-5 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }))); }),
|
|
1021
|
+
!props.loading &&
|
|
1022
|
+
props.data.map(function (row, index) {
|
|
1023
|
+
var _a, _b, _c, _d;
|
|
1024
|
+
var spaceRow = (_a = props.spaceData) === null || _a === void 0 ? void 0 : _a[index];
|
|
1025
|
+
var isSelected = ((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.includes(row.id)) !== null && _c !== void 0 ? _c : false) ||
|
|
1026
|
+
((_d = props.selectAll) !== null && _d !== void 0 ? _d : false);
|
|
1027
|
+
var rowBgClass = isSelected ? selectedRowBg : bgColor;
|
|
1028
|
+
var isRowHoverable = !!props.onClickRow && !isSelected;
|
|
1029
|
+
return (react_2.default.createElement("tr", { key: row.id, onClick: function (e) {
|
|
1030
|
+
if (props.onClickRow) {
|
|
1031
|
+
props.onClickRow(row.id, row, spaceRow);
|
|
1032
|
+
}
|
|
1033
|
+
e.preventDefault();
|
|
1034
|
+
}, className: "group ".concat(isSelected
|
|
1035
|
+
? selectedRowBg
|
|
1036
|
+
: props.onClickRow
|
|
1037
|
+
? "cursor-pointer ".concat(rowHoverBg)
|
|
1038
|
+
: editDataIsLoading && editDataRowId === row.id
|
|
1039
|
+
? "animate-pulse"
|
|
1040
|
+
: "") },
|
|
1041
|
+
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
|
|
1042
|
+
? { position: "sticky", left: 0, zIndex: 1 }
|
|
1043
|
+
: undefined, onClick: function (e) { return handleSelectRow(row.id, e); } }, renderCheckbox(isSelected, function () { }))),
|
|
1044
|
+
flatColumns.map(function (col, colIndex) {
|
|
1045
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1046
|
+
var cellValue = spaceRow
|
|
1047
|
+
? spaceRow[col.key]
|
|
1048
|
+
: resolveValue(row, col.key);
|
|
1049
|
+
// INFO: first col with type "string" is never made editable
|
|
1050
|
+
var isEditable = ((_a = props.editable) === null || _a === void 0 ? void 0 : _a.active) &&
|
|
1051
|
+
!(((_c = (_b = props.selectedIds) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0 ||
|
|
1052
|
+
props.selectAll) &&
|
|
1053
|
+
col.type &&
|
|
1054
|
+
utils_1.supportedTableAddList.includes(col.type) &&
|
|
1055
|
+
!(colIndex === 0 && col.type === "string");
|
|
1056
|
+
var rowData = editDataRowId === row.id ? editDataValue : row;
|
|
1057
|
+
if (isEditable) {
|
|
1058
|
+
var bareOverride = (_e = (_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareListDescription) === null || _e === void 0 ? void 0 : _e.call(_d, col.key, cellValue);
|
|
1059
|
+
if (!bareOverride)
|
|
1060
|
+
return renderEditDataInputs(colIndex, col, rowData, row.id, rowBgClass, isRowHoverable);
|
|
1061
|
+
}
|
|
1062
|
+
return (
|
|
1063
|
+
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
1064
|
+
react_2.default.createElement("td", { key: col.key, 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((_g = (_f = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _f === void 0 ? void 0 : _f.className) !== null && _g !== void 0 ? _g : ""), style: (_h = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _h === void 0 ? void 0 : _h.style }, props.newTabUrl && props.onClickRow ? (react_2.default.createElement(link_1.Link, { href: props.newTabUrl +
|
|
1065
|
+
row.id +
|
|
1066
|
+
((_j = props.addNewTabUrl) !== null && _j !== void 0 ? _j : ""), 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))));
|
|
1067
|
+
}),
|
|
1068
|
+
renderActionColumnCell(row.id)));
|
|
1069
|
+
}),
|
|
1070
|
+
!props.loading && addData && renderAddDataRow())),
|
|
1071
|
+
!props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (_o = props.emptyTitle) !== null && _o !== void 0 ? _o : "No items")),
|
|
1072
|
+
renderAddableSection()),
|
|
1073
|
+
!props.hidePagination && props.paginationType && (react_2.default.createElement("div", { className: "mt-2 flex items-center justify-between ".concat(props.fixedPagination
|
|
1074
|
+
? "pagination-container w-full ".concat(borderColor, " ").concat(isFixed ? "fixed bottom-0 left-0 z-10" : "sticky top-0 left-0")
|
|
1075
|
+
: "") },
|
|
381
1076
|
renderPageResult(),
|
|
382
1077
|
renderPagination())),
|
|
383
1078
|
renderFloatingActionBar()));
|