@typeolymp/ui-components 1.18.6 → 1.19.0
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/build/components/organisms/Table/index.d.ts +15 -9
- package/build/index.es.js +30 -10
- package/build/index.es.js.map +1 -1
- package/build/index.js +30 -10
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -48257,16 +48257,36 @@ var EmptyTableCell = styled__default["default"].td(templateObject_8 || (template
|
|
|
48257
48257
|
var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
48258
48258
|
|
|
48259
48259
|
var Table = function (_a) {
|
|
48260
|
-
var columns = _a.columns, data = _a.data, empytText = _a.empytText;
|
|
48261
|
-
|
|
48262
|
-
|
|
48263
|
-
|
|
48264
|
-
|
|
48265
|
-
|
|
48266
|
-
|
|
48267
|
-
|
|
48268
|
-
|
|
48269
|
-
|
|
48260
|
+
var columns = _a.columns, data = _a.data, empytText = _a.empytText, rowSelection = _a.rowSelection;
|
|
48261
|
+
var _b = React$3.useState([]), selectedRowKeys = _b[0], setSelectedRowKeys = _b[1];
|
|
48262
|
+
var onSelectRow = function (selectedKey) {
|
|
48263
|
+
var index = selectedRowKeys.indexOf(selectedKey);
|
|
48264
|
+
var newSelectedRowKeys = __spreadArray([], selectedRowKeys, true);
|
|
48265
|
+
if (index === -1)
|
|
48266
|
+
newSelectedRowKeys.push(selectedKey);
|
|
48267
|
+
else
|
|
48268
|
+
newSelectedRowKeys.splice(index, 1);
|
|
48269
|
+
setSelectedRowKeys(newSelectedRowKeys);
|
|
48270
|
+
var selectedRows = data.filter(function (_a) {
|
|
48271
|
+
var key = _a.key;
|
|
48272
|
+
return newSelectedRowKeys.includes(key);
|
|
48273
|
+
});
|
|
48274
|
+
var selectedRow = data.find(function (_a) {
|
|
48275
|
+
var key = _a.key;
|
|
48276
|
+
return key === selectedKey;
|
|
48277
|
+
});
|
|
48278
|
+
if (rowSelection && rowSelection.onChange)
|
|
48279
|
+
rowSelection.onChange(newSelectedRowKeys, selectedKey, selectedRows, selectedRow);
|
|
48280
|
+
};
|
|
48281
|
+
return (jsxRuntime.jsxs(Container$1, { children: [jsxRuntime.jsx(TableHead, { children: jsxRuntime.jsxs(TableRow, { children: [rowSelection && jsxRuntime.jsx("th", { style: { width: 55 } }), columns.map(function (_a, index) {
|
|
48282
|
+
var title = _a.title, dataIndex = _a.dataIndex;
|
|
48283
|
+
return (jsxRuntime.jsx(ColumnTitle, { children: title && (jsxRuntime.jsx(Heading, __assign$2({ type: "h6", as: "span" }, { children: title }))) }, "".concat(dataIndex, "-").concat(index)));
|
|
48284
|
+
})] }) }), jsxRuntime.jsx(TableBody, { children: data.length === 0 ? (jsxRuntime.jsx(TableRow, { children: jsxRuntime.jsx(EmptyTableCell, __assign$2({ colSpan: columns.length }, { children: jsxRuntime.jsx(Paragraph, __assign$2({ align: "center", size: "small", weight: "regular" }, { children: empytText || "No data" })) })) })) : (data.map(function (row, rowIndex) {
|
|
48285
|
+
return (jsxRuntime.jsxs(TableRow, { children: [rowSelection && (jsxRuntime.jsx(TableCell, { children: jsxRuntime.jsx(Checkbox, { id: "".concat(rowIndex), name: "".concat(rowIndex), value: row.key, onChange: onSelectRow }) }, "row-select-".concat(rowIndex))), columns.map(function (_a, colIndex) {
|
|
48286
|
+
var dataIndex = _a.dataIndex, render = _a.render, align = _a.align;
|
|
48287
|
+
var data = row[dataIndex];
|
|
48288
|
+
return (jsxRuntime.jsx(TableCell, __assign$2({ align: align }, { children: render ? render(data, row) : data }), "col-".concat(colIndex)));
|
|
48289
|
+
})] }, "row-".concat(rowIndex)));
|
|
48270
48290
|
})) })] }));
|
|
48271
48291
|
};
|
|
48272
48292
|
|