UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

56 lines 2.8 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["columns"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { Table as AntdTable, Tooltip } from 'antd'; import React, { useMemo } from 'react'; import { CollapseTable } from "./collapse"; import { jsx as _jsx } from "react/jsx-runtime"; export * from "./collapse"; export var Table = function Table(props) { var columns = props.columns, otherProps = _objectWithoutProperties(props, _excluded); var formatColumns = useMemo(function () { return columns === null || columns === void 0 ? void 0 : columns.map(function (item) { if (item.render) { return item; } if (item.ellipsis && item.ellipsis !== true && item.ellipsis.showTitle || item.ellipsis === true) { var tooltipProps = item.ellipsis === true ? {} : item.ellipsis; return _objectSpread(_objectSpread({}, item), {}, { ellipsis: { showTitle: false }, render: function render(text) { return text || text === 0 ? /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, { placement: "topLeft", title: text, children: text })) : '-'; } }); } if (!item.render) { item.render = function (text) { return text !== null && text !== void 0 ? text : '-'; }; } return item; }); }, [columns]); return /*#__PURE__*/_jsx(AntdTable, _objectSpread(_objectSpread({}, otherProps), {}, { columns: formatColumns })); }; Table.displayName = 'Table'; Table.SELECTION_COLUMN = AntdTable.SELECTION_COLUMN; Table.EXPAND_COLUMN = AntdTable.EXPAND_COLUMN; Table.SELECTION_ALL = AntdTable.SELECTION_ALL; Table.SELECTION_INVERT = AntdTable.SELECTION_INVERT; Table.SELECTION_NONE = AntdTable.SELECTION_NONE; Table.Column = AntdTable.Column; Table.ColumnGroup = AntdTable.ColumnGroup; Table.Summary = AntdTable.Summary; Table.Collapse = CollapseTable; export default Table;