2022-09-29 10:26:34 +00:00
|
|
|
import { ComponentType } from 'react';
|
2017-09-18 20:52:10 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../app/types';
|
2022-09-29 10:26:34 +00:00
|
|
|
import { IStateful } from '../app/types';
|
|
|
|
// eslint-disable-next-line lines-around-comment
|
|
|
|
// @ts-ignore
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../color-scheme';
|
2022-09-29 10:26:34 +00:00
|
|
|
import { toState } from '../redux/functions';
|
2017-09-18 20:52:10 +00:00
|
|
|
|
2020-02-20 13:01:23 +00:00
|
|
|
/**
|
|
|
|
* Checks if any {@code Dialog} is currently open.
|
|
|
|
*
|
2022-09-29 10:26:34 +00:00
|
|
|
* @param {IStateful} stateful - The redux store, the redux
|
2020-02-20 13:01:23 +00:00
|
|
|
* {@code getState} function, or the redux state itself.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 10:26:34 +00:00
|
|
|
export function isAnyDialogOpen(stateful: IStateful) {
|
2020-02-20 13:01:23 +00:00
|
|
|
return Boolean(toState(stateful)['features/base/dialog'].component);
|
|
|
|
}
|
|
|
|
|
2017-09-18 20:52:10 +00:00
|
|
|
/**
|
2017-10-01 06:35:19 +00:00
|
|
|
* Checks if a {@code Dialog} with a specific {@code component} is currently
|
2017-09-18 20:52:10 +00:00
|
|
|
* open.
|
|
|
|
*
|
2022-09-29 10:26:34 +00:00
|
|
|
* @param {IStateful} stateful - The redux store, the redux
|
2017-10-01 06:35:19 +00:00
|
|
|
* {@code getState} function, or the redux state itself.
|
|
|
|
* @param {React.Component} component - The {@code component} of a
|
|
|
|
* {@code Dialog} to be checked.
|
2017-09-18 20:52:10 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-09-29 10:26:34 +00:00
|
|
|
export function isDialogOpen(stateful: IStateful, component: ComponentType) {
|
2017-09-18 20:52:10 +00:00
|
|
|
return toState(stateful)['features/base/dialog'].component === component;
|
|
|
|
}
|
2019-01-22 10:35:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of any Dialog based component.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The Redux state.
|
2019-01-22 10:35:28 +00:00
|
|
|
* @returns {{
|
|
|
|
* _dialogStyles: StyleType
|
|
|
|
* }}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function _abstractMapStateToProps(state: IReduxState) {
|
2019-01-22 10:35:28 +00:00
|
|
|
return {
|
|
|
|
_dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
|
|
|
|
};
|
|
|
|
}
|