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

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