UNPKG

3.06 kBJavaScriptView Raw
1import { getUniqueId } from './uniqueId.js';
2import { string, node, shape, oneOfType, element, bool, func } from 'prop-types';
3import { a as _objectSpread, c as _objectWithoutPropertiesLoose, g as _extends } from './chunk-1f79df9b.js';
4import Box from 'reakit/Box';
5import 'reakit/Block';
6import 'reakit/Inline';
7import 'reakit/InlineBlock';
8import Flex from 'reakit/Flex';
9import 'reakit/InlineFlex';
10import 'reakit/Grid';
11import { createElement } from 'react';
12import { cardCardPropTypes, cardCardDefaultProps } from './Card/CardCard.js';
13import _Callout, { CalloutTitle, CalloutIcon, CalloutHeader, CalloutContent, CalloutFooter } from './Callout/styled.js';
14import CalloutClose, { calloutClosePropTypes } from './Callout/CalloutClose.js';
15
16var Callout = function Callout(_ref) {
17 var a11yDescriptionId = _ref.a11yDescriptionId,
18 a11yTitleId = _ref.a11yTitleId,
19 children = _ref.children,
20 closeButtonProps = _ref.closeButtonProps,
21 footer = _ref.footer,
22 hasTint = _ref.hasTint,
23 icon = _ref.icon,
24 onClickClose = _ref.onClickClose,
25 showCloseButton = _ref.showCloseButton,
26 title = _ref.title,
27 type = _ref.type,
28 props = _objectWithoutPropertiesLoose(_ref, ["a11yDescriptionId", "a11yTitleId", "children", "closeButtonProps", "footer", "hasTint", "icon", "onClickClose", "showCloseButton", "title", "type"]);
29
30 return createElement(_Callout, _extends({
31 a11yDescriptionId: a11yDescriptionId,
32 a11yTitleId: a11yTitleId,
33 hasTint: hasTint,
34 type: type
35 }, props), createElement(Flex, null, (type || icon) && createElement(CalloutTitle, null, createElement(CalloutIcon, {
36 icon: type || icon,
37 color: type
38 })), createElement(Box, null, title && createElement(CalloutHeader, null, typeof title === 'string' ? createElement(CalloutTitle, {
39 id: a11yTitleId
40 }, title) : title), createElement(CalloutContent, {
41 id: a11yDescriptionId
42 }, children), footer && createElement(CalloutFooter, null, footer))), showCloseButton && createElement(CalloutClose, _extends({
43 onClickClose: onClickClose
44 }, closeButtonProps)));
45};
46var calloutPropTypes = _objectSpread({
47 a11yDescriptionId: string,
48 a11yTitleId: string,
49 children: node.isRequired,
50 className: string,
51 closeButtonProps: shape(calloutClosePropTypes),
52 footer: oneOfType([string, element]),
53 hasTint: bool,
54 icon: string,
55 onClickClose: func,
56 showCloseButton: bool,
57 title: oneOfType([string, element]),
58 type: string
59}, cardCardPropTypes);
60Callout.propTypes = calloutPropTypes;
61var calloutDefaultProps = _objectSpread({}, cardCardDefaultProps, {
62 a11yDescriptionId: getUniqueId('Callout'),
63 a11yTitleId: getUniqueId('Callout'),
64 children: undefined,
65 className: undefined,
66 closeButtonProps: {},
67 footer: undefined,
68 hasTint: false,
69 icon: undefined,
70 onClickClose: undefined,
71 showCloseButton: false,
72 title: undefined,
73 type: undefined
74});
75Callout.defaultProps = calloutDefaultProps; // @ts-ignore
76
77var C = Callout;
78
79export { C as a, calloutPropTypes as b, calloutDefaultProps as c };