UNPKG

9s-fe-core

Version:

Core functionalities for authentication, configuration, and repository management.

23 lines (22 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const template_utils_1 = require("../../utils/template_utils"); const ArrayDisplay = ({ fieldItem }) => { var _a, _b; let arrayValue = (_a = fieldItem.value) !== null && _a !== void 0 ? _a : []; console.log('fieldItem:', JSON.stringify(fieldItem, null, 2)); 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: (_b = fieldItem.array_fields) === null || _b === void 0 ? void 0 : _b.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: arrayValue.map((record) => { var _a, _b, _c; 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: (_c = fieldItem.array_fields) === null || _c === void 0 ? void 0 : _c.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)); }) })] }, fieldItem.key)); }; exports.default = ArrayDisplay;