@etsoo/materialui
Version:
TypeScript Material-UI Implementation
45 lines (44 loc) • 1.49 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { DataTable } from "./DataTable";
import React from "react";
import { useAppContext } from "./app/ReactApp";
/**
* Culture DataTable
* @param props Props
* @returns Component
*/
export function CultureDataTable(props) {
// Global app
const app = useAppContext();
// Destruct
const { cultures, cultureLabel = app?.get("culture"), editable = true, titleLabel, hasDescription = false, descriptionLabel = app?.get("description"), ...rest } = props;
const getCultureLabel = React.useCallback((value) => cultures.find((c) => c.id == value.id)?.label ?? `${value.value}`, [cultures]);
return (_jsx(DataTable, { columns: [
{
field: "id",
headerName: cultureLabel,
renderCell: getCultureLabel,
width: 150,
editable: false,
sortable: false
},
{
field: "title",
headerName: titleLabel,
flex: 1,
editable,
sortable: false
},
...(hasDescription
? [
{
field: "description",
headerName: descriptionLabel,
flex: 1,
editable,
sortable: false
}
]
: [])
], ...rest }));
}