• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / ui5-webcomponents-react / 9495452693

13 Jun 2024 07:23AM CUT coverage: 86.298% (+0.02%) from 86.282%
9495452693

Pull #5920

github

web-flow
Merge 8cd8b6a82 into 7a27b7f0a
Pull Request #5920: chore(deps): update ui5 web components to v2.0.0-rc.5 (patch)

2980 of 4086 branches covered (72.93%)

5404 of 6262 relevant lines covered (86.3%)

65738.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/packages/main/src/internal/ModalsContext.ts
1
import type { ComponentType, ContextType, Dispatch, RefCallback, RefObject } from 'react';
2
import { createContext, useContext } from 'react';
3

4
export interface UpdateModalStateAction<Props, DomRef, ContainerElement = HTMLElement> {
5
  type: 'set' | 'reset';
6
  payload?: ModalState<Props, DomRef, ContainerElement> | { id: string };
7
}
8

9
export interface ModalState<Props, DomRef, ContainerElement> {
10
  Component: ComponentType;
11
  props: Props;
12
  ref: RefObject<DomRef> | RefCallback<DomRef>;
13
  container: ContainerElement;
14
  id: string;
15
}
16

17
interface IModalsContext<Props, DomRef> {
18
  setModal?: Dispatch<UpdateModalStateAction<Props, DomRef>>;
19
}
20

21
const ModalsContext = createContext<IModalsContext<Record<string, any>, HTMLElement>>({
428✔
22
  setModal: null
23
});
24

25
export function getModalContext() {
26
  if (!globalThis['@ui5/webcomponents-react']?.ModalsContext) {
6,365✔
27
    globalThis['@ui5/webcomponents-react'] ??= {};
410✔
28
    globalThis['@ui5/webcomponents-react'].ModalsContext = ModalsContext;
410✔
29
  }
30

31
  return globalThis['@ui5/webcomponents-react'].ModalsContext;
6,365✔
32
}
33

34
export const useModalsContext = (): ContextType<typeof ModalsContext> => {
428✔
35
  return useContext(getModalContext());
27✔
36
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc