@redocly/theme
Version:
Shared UI components lib
45 lines • 1.7 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CatalogLastUpdateCell = CatalogLastUpdateCell;
const react_1 = __importDefault(require("react"));
const styled_components_1 = __importDefault(require("styled-components"));
const Tooltip_1 = require("../../../components/Tooltip/Tooltip");
function formatLastModified(isoString) {
const date = new Date(isoString);
if (Number.isNaN(date.getTime())) {
return isoString;
}
return date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
timeZone: 'UTC',
});
}
function formatLastModifiedTooltip(isoString) {
const date = new Date(isoString);
if (Number.isNaN(date.getTime())) {
return isoString;
}
return date.toLocaleString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
timeZone: 'UTC',
});
}
function CatalogLastUpdateCell({ lastModified, }) {
return (react_1.default.createElement(CatalogLastUpdateCellWrapper, { "data-component-name": "Catalog/CatalogTableView/CatalogLastUpdateCell" },
react_1.default.createElement(Tooltip_1.Tooltip, { tip: formatLastModifiedTooltip(lastModified), placement: "bottom" }, formatLastModified(lastModified))));
}
const CatalogLastUpdateCellWrapper = styled_components_1.default.div `
color: var(--text-color-helper);
`;
//# sourceMappingURL=CatalogLastUpdateCell.js.map