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.

AbstractDialogTab.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import { Component } from 'react';
  3. /**
  4. * The type of the React {@code Component} props of {@link AbstractDialogTab}.
  5. */
  6. export type Props = {
  7. /**
  8. * Function that closes the dialog.
  9. */
  10. closeDialog: Function,
  11. /**
  12. * Callback to invoke on change.
  13. */
  14. onTabStateChange: Function,
  15. /**
  16. * The id of the tab.
  17. */
  18. tabId: number
  19. };
  20. /**
  21. * Abstract React {@code Component} for tabs of the DialogWithTabs component.
  22. *
  23. * @extends Component
  24. */
  25. class AbstractDialogTab extends Component<Props> {
  26. /**
  27. * Initializes a new {@code AbstractDialogTab} instance.
  28. *
  29. * @param {Object} props - The read-only properties with which the new
  30. * instance is to be initialized.
  31. */
  32. constructor(props: Props) {
  33. super(props);
  34. // Bind event handler so it is only bound once for every instance.
  35. this._onChange = this._onChange.bind(this);
  36. }
  37. _onChange: (Object) => {};
  38. /**
  39. * Uses the onTabStateChange function to pass the changed state of the
  40. * controlled tab component to the controlling DialogWithTabs component.
  41. *
  42. * @param {Object} change - Object that contains the changed property and
  43. * value.
  44. * @returns {void}
  45. */
  46. _onChange(change) {
  47. const { onTabStateChange, tabId } = this.props;
  48. onTabStateChange(tabId, {
  49. ...this.props,
  50. ...change
  51. });
  52. }
  53. }
  54. export default AbstractDialogTab;