"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.CustomCells = exports.BoldCells = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _reactIntl = require("react-intl");
var _ = require("../../..");
var _FlexTable = _interopRequireDefault(require("../FlexTable.mdx"));
var _excluded = ["columnId", "value", "percentage"],
  _excluded2 = ["columnId", "value", "percentage"],
  _excluded3 = ["columnId", "value"],
  _excluded4 = ["columnId", "country"],
  _excluded5 = ["columnId", "children"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var _default = exports.default = {
  title: 'Molecules / FlexTable / With Custom Cells',
  parameters: {
    component: _.FlexTable,
    docs: {
      page: _FlexTable.default
    }
  }
};
var StyledFlexboxContainer = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "WithCustomCellsstories__StyledFlexboxContainer",
  componentId: "sc-gh96k2-0"
})(["justify-content:inherit;"]);
var CustomCells = exports.CustomCells = function CustomCells() {
  var Story = function Story() {
    var TruncateStartHeader = function TruncateStartHeader(_ref) {
      var children = _ref.children,
        columnId = _ref.columnId,
        flex = _ref.flex,
        currency = _ref.currency,
        justifyContent = _ref.justifyContent;
      return _react.default.createElement(_.FlexTable.Header, {
        columnId: columnId,
        flex: flex,
        justifyContent: justifyContent,
        sortable: true
      }, function (_ref2) {
        var sortable = _ref2.sortable,
          sorted = _ref2.sorted,
          onSortClick = _ref2.onSortClick,
          sortOrder = _ref2.sortOrder;
        return _react.default.createElement(_.FlexTable.Header.SortButton, {
          onClick: onSortClick
        }, _react.default.createElement(StyledFlexboxContainer, {
          container: true
        }, _react.default.createElement(_.FlexTable.CellInlineContainer, {
          item: true
        }, _react.default.createElement(_.FlexTable.Header.TextWrapper, {
          sorted: sorted
        }, children)), _react.default.createElement(_.Flexbox, {
          item: true
        }, _react.default.createElement(_.FlexTable.Header.TextWrapper, {
          sorted: sorted,
          truncate: false
        }, currency)), sortable && _react.default.createElement(_.Flexbox, {
          item: true
        }, _react.default.createElement(_.FlexTable.Header.SortIcon, {
          sortOrder: sortOrder
        }))));
      });
    };
    var NumberCell = _react.default.memo(function (_ref3) {
      var columnId = _ref3.columnId,
        value = _ref3.value,
        _ref3$percentage = _ref3.percentage,
        percentage = _ref3$percentage === void 0 ? false : _ref3$percentage,
        cellProps = _objectWithoutProperties(_ref3, _excluded);
      return _react.default.createElement(_.FlexTable.Cell, _extends({
        columnId: columnId
      }, cellProps), _react.default.createElement(_.FlexTable.Cell.TextWrapper, null, _react.default.createElement(_.Number, {
        value: value,
        percentage: percentage
      })));
    });
    var NumberFooter = _react.default.memo(function (_ref4) {
      var columnId = _ref4.columnId,
        value = _ref4.value,
        _ref4$percentage = _ref4.percentage,
        percentage = _ref4$percentage === void 0 ? false : _ref4$percentage,
        cellProps = _objectWithoutProperties(_ref4, _excluded2);
      return _react.default.createElement(_.FlexTable.Footer, _extends({
        columnId: columnId
      }, cellProps), _react.default.createElement(_.FlexTable.Footer.TextWrapper, null, _react.default.createElement(_.Number, {
        value: value,
        percentage: percentage
      })));
    });
    var DateCell = _react.default.memo(function (_ref5) {
      var columnId = _ref5.columnId,
        value = _ref5.value,
        cellProps = _objectWithoutProperties(_ref5, _excluded3);
      return _react.default.createElement(_.FlexTable.Cell, _extends({
        columnId: columnId
      }, cellProps), _react.default.createElement(_.FlexTable.Cell.TextWrapper, null, _react.default.createElement(_.DateTime, {
        value: value
      })));
    });
    var FlagCell = _react.default.memo(function (_ref6) {
      var columnId = _ref6.columnId,
        country = _ref6.country,
        cellProps = _objectWithoutProperties(_ref6, _excluded4);
      return _react.default.createElement(_.FlexTable.Cell, _extends({
        columnId: columnId
      }, cellProps), _react.default.createElement(_.FlexTable.Cell.TextWrapper, null, _react.default.createElement(_.Flag, {
        country: country,
        size: "s"
      })));
    });
    return _react.default.createElement(_reactIntl.IntlProvider, {
      locale: "en"
    }, _react.default.createElement(_.FlexTable, null, _react.default.createElement(_.FlexTable.HeaderRow, null, _react.default.createElement(_.FlexTable.Header, {
      columnId: "date"
    }, "Date"), _react.default.createElement(TruncateStartHeader, {
      columnId: "transferable-quantity",
      flex: "0 0 150px",
      justifyContent: "flex-end",
      currency: "USD"
    }, "Transferable quantity"), _react.default.createElement(_.FlexTable.Header, {
      columnId: "country"
    }, "Country"), _react.default.createElement(_.FlexTable.Header, {
      columnId: "percentage",
      justifyContent: "flex-end"
    }, "Percentage")), _react.default.createElement(_.FlexTable.Row, null, _react.default.createElement(DateCell, {
      columnId: "date",
      value: 1594385610185
    }), _react.default.createElement(NumberCell, {
      columnId: "transferable-quantity",
      value: 300,
      justifyContent: "flex-end",
      flex: "0 0 150px"
    }), _react.default.createElement(FlagCell, {
      columnId: "country",
      country: "SE"
    }), _react.default.createElement(NumberCell, {
      columnId: "percentage",
      value: 75,
      percentage: true,
      justifyContent: "flex-end"
    })), _react.default.createElement(_.FlexTable.Row, null, _react.default.createElement(DateCell, {
      columnId: "date",
      value: 1594385610000
    }), _react.default.createElement(NumberCell, {
      columnId: "transferable-quantity",
      value: 100,
      justifyContent: "flex-end",
      flex: "0 0 150px"
    }), _react.default.createElement(FlagCell, {
      columnId: "country",
      country: "NO"
    }), _react.default.createElement(NumberCell, {
      columnId: "percentage",
      value: 25,
      percentage: true,
      justifyContent: "flex-end"
    })), _react.default.createElement(_.FlexTable.FooterRow, null, _react.default.createElement(_.FlexTable.Footer, {
      columnId: "date"
    }), _react.default.createElement(NumberFooter, {
      columnId: "transferable-quantity",
      value: 400,
      justifyContent: "flex-end",
      flex: "0 0 150px"
    }), _react.default.createElement(_.FlexTable.Footer, {
      columnId: "country"
    }), _react.default.createElement(NumberFooter, {
      columnId: "percentage",
      value: 25,
      percentage: true,
      justifyContent: "flex-end"
    }))));
  };
  return _react.default.createElement(Story, null);
};
var BoldCells = exports.BoldCells = function BoldCells() {
  var Story = function Story() {
    var BoldCell = _react.default.memo(function (_ref7) {
      var columnId = _ref7.columnId,
        children = _ref7.children,
        cellProps = _objectWithoutProperties(_ref7, _excluded5);
      return _react.default.createElement(_.FlexTable.Cell, _extends({
        columnId: columnId
      }, cellProps), _react.default.createElement(_.FlexTable.Cell.TextWrapper, {
        weight: "bold"
      }, children));
    });
    return _react.default.createElement(_.FlexTable, null, _react.default.createElement(_.FlexTable.HeaderRow, null, _react.default.createElement(_.FlexTable.Header, {
      columnId: "column1"
    }, "Column 1"), _react.default.createElement(_.FlexTable.Header, {
      columnId: "column2"
    }, "Column 2"), _react.default.createElement(_.FlexTable.Header, {
      columnId: "column3"
    }, "Column 3")), _react.default.createElement(_.FlexTable.Row, null, _react.default.createElement(_.FlexTable.Cell, {
      columnId: "column1"
    }, "123"), _react.default.createElement(BoldCell, {
      columnId: "column2"
    }, "123"), _react.default.createElement(_.FlexTable.Cell, {
      columnId: "column3"
    }, "123")));
  };
  return _react.default.createElement(Story, null);
};