"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.DateView = void 0;
var _react = _interopRequireDefault(require("react"));
var _designSystem = require("@wix/design-system");
var _CellViewLayout = require("../CellViewLayout");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/EditableTable/cellTypes/date/View.tsx";
const dateFormatter = new Intl.DateTimeFormat(undefined, {
  day: '2-digit',
  month: '2-digit',
  year: 'numeric'
});
function formatDate(value) {
  if (!value) {
    return '';
  }
  const date = value instanceof Date ? value : new Date(value);
  if (isNaN(date.getTime())) {
    return typeof value === 'string' ? value : '';
  }
  return dateFormatter.format(date);
}
const DateView = ({
  value
}) => /*#__PURE__*/_react.default.createElement(_CellViewLayout.CellViewLayout, {
  __self: void 0,
  __source: {
    fileName: _jsxFileName,
    lineNumber: 26,
    columnNumber: 3
  }
}, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
  size: "small",
  ellipsis: true,
  __self: void 0,
  __source: {
    fileName: _jsxFileName,
    lineNumber: 27,
    columnNumber: 5
  }
}, formatDate(value)));
exports.DateView = DateView;
//# sourceMappingURL=View.js.map