You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractContainer.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { Component } from 'react';
  2. /**
  3. * Abstract (base) class for container of React Component children with a style.
  4. *
  5. * @extends Component
  6. */
  7. export default class AbstractContainer extends Component {
  8. /**
  9. * Renders this AbstractContainer as a React Component of a specific type.
  10. *
  11. * @param {string|ReactClass} type - The type of the React Component which
  12. * is to be rendered.
  13. * @param {Object|undefined} props - The read-only React Component
  14. * properties, if any, to render. If undefined, the props of this instance
  15. * will be rendered.
  16. * @protected
  17. * @returns {ReactElement}
  18. */
  19. _render(type, props) {
  20. const {
  21. children,
  22. /* eslint-disable no-unused-vars */
  23. // The following properties are defined for the benefit of
  24. // AbstractContainer and its extenders so they are to not be
  25. // propagated.
  26. touchFeedback,
  27. visible,
  28. /* eslint-enable no-unused-vars */
  29. ...filteredProps
  30. } = props || this.props;
  31. return React.createElement(type, filteredProps, children);
  32. }
  33. }
  34. /**
  35. * AbstractContainer component's property types.
  36. *
  37. * @static
  38. */
  39. AbstractContainer.propTypes = {
  40. children: React.PropTypes.node,
  41. /**
  42. * The event handler/listener to be invoked when this AbstractContainer is
  43. * clicked on Web or pressed on React Native. If onClick is defined and
  44. * touchFeedback is undefined, touchFeedback is considered defined as true.
  45. */
  46. onClick: React.PropTypes.func,
  47. /**
  48. * The style (as in stylesheet) to be applied to this AbstractContainer.
  49. */
  50. style: React.PropTypes.object,
  51. /**
  52. * True if this instance is to provide visual feedback when touched;
  53. * otherwise, false. If touchFeedback is undefined and onClick is defined,
  54. * touchFeedback is considered defined as true.
  55. */
  56. touchFeedback: React.PropTypes.bool,
  57. /**
  58. * True if this AbstractContainer is to be visible or false if this instance
  59. * is to be hidden or not rendered at all.
  60. */
  61. visible: React.PropTypes.bool
  62. };