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.

functions.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* @flow */
  2. import { ColorSchemeRegistry } from '../color-scheme';
  3. import { toState } from '../redux';
  4. /**
  5. * Checks if any {@code Dialog} is currently open.
  6. *
  7. * @param {Function|Object} stateful - The redux store, the redux
  8. * {@code getState} function, or the redux state itself.
  9. * @returns {boolean}
  10. */
  11. export function isAnyDialogOpen(stateful: Function) {
  12. return Boolean(toState(stateful)['features/base/dialog'].component);
  13. }
  14. /**
  15. * Checks if a {@code Dialog} with a specific {@code component} is currently
  16. * open.
  17. *
  18. * @param {Function|Object} stateful - The redux store, the redux
  19. * {@code getState} function, or the redux state itself.
  20. * @param {React.Component} component - The {@code component} of a
  21. * {@code Dialog} to be checked.
  22. * @returns {boolean}
  23. */
  24. export function isDialogOpen(stateful: Function | Object, component: Object) {
  25. return toState(stateful)['features/base/dialog'].component === component;
  26. }
  27. /**
  28. * Maps part of the Redux state to the props of any Dialog based component.
  29. *
  30. * @param {Object} state - The Redux state.
  31. * @returns {{
  32. * _dialogStyles: StyleType
  33. * }}
  34. */
  35. export function _abstractMapStateToProps(state: Object): Object {
  36. return {
  37. _dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
  38. };
  39. }