9s-fe-core
Version:
Core functionalities for authentication, configuration, and repository management.
21 lines (20 loc) • 1.73 kB
JavaScript
;
'use client';
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ExpandableTable;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const template_utils_1 = require("../../utils/template_utils");
function ExpandableTable({ records, fieldList, }) {
return ((0, jsx_runtime_1.jsxs)("table", { className: "table-auto w-full border border-gray-300", children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsx)("tr", { className: "bg-gray-100", children: fieldList === null || fieldList === void 0 ? void 0 : fieldList.map((fieldItem) => {
return ((0, jsx_runtime_1.jsx)("th", { className: "p-2 text-left", children: fieldItem.label }, fieldItem.key));
}) }) }), (0, jsx_runtime_1.jsx)("tbody", { children: records.map((record) => {
var _a, _b;
const rowId = (_b = (_a = record.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : Math.random().toString(); // fallback nếu không có id
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsx)("tr", { className: "cursor-pointer hover:bg-gray-50", children: fieldList === null || fieldList === void 0 ? void 0 : fieldList.map((fieldItem) => {
let value = record[fieldItem.key];
fieldItem.value = value;
return ((0, jsx_runtime_1.jsx)("td", { className: "p-2", children: (0, template_utils_1.renderFieldDisplayUI)(fieldItem) }, fieldItem.key));
}) }) }, rowId));
}) })] }));
}