GridContentRenderer.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: Dashboard
  8. * (C) Copyright IBM Corp. 2020
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['react', 'prop-types'], function (React, PropTypes) {
  12. /**
  13. * @class GridContentRenderer
  14. * @classdesc React component to display grid cell content consisting of a value and an optional shape
  15. */
  16. var GridContentRenderer = function (_React$Component) {
  17. _inherits(GridContentRenderer, _React$Component);
  18. function GridContentRenderer(props) {
  19. _classCallCheck(this, GridContentRenderer);
  20. return _possibleConstructorReturn(this, _React$Component.call(this, props));
  21. }
  22. GridContentRenderer.prototype.render = function render() {
  23. var displayValue = this.props.displayValue;
  24. var shapeId = this.props.shapeId;
  25. var isShapeCol = 'shapeId' in this.props;
  26. var classNames = ['dashboard-text-cell'];
  27. if (isShapeCol) {
  28. classNames.push('grid-shape-right');
  29. if (!shapeId) {
  30. classNames.push('noShape');
  31. }
  32. }
  33. return React.createElement(
  34. React.Fragment,
  35. null,
  36. React.createElement(
  37. 'div',
  38. { className: classNames.join(' ') },
  39. displayValue
  40. ),
  41. shapeId && React.createElement(
  42. 'svg',
  43. { className: 'dashboard-grid-shape' },
  44. React.createElement('use', { xlinkHref: '#' + shapeId }),
  45. React.createElement(
  46. 'title',
  47. null,
  48. shapeId
  49. )
  50. )
  51. );
  52. };
  53. return GridContentRenderer;
  54. }(React.Component);
  55. GridContentRenderer.propTypes = {
  56. /** The value to display in the cell*/
  57. displayValue: PropTypes.string.isRequired,
  58. /** The optional shape id to render in the cell.*/
  59. shapeId: PropTypes.string
  60. };
  61. return GridContentRenderer;
  62. });
  63. //# sourceMappingURL=GridContentRenderer.js.map