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.ts 1.4KB

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