@zendeskgarden/react-modals 9.0.0-next.2 → 9.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/esm/elements/Body.js +42 -0
- package/dist/esm/elements/Close.js +53 -0
- package/dist/esm/elements/Drawer/Body.js +43 -0
- package/dist/esm/elements/Drawer/Close.js +54 -0
- package/dist/esm/elements/Drawer/Drawer.js +182 -0
- package/dist/esm/elements/Drawer/Footer.js +37 -0
- package/dist/esm/elements/Drawer/FooterItem.js +37 -0
- package/dist/esm/elements/Drawer/Header.js +69 -0
- package/dist/esm/elements/Footer.js +43 -0
- package/dist/esm/elements/FooterItem.js +36 -0
- package/dist/esm/elements/Header.js +70 -0
- package/dist/esm/elements/Modal.js +191 -0
- package/dist/esm/elements/TooltipModal/Body.js +43 -0
- package/dist/esm/elements/TooltipModal/Close.js +50 -0
- package/dist/esm/elements/TooltipModal/Footer.js +37 -0
- package/dist/esm/elements/TooltipModal/FooterItem.js +37 -0
- package/dist/esm/elements/TooltipModal/Title.js +68 -0
- package/dist/esm/elements/TooltipModal/TooltipModal.js +192 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js +37 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +26 -0
- package/dist/esm/styled/StyledBackdrop.js +49 -0
- package/dist/esm/styled/StyledBody.js +30 -0
- package/dist/esm/styled/StyledClose.js +28 -0
- package/dist/esm/styled/StyledDangerIcon.js +19 -0
- package/dist/esm/styled/StyledDrawer.js +44 -0
- package/dist/esm/styled/StyledDrawerBody.js +23 -0
- package/dist/esm/styled/StyledDrawerClose.js +28 -0
- package/dist/esm/styled/StyledDrawerFooter.js +30 -0
- package/dist/esm/styled/StyledDrawerFooterItem.js +23 -0
- package/dist/esm/styled/StyledDrawerHeader.js +24 -0
- package/dist/esm/styled/StyledFooter.js +22 -0
- package/dist/esm/styled/StyledFooterItem.js +22 -0
- package/dist/esm/styled/StyledHeader.js +38 -0
- package/dist/esm/styled/StyledModal.js +58 -0
- package/dist/esm/styled/StyledTooltipModal.js +33 -0
- package/dist/esm/styled/StyledTooltipModalBackdrop.js +22 -0
- package/dist/esm/styled/StyledTooltipModalBody.js +30 -0
- package/dist/esm/styled/StyledTooltipModalClose.js +23 -0
- package/dist/esm/styled/StyledTooltipModalFooter.js +22 -0
- package/dist/esm/styled/StyledTooltipModalFooterItem.js +23 -0
- package/dist/esm/styled/StyledTooltipModalTitle.js +36 -0
- package/dist/esm/styled/StyledTooltipWrapper.js +25 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/utils/useModalContext.js +18 -0
- package/dist/esm/utils/useTooltipModalContext.js +18 -0
- package/dist/index.cjs.js +272 -215
- package/dist/typings/elements/Body.d.ts +2 -0
- package/dist/typings/elements/Close.d.ts +2 -0
- package/dist/typings/elements/Footer.d.ts +2 -0
- package/dist/typings/elements/FooterItem.d.ts +2 -0
- package/dist/typings/elements/Header.d.ts +2 -0
- package/dist/typings/elements/Modal.d.ts +13 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/styled/StyledClose.d.ts +2 -5
- package/dist/typings/styled/StyledDrawerClose.d.ts +2 -1
- package/dist/typings/styled/StyledHeader.d.ts +2 -1
- package/dist/typings/styled/StyledTooltipModalClose.d.ts +2 -1
- package/package.json +9 -9
- package/dist/index.esm.js +0 -1115
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import styled, { keyframes, css } from 'styled-components';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor, mediaQuery } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'modals.modal';
|
|
12
|
+
const animationName = keyframes(["0%{transform:scale(0);opacity:0;}50%{transform:scale(1.05);}100%{opacity:1;}"]);
|
|
13
|
+
const animationStyles = props => {
|
|
14
|
+
if (props.isAnimated) {
|
|
15
|
+
return css(["animation:", " 0.3s ease-in;"], animationName);
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
};
|
|
19
|
+
const colorStyles = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
theme
|
|
22
|
+
} = _ref;
|
|
23
|
+
const offsetY = `${theme.space.base * 5}px`;
|
|
24
|
+
const blurRadius = `${theme.space.base * 7}px`;
|
|
25
|
+
const shadowColor = getColor({
|
|
26
|
+
variable: 'shadow.large',
|
|
27
|
+
theme
|
|
28
|
+
});
|
|
29
|
+
const shadow = theme.shadows.lg(offsetY, blurRadius, shadowColor);
|
|
30
|
+
const borderColor = getColor({
|
|
31
|
+
theme,
|
|
32
|
+
variable: 'border.default'
|
|
33
|
+
});
|
|
34
|
+
const backgroundColor = getColor({
|
|
35
|
+
theme,
|
|
36
|
+
variable: 'background.raised'
|
|
37
|
+
});
|
|
38
|
+
return css(["border-color:", ";box-shadow:", ";background-color:", ";"], borderColor, shadow, backgroundColor);
|
|
39
|
+
};
|
|
40
|
+
const sizeStyles = props => {
|
|
41
|
+
return css(["", "{width:", ";}"], mediaQuery('up', props.isLarge ? 'md' : 'sm', props.theme), props.isLarge ? props.theme.breakpoints.md : props.theme.breakpoints.sm);
|
|
42
|
+
};
|
|
43
|
+
const StyledModal = styled.div.attrs({
|
|
44
|
+
'data-garden-id': COMPONENT_ID,
|
|
45
|
+
'data-garden-version': '9.0.0-next.21'
|
|
46
|
+
}).withConfig({
|
|
47
|
+
displayName: "StyledModal",
|
|
48
|
+
componentId: "sc-1pe1axu-0"
|
|
49
|
+
})(["display:flex;position:fixed;flex-direction:column;animation-delay:0.01s;margin:", ";border:", ";border-radius:", ";min-height:60px;max-height:calc(100vh - ", "px);overflow:auto;direction:", ";", ";", ";", ";&:focus{outline:none;}@media (max-height:399px){top:", "px;bottom:auto;margin-bottom:", "px;max-height:none;}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){right:", ";bottom:", ";transform:", ";}", ";"], props => props.isCentered ? '0' : `${props.theme.space.base * 12}px`, props => props.theme.borders.sm, props => props.theme.borderRadii.md, props => props.theme.space.base * 24, props => props.theme.rtl && 'rtl', animationStyles, sizeStyles, colorStyles, props => props.theme.space.base * 6, props => props.theme.space.base * 6, props => props.isCentered && '50%', props => props.isCentered && '50%', props => props.isCentered && 'translate(50%, 50%)', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
50
|
+
StyledModal.propTypes = {
|
|
51
|
+
isLarge: PropTypes.bool,
|
|
52
|
+
isAnimated: PropTypes.bool
|
|
53
|
+
};
|
|
54
|
+
StyledModal.defaultProps = {
|
|
55
|
+
theme: DEFAULT_THEME
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { StyledModal };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { arrowStyles, getArrowPosition, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'modals.tooltip_modal';
|
|
11
|
+
const StyledTooltipModal = styled.div.attrs(props => ({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.21',
|
|
14
|
+
className: props.isAnimated && 'is-animated'
|
|
15
|
+
})).withConfig({
|
|
16
|
+
displayName: "StyledTooltipModal",
|
|
17
|
+
componentId: "sc-42ubfr-0"
|
|
18
|
+
})(["padding:", "px;width:400px;", ";", ";"], props => props.theme.space.base * 5, props => {
|
|
19
|
+
const computedArrowStyles = arrowStyles(getArrowPosition(props.theme, props.placement), {
|
|
20
|
+
size: `${props.theme.space.base * 2}px`,
|
|
21
|
+
inset: '1px',
|
|
22
|
+
animationModifier: '.is-animated'
|
|
23
|
+
});
|
|
24
|
+
if (props.isAnimated) {
|
|
25
|
+
return props.hasArrow && props.transitionState === 'entered' && computedArrowStyles;
|
|
26
|
+
}
|
|
27
|
+
return props.hasArrow && computedArrowStyles;
|
|
28
|
+
}, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
29
|
+
StyledTooltipModal.defaultProps = {
|
|
30
|
+
theme: DEFAULT_THEME
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { StyledTooltipModal };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'modals.tooltip_modal.backdrop';
|
|
11
|
+
const StyledTooltipModalBackdrop = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.21'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledTooltipModalBackdrop",
|
|
16
|
+
componentId: "sc-1yaomgq-0"
|
|
17
|
+
})(["position:fixed;inset:0;z-index:400;overflow:hidden;-webkit-overflow-scrolling:touch;font-family:", ";direction:", ";&.garden-tooltip-modal-transition-exit-active{pointer-events:none;}&.garden-tooltip-modal-transition-exit-active div{transition:opacity 200ms;opacity:0;}", ";"], props => props.theme.fonts.system, props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledTooltipModalBackdrop.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledTooltipModalBackdrop };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { getLineHeight, getColor, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'modals.tooltip_modal.body';
|
|
11
|
+
const StyledTooltipModalBody = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.21'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledTooltipModalBody",
|
|
16
|
+
componentId: "sc-195dkzj-0"
|
|
17
|
+
})(["display:block;margin:0;padding-top:", "px;line-height:", ";color-scheme:only ", ";color:", ";font-size:", ";", ";"], props => props.theme.space.base * 1.5, props => getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), p => p.theme.colors.base, _ref => {
|
|
18
|
+
let {
|
|
19
|
+
theme
|
|
20
|
+
} = _ref;
|
|
21
|
+
return getColor({
|
|
22
|
+
variable: 'foreground.default',
|
|
23
|
+
theme
|
|
24
|
+
});
|
|
25
|
+
}, props => props.theme.fontSizes.md, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
26
|
+
StyledTooltipModalBody.defaultProps = {
|
|
27
|
+
theme: DEFAULT_THEME
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { StyledTooltipModalBody };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledClose } from './StyledClose.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'modals.tooltip_modal.close';
|
|
12
|
+
const StyledTooltipModalClose = styled(StyledClose).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.21'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledTooltipModalClose",
|
|
17
|
+
componentId: "sc-1h2ke3q-0"
|
|
18
|
+
})(["top:", "px;", ":", ";", ";"], props => props.theme.space.base * 3.5, props => props.theme.rtl ? 'left' : 'right', props => `${props.theme.space.base * 3}px`, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledTooltipModalClose.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledTooltipModalClose };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'modals.tooltip_modal.footer';
|
|
11
|
+
const StyledTooltipModalFooter = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.21'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledTooltipModalFooter",
|
|
16
|
+
componentId: "sc-fm36a9-0"
|
|
17
|
+
})(["display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;padding-top:", "px;", ";"], p => p.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledTooltipModalFooter.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledTooltipModalFooter };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledFooterItem } from './StyledFooterItem.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'modals.tooltip_modal.footer_item';
|
|
12
|
+
const StyledTooltipModalFooterItem = styled(StyledFooterItem).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.21'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledTooltipModalFooterItem",
|
|
17
|
+
componentId: "sc-1nahj6p-0"
|
|
18
|
+
})(["", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledTooltipModalFooterItem.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledTooltipModalFooterItem };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { getColor, retrieveComponentStyles, DEFAULT_THEME, getLineHeight } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'modals.tooltip_modal.title';
|
|
11
|
+
const sizeStyles = props => `
|
|
12
|
+
/* stylelint-disable-next-line property-no-unknown */
|
|
13
|
+
padding-${props.theme.rtl ? 'left' : 'right'}: ${props.theme.space.base * 8}px;
|
|
14
|
+
line-height: ${getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md)};
|
|
15
|
+
font-size: ${props.theme.fontSizes.md};
|
|
16
|
+
`;
|
|
17
|
+
const StyledTooltipModalTitle = styled.div.attrs({
|
|
18
|
+
'data-garden-id': COMPONENT_ID,
|
|
19
|
+
'data-garden-version': '9.0.0-next.21'
|
|
20
|
+
}).withConfig({
|
|
21
|
+
displayName: "StyledTooltipModalTitle",
|
|
22
|
+
componentId: "sc-11xjgjs-0"
|
|
23
|
+
})(["margin:0;color:", ";font-weight:", ";", ";", ";"], _ref => {
|
|
24
|
+
let {
|
|
25
|
+
theme
|
|
26
|
+
} = _ref;
|
|
27
|
+
return getColor({
|
|
28
|
+
variable: 'foreground.default',
|
|
29
|
+
theme
|
|
30
|
+
});
|
|
31
|
+
}, props => props.theme.fontWeights.semibold, props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
32
|
+
StyledTooltipModalTitle.defaultProps = {
|
|
33
|
+
theme: DEFAULT_THEME
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { StyledTooltipModalTitle };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { menuStyles, getMenuPosition, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const StyledTooltipWrapper = styled.div.attrs(props => ({
|
|
11
|
+
className: props.isAnimated && 'is-animated'
|
|
12
|
+
})).withConfig({
|
|
13
|
+
displayName: "StyledTooltipWrapper",
|
|
14
|
+
componentId: "sc-1xk05kf-0"
|
|
15
|
+
})(["top:0;left:0;", ";"], props => menuStyles(getMenuPosition(props.placement), {
|
|
16
|
+
theme: props.theme,
|
|
17
|
+
hidden: false,
|
|
18
|
+
zIndex: props.zIndex,
|
|
19
|
+
animationModifier: '.is-animated'
|
|
20
|
+
}));
|
|
21
|
+
StyledTooltipWrapper.defaultProps = {
|
|
22
|
+
theme: DEFAULT_THEME
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { StyledTooltipWrapper };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { PLACEMENT as PLACEMENT$1 } from '@zendeskgarden/react-theming';
|
|
8
|
+
|
|
9
|
+
const PLACEMENT = ['auto', ...PLACEMENT$1];
|
|
10
|
+
|
|
11
|
+
export { PLACEMENT };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const ModalsContext = createContext(undefined);
|
|
10
|
+
const useModalContext = () => {
|
|
11
|
+
const context = useContext(ModalsContext);
|
|
12
|
+
if (context === undefined) {
|
|
13
|
+
throw new Error('useModalContext must be used within a ModalsContext.Provider');
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { ModalsContext, useModalContext };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const TooltipModalContext = createContext(undefined);
|
|
10
|
+
const useTooltipModalContext = () => {
|
|
11
|
+
const context = useContext(TooltipModalContext);
|
|
12
|
+
if (context === undefined) {
|
|
13
|
+
throw new Error('Element must be used within a TooltipModal component.');
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { TooltipModalContext, useTooltipModalContext };
|