@openedx/paragon 22.18.2 → 22.20.0
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/dist/Alert/index.d.ts +36 -0
- package/dist/Alert/index.js +18 -9
- package/dist/Alert/index.js.map +1 -1
- package/dist/Modal/ModalDialog.d.ts +0 -1
- package/dist/Modal/ModalDialog.js +6 -3
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Modal/messages.d.ts +8 -0
- package/dist/Modal/messages.js +10 -0
- package/dist/Modal/messages.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/utils/breakpoints.d.ts +26 -0
- package/package.json +1 -1
- package/src/Alert/{Alert.test.jsx → Alert.test.tsx} +33 -3
- package/src/Alert/{index.jsx → index.tsx} +92 -29
- package/src/Modal/ModalDialog.tsx +6 -4
- package/src/Modal/messages.ts +11 -0
- package/src/Modal/tests/AlertModal.test.jsx +48 -39
- package/src/Modal/tests/ModalDialog.test.tsx +57 -50
- package/src/index.d.ts +3 -3
- package/src/index.js +3 -3
- package/src/utils/breakpoints.d.ts +26 -0
- /package/src/Alert/__snapshots__/{Alert.test.jsx.snap → Alert.test.tsx.snap} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { ReactNode, ElementType, FC, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import { AlertProps as BaseAlertProps } from 'react-bootstrap';
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
4
|
+
export declare const ALERT_CLOSE_LABEL_TEXT = "Dismiss";
|
|
5
|
+
export type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';
|
|
6
|
+
export type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;
|
|
7
|
+
export interface AlertProps extends BaseProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
bsPrefix?: string;
|
|
10
|
+
variant?: AlertVariant;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
icon?: React.ComponentType<IconProps>;
|
|
13
|
+
show?: boolean;
|
|
14
|
+
dismissible?: boolean;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
actions?: React.ReactElement[];
|
|
17
|
+
stacked?: boolean;
|
|
18
|
+
closeLabel?: string | ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface AlertHeadingProps {
|
|
21
|
+
as?: ElementType;
|
|
22
|
+
bsPrefix?: string;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export interface AlertLinkProps {
|
|
26
|
+
as?: ElementType;
|
|
27
|
+
bsPrefix?: string;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
href?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AlertComponent extends ForwardRefExoticComponent<AlertProps & RefAttributes<HTMLDivElement>> {
|
|
32
|
+
Heading: FC<AlertHeadingProps>;
|
|
33
|
+
Link: FC<AlertLinkProps>;
|
|
34
|
+
}
|
|
35
|
+
declare const Alert: AlertComponent;
|
|
36
|
+
export default Alert;
|
package/dist/Alert/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react/require-default-props */
|
|
2
|
+
import React, { useCallback, useEffect, useState, forwardRef, cloneElement } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
|
-
import BaseAlert from 'react-bootstrap
|
|
5
|
+
import { Alert as BaseAlert } from 'react-bootstrap';
|
|
5
6
|
import divWithClassName from 'react-bootstrap/divWithClassName';
|
|
6
7
|
import { FormattedMessage } from 'react-intl';
|
|
7
8
|
import { useMediaQuery } from 'react-responsive';
|
|
8
9
|
import Icon from '../Icon';
|
|
9
10
|
import breakpoints from '../utils/breakpoints';
|
|
10
11
|
import Button from '../Button';
|
|
12
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
11
13
|
import ActionRow from '../ActionRow';
|
|
12
14
|
export const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';
|
|
13
|
-
const Alert = /*#__PURE__*/
|
|
15
|
+
const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
16
|
let {
|
|
15
17
|
children,
|
|
16
18
|
icon,
|
|
@@ -38,7 +40,7 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
38
40
|
size: actionButtonSize,
|
|
39
41
|
key: Action.props.children
|
|
40
42
|
};
|
|
41
|
-
return /*#__PURE__*/
|
|
43
|
+
return /*#__PURE__*/cloneElement(Action, addtlActionProps);
|
|
42
44
|
}, []);
|
|
43
45
|
return /*#__PURE__*/React.createElement(BaseAlert, {
|
|
44
46
|
...props,
|
|
@@ -54,7 +56,7 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
54
56
|
})
|
|
55
57
|
}, /*#__PURE__*/React.createElement("div", {
|
|
56
58
|
className: "alert-message-content"
|
|
57
|
-
}, children), (dismissible || actions
|
|
59
|
+
}, children), (dismissible || actions && actions.length > 0) && /*#__PURE__*/React.createElement(ActionRow, {
|
|
58
60
|
className: "pgn__alert-actions"
|
|
59
61
|
}, /*#__PURE__*/React.createElement(ActionRow.Spacer, null), dismissible && /*#__PURE__*/React.createElement(Button, {
|
|
60
62
|
size: actionButtonSize,
|
|
@@ -82,14 +84,18 @@ function AlertLink(props) {
|
|
|
82
84
|
...props
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
AlertLink.propTypes = {
|
|
88
|
+
/** Specifies the base element */
|
|
89
|
+
as: PropTypes.elementType,
|
|
90
|
+
/** Overrides underlying component base CSS class name */
|
|
91
|
+
bsPrefix: PropTypes.string
|
|
92
|
+
};
|
|
93
|
+
AlertHeading.propTypes = {
|
|
86
94
|
/** Specifies the base element */
|
|
87
95
|
as: PropTypes.elementType,
|
|
88
96
|
/** Overrides underlying component base CSS class name */
|
|
89
97
|
bsPrefix: PropTypes.string
|
|
90
98
|
};
|
|
91
|
-
AlertLink.propTypes = commonPropTypes;
|
|
92
|
-
AlertHeading.propTypes = commonPropTypes;
|
|
93
99
|
AlertLink.defaultProps = {
|
|
94
100
|
as: 'a',
|
|
95
101
|
bsPrefix: 'alert-link'
|
|
@@ -147,7 +153,10 @@ Alert.defaultProps = {
|
|
|
147
153
|
onClose: () => {},
|
|
148
154
|
closeLabel: undefined,
|
|
149
155
|
show: true,
|
|
150
|
-
stacked: false
|
|
156
|
+
stacked: false,
|
|
157
|
+
className: undefined,
|
|
158
|
+
bsPrefix: undefined,
|
|
159
|
+
variant: undefined
|
|
151
160
|
};
|
|
152
161
|
Alert.Heading = AlertHeading;
|
|
153
162
|
Alert.Link = AlertLink;
|
package/dist/Alert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","PropTypes","classNames","BaseAlert","divWithClassName","FormattedMessage","useMediaQuery","Icon","breakpoints","Button","ActionRow","ALERT_CLOSE_LABEL_TEXT","Alert","forwardRef","_ref","ref","children","icon","actions","dismissible","onClose","closeLabel","stacked","props","isStacked","setIsStacked","isExtraSmall","maxWidth","extraSmall","actionButtonSize","cloneActionElement","Action","addtlActionProps","size","key","cloneElement","createElement","className","src","length","Spacer","variant","onClick","id","defaultMessage","description","map","DivStyledAsH4","displayName","AlertHeading","Heading","AlertLink","Link","commonPropTypes","as","elementType","bsPrefix","string","propTypes","defaultProps","oneOf","transition","oneOfType","bool","shape","in","appear","node","onEnter","func","onEntered","onEntering","onExit","onExited","onExiting","show","arrayOf","element","undefined"],"sources":["../../src/Alert/index.jsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport BaseAlert from 'react-bootstrap/Alert';\nimport divWithClassName from 'react-bootstrap/divWithClassName';\nimport { FormattedMessage } from 'react-intl';\nimport { useMediaQuery } from 'react-responsive';\nimport Icon from '../Icon';\nimport breakpoints from '../utils/breakpoints';\nimport Button from '../Button';\nimport ActionRow from '../ActionRow';\n\nexport const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';\n\nconst Alert = React.forwardRef(({\n children,\n icon,\n actions,\n dismissible,\n onClose,\n closeLabel,\n stacked,\n ...props\n}, ref) => {\n const [isStacked, setIsStacked] = useState(stacked);\n const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });\n const actionButtonSize = 'sm';\n\n useEffect(() => {\n if (isExtraSmall) {\n setIsStacked(true);\n } else {\n setIsStacked(stacked);\n }\n }, [isExtraSmall, stacked]);\n\n const cloneActionElement = useCallback(\n (Action) => {\n const addtlActionProps = { size: actionButtonSize, key: Action.props.children };\n return React.cloneElement(Action, addtlActionProps);\n },\n [],\n );\n\n return (\n <BaseAlert\n {...props}\n className={classNames('alert-content', props.className)}\n ref={ref}\n >\n {icon && <Icon src={icon} className=\"alert-icon\" />}\n <div\n className={classNames({\n 'pgn__alert-message-wrapper': !isStacked,\n 'pgn__alert-message-wrapper-stacked': isStacked,\n })}\n >\n <div className=\"alert-message-content\">\n {children}\n </div>\n {(dismissible || actions?.length > 0) && (\n <ActionRow className=\"pgn__alert-actions\">\n <ActionRow.Spacer />\n {dismissible && (\n <Button\n size={actionButtonSize}\n variant=\"tertiary\"\n onClick={onClose}\n >\n {closeLabel || (\n <FormattedMessage\n id=\"pgn.Alert.closeLabel\"\n defaultMessage=\"Dismiss\"\n description=\"Label of a close button on Alert component\"\n />\n )}\n </Button>\n )}\n {actions && actions.map(cloneActionElement)}\n </ActionRow>\n )}\n </div>\n </BaseAlert>\n );\n});\n\n// This is needed to display a default prop for Alert.Heading element\n// Copied from react-bootstrap since BaseAlert.Heading component doesn't have defaultProps,\n// so there seems to be no other way of providing correct default prop for base element\nconst DivStyledAsH4 = divWithClassName('h4');\nDivStyledAsH4.displayName = 'DivStyledAsH4';\n\nfunction AlertHeading(props) {\n return <BaseAlert.Heading {...props} />;\n}\nfunction AlertLink(props) {\n return <BaseAlert.Link {...props} />;\n}\n\nconst commonPropTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nAlertLink.propTypes = commonPropTypes;\nAlertHeading.propTypes = commonPropTypes;\n\nAlertLink.defaultProps = {\n as: 'a',\n bsPrefix: 'alert-link',\n};\n\nAlertHeading.defaultProps = {\n as: DivStyledAsH4,\n bsPrefix: 'alert-heading',\n};\n\nAlert.propTypes = {\n ...BaseAlert.propTypes,\n /** Specifies class name to append to the base element */\n className: PropTypes.string,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n /** Specifies variant to use. */\n variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light']),\n /**\n * Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,\n * more detailed customization is also provided.\n */\n transition: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({\n in: PropTypes.bool,\n appear: PropTypes.bool,\n children: PropTypes.node,\n onEnter: PropTypes.func,\n onEntered: PropTypes.func,\n onEntering: PropTypes.func,\n onExit: PropTypes.func,\n onExited: PropTypes.func,\n onExiting: PropTypes.func,\n })]),\n /** Docstring for the children prop */\n children: PropTypes.node,\n /** Docstring for the icon prop... Icon that will be shown in the alert */\n icon: PropTypes.func,\n /** Whether the alert is shown. */\n show: PropTypes.bool,\n /** Whether the alert is dismissible. Defaults to true. */\n dismissible: PropTypes.bool,\n /** Optional callback function for when the alert it dismissed. */\n onClose: PropTypes.func,\n /** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */\n actions: PropTypes.arrayOf(PropTypes.element),\n /** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */\n stacked: PropTypes.bool,\n /** Sets the text for alert close button, defaults to 'Dismiss'. */\n closeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n};\n\nAlert.defaultProps = {\n ...BaseAlert.defaultProps,\n children: undefined,\n icon: undefined,\n actions: undefined,\n dismissible: false,\n onClose: () => {},\n closeLabel: undefined,\n show: true,\n stacked: false,\n};\n\nAlert.Heading = AlertHeading;\nAlert.Link = AlertLink;\n\nexport default Alert;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,SAAS,MAAM,cAAc;AAEpC,OAAO,MAAMC,sBAAsB,GAAG,SAAS;AAE/C,MAAMC,KAAK,gBAAGf,KAAK,CAACgB,UAAU,CAAC,CAAAC,IAAA,EAS5BC,GAAG,KAAK;EAAA,IATqB;IAC9BC,QAAQ;IACRC,IAAI;IACJC,OAAO;IACPC,WAAW;IACXC,OAAO;IACPC,UAAU;IACVC,OAAO;IACP,GAAGC;EACL,CAAC,GAAAT,IAAA;EACC,MAAM,CAACU,SAAS,EAAEC,YAAY,CAAC,GAAGzB,QAAQ,CAACsB,OAAO,CAAC;EACnD,MAAMI,YAAY,GAAGpB,aAAa,CAAC;IAAEqB,QAAQ,EAAEnB,WAAW,CAACoB,UAAU,CAACD;EAAS,CAAC,CAAC;EACjF,MAAME,gBAAgB,GAAG,IAAI;EAE7B9B,SAAS,CAAC,MAAM;IACd,IAAI2B,YAAY,EAAE;MAChBD,YAAY,CAAC,IAAI,CAAC;IACpB,CAAC,MAAM;MACLA,YAAY,CAACH,OAAO,CAAC;IACvB;EACF,CAAC,EAAE,CAACI,YAAY,EAAEJ,OAAO,CAAC,C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CAAA,KAAM,CAAC,CAAC;EACjBC,UAAU,EAAEyD,SAAS;EACrBH,IAAI,EAAE,IAAI;EACVrD,OAAO,EAAE;AACX,CAAC;AAEDV,KAAK,CAACsC,OAAO,GAAGD,YAAY;AAC5BrC,KAAK,CAACwC,IAAI,GAAGD,SAAS;AAEtB,eAAevC,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","forwardRef","cloneElement","PropTypes","classNames","Alert","BaseAlert","divWithClassName","FormattedMessage","useMediaQuery","Icon","breakpoints","Button","ActionRow","ALERT_CLOSE_LABEL_TEXT","_ref","ref","children","icon","actions","dismissible","onClose","closeLabel","stacked","props","isStacked","setIsStacked","isExtraSmall","maxWidth","extraSmall","actionButtonSize","cloneActionElement","Action","addtlActionProps","size","key","createElement","className","src","length","Spacer","variant","onClick","id","defaultMessage","description","map","DivStyledAsH4","displayName","AlertHeading","Heading","AlertLink","Link","propTypes","as","elementType","bsPrefix","string","defaultProps","oneOf","transition","oneOfType","bool","shape","in","appear","node","onEnter","func","onEntered","onEntering","onExit","onExited","onExiting","show","arrayOf","element","undefined"],"sources":["../../src/Alert/index.tsx"],"sourcesContent":["/* eslint-disable react/require-default-props */\nimport React, {\n useCallback,\n useEffect,\n useState,\n ReactNode,\n ElementType,\n forwardRef,\n FC,\n ForwardRefExoticComponent,\n RefAttributes,\n cloneElement,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport {\n Alert as BaseAlert,\n AlertProps as BaseAlertProps,\n} from 'react-bootstrap';\nimport divWithClassName from 'react-bootstrap/divWithClassName';\nimport { FormattedMessage } from 'react-intl';\nimport { useMediaQuery } from 'react-responsive';\nimport Icon, { IconProps } from '../Icon';\nimport breakpoints from '../utils/breakpoints';\nimport Button from '../Button';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ActionRow from '../ActionRow';\n\nexport const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';\n\nexport type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';\n\nexport type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;\n\nexport interface AlertProps extends BaseProps {\n className?: string;\n bsPrefix?: string;\n variant?: AlertVariant;\n children?: ReactNode;\n icon?: React.ComponentType<IconProps>;\n show?: boolean;\n dismissible?: boolean;\n onClose?: () => void;\n actions?: React.ReactElement[];\n stacked?: boolean;\n closeLabel?: string | ReactNode;\n}\n\nexport interface AlertHeadingProps {\n as?: ElementType;\n bsPrefix?: string;\n children?: ReactNode;\n}\n\nexport interface AlertLinkProps {\n as?: ElementType;\n bsPrefix?: string;\n children?: ReactNode;\n href?: string;\n}\n\nexport interface AlertComponent extends ForwardRefExoticComponent<AlertProps & RefAttributes<HTMLDivElement>> {\n Heading: FC<AlertHeadingProps>;\n Link: FC<AlertLinkProps>;\n}\n\nconst Alert = forwardRef<HTMLDivElement, AlertProps>(({\n children,\n icon,\n actions,\n dismissible,\n onClose,\n closeLabel,\n stacked,\n ...props\n}, ref) => {\n const [isStacked, setIsStacked] = useState(stacked);\n const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });\n const actionButtonSize = 'sm';\n\n useEffect(() => {\n if (isExtraSmall) {\n setIsStacked(true);\n } else {\n setIsStacked(stacked);\n }\n }, [isExtraSmall, stacked]);\n\n const cloneActionElement = useCallback(\n (Action: React.ReactElement) => {\n const addtlActionProps = { size: actionButtonSize, key: Action.props.children };\n return cloneElement(Action, addtlActionProps);\n },\n [],\n );\n\n return (\n <BaseAlert\n {...props}\n className={classNames('alert-content', props.className)}\n ref={ref}\n >\n {icon && <Icon src={icon} className=\"alert-icon\" />}\n <div\n className={classNames({\n 'pgn__alert-message-wrapper': !isStacked,\n 'pgn__alert-message-wrapper-stacked': isStacked,\n })}\n >\n <div className=\"alert-message-content\">\n {children}\n </div>\n {(dismissible || (actions && actions.length > 0)) && (\n <ActionRow className=\"pgn__alert-actions\">\n <ActionRow.Spacer />\n {dismissible && (\n <Button\n size={actionButtonSize}\n variant=\"tertiary\"\n onClick={onClose}\n >\n {closeLabel || (\n <FormattedMessage\n id=\"pgn.Alert.closeLabel\"\n defaultMessage=\"Dismiss\"\n description=\"Label of a close button on Alert component\"\n />\n )}\n </Button>\n )}\n {actions && actions.map(cloneActionElement)}\n </ActionRow>\n )}\n </div>\n </BaseAlert>\n );\n}) as AlertComponent;\n\n// This is needed to display a default prop for Alert.Heading element\n// Copied from react-bootstrap since BaseAlert.Heading component doesn't have defaultProps,\n// so there seems to be no other way of providing correct default prop for base element\nconst DivStyledAsH4 = divWithClassName('h4');\nDivStyledAsH4.displayName = 'DivStyledAsH4';\n\nfunction AlertHeading(props: AlertHeadingProps): JSX.Element {\n return <BaseAlert.Heading {...props} />;\n}\n\nfunction AlertLink(props: AlertLinkProps): JSX.Element {\n return <BaseAlert.Link {...props} />;\n}\n\nAlertLink.propTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType as PropTypes.Validator<ElementType>,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nAlertHeading.propTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType as PropTypes.Validator<ElementType>,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nAlertLink.defaultProps = {\n as: 'a' as ElementType,\n bsPrefix: 'alert-link',\n};\n\nAlertHeading.defaultProps = {\n as: DivStyledAsH4,\n bsPrefix: 'alert-heading',\n};\n\nAlert.propTypes = {\n ...BaseAlert.propTypes,\n /** Specifies class name to append to the base element */\n className: PropTypes.string,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n /** Specifies variant to use. */\n variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'] as AlertVariant[]),\n /**\n * Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,\n * more detailed customization is also provided.\n */\n transition: PropTypes.oneOfType([\n PropTypes.bool,\n PropTypes.shape({\n in: PropTypes.bool,\n appear: PropTypes.bool,\n children: PropTypes.node,\n onEnter: PropTypes.func,\n onEntered: PropTypes.func,\n onEntering: PropTypes.func,\n onExit: PropTypes.func,\n onExited: PropTypes.func,\n onExiting: PropTypes.func,\n }),\n ]) as PropTypes.Validator<BaseAlertProps['transition']>,\n /** Docstring for the children prop */\n children: PropTypes.node as PropTypes.Validator<ReactNode>,\n /** Docstring for the icon prop... Icon that will be shown in the alert */\n icon: PropTypes.func,\n /** Whether the alert is shown. */\n show: PropTypes.bool,\n /** Whether the alert is dismissible. Defaults to true. */\n dismissible: PropTypes.bool,\n /** Optional callback function for when the alert it dismissed. */\n onClose: PropTypes.func,\n /** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */\n actions: PropTypes.arrayOf(PropTypes.element) as PropTypes.Validator<React.ReactElement[]>,\n /** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */\n stacked: PropTypes.bool,\n /** Sets the text for alert close button, defaults to 'Dismiss'. */\n closeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n};\n\nAlert.defaultProps = {\n ...BaseAlert.defaultProps,\n children: undefined,\n icon: undefined,\n actions: undefined,\n dismissible: false,\n onClose: () => {},\n closeLabel: undefined,\n show: true,\n stacked: false,\n className: undefined,\n bsPrefix: undefined,\n variant: undefined,\n};\n\nAlert.Heading = AlertHeading;\nAlert.Link = AlertLink;\n\nexport default Alert;\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,QAAQ,EAGRC,UAAU,EAIVC,YAAY,QACP,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,KAAK,IAAIC,SAAS,QAEb,iBAAiB;AACxB,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAO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-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useMediaQuery } from 'react-responsive';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
5
6
|
import ModalLayer from './ModalLayer';
|
|
6
7
|
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
7
8
|
import ModalCloseButton from './ModalCloseButton';
|
|
@@ -17,7 +18,7 @@ import ModalDialogHero from './ModalDialogHero';
|
|
|
17
18
|
import Icon from '../Icon';
|
|
18
19
|
import IconButton from '../IconButton';
|
|
19
20
|
import { Close } from '../../icons';
|
|
20
|
-
|
|
21
|
+
import messages from './messages';
|
|
21
22
|
function ModalDialog(_ref) {
|
|
22
23
|
let {
|
|
23
24
|
children,
|
|
@@ -27,7 +28,7 @@ function ModalDialog(_ref) {
|
|
|
27
28
|
size = 'md',
|
|
28
29
|
variant = 'default',
|
|
29
30
|
hasCloseButton = true,
|
|
30
|
-
closeLabel
|
|
31
|
+
closeLabel,
|
|
31
32
|
isFullscreenScroll = false,
|
|
32
33
|
className,
|
|
33
34
|
isFullscreenOnMobile = false,
|
|
@@ -35,6 +36,8 @@ function ModalDialog(_ref) {
|
|
|
35
36
|
zIndex,
|
|
36
37
|
isOverflowVisible
|
|
37
38
|
} = _ref;
|
|
39
|
+
const intl = useIntl();
|
|
40
|
+
const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);
|
|
38
41
|
const isMobile = useMediaQuery({
|
|
39
42
|
query: '(max-width: 767.98px)'
|
|
40
43
|
});
|
|
@@ -60,7 +63,7 @@ function ModalDialog(_ref) {
|
|
|
60
63
|
iconAs: Icon,
|
|
61
64
|
invertColors: variant === 'dark',
|
|
62
65
|
src: Close,
|
|
63
|
-
alt:
|
|
66
|
+
alt: closeButtonText
|
|
64
67
|
})), children));
|
|
65
68
|
}
|
|
66
69
|
ModalDialog.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","
|
|
1
|
+
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","useIntl","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","messages","ModalDialog","_ref","children","title","isOpen","onClose","size","variant","hasCloseButton","closeLabel","isFullscreenScroll","className","isFullscreenOnMobile","isBlocking","zIndex","isOverflowVisible","intl","closeButtonText","formatMessage","isMobile","query","showFullScreen","createElement","role","as","iconAs","invertColors","src","alt","propTypes","node","isRequired","string","func","bool","oneOf","number","Header","Title","Footer","CloseButton","Body","Hero"],"sources":["../../src/Modal/ModalDialog.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useMediaQuery } from 'react-responsive';\nimport { useIntl } from 'react-intl';\nimport ModalLayer from './ModalLayer';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalCloseButton from './ModalCloseButton';\nimport ModalDialogHeader from './ModalDialogHeader';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogTitle from './ModalDialogTitle';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogFooter from './ModalDialogFooter';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogBody from './ModalDialogBody';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogHero from './ModalDialogHero';\n\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\nimport { Close } from '../../icons';\nimport messages from './messages';\n\ninterface Props {\n /** Specifies the content of the dialog */\n children: React.ReactNode;\n /** The aria-label of the dialog */\n title: string;\n /** A callback to close the modal dialog, e.g. when Escape is pressed */\n onClose: () => void;\n /** Is the modal dialog open or closed? */\n isOpen?: boolean;\n /** The close 'x' icon button in the top right of the dialog box */\n hasCloseButton?: boolean;\n /** Size determines the maximum width of the dialog box */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'fullscreen';\n /** The visual style of the dialog box */\n variant?: 'default' | 'warning' | 'danger' | 'success' | 'dark';\n /** The label supplied to the close icon button if one is rendered */\n closeLabel?: string;\n /** Specifies class name to append to the base element */\n className?: string;\n /**\n * Determines where a scrollbar should appear if a modal is too large for the\n * viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true\n * the browser window itself receives the scrollbar.\n */\n isFullscreenScroll?: boolean;\n /** To show full screen view on mobile screens */\n isFullscreenOnMobile?: boolean;\n /** Prevent clicking on the backdrop or pressing Esc to close the modal */\n isBlocking?: boolean;\n /** Specifies the z-index of the modal */\n zIndex?: number;\n /** Specifies whether overflow is visible in the modal */\n isOverflowVisible: boolean;\n}\n\nfunction ModalDialog({\n children,\n title,\n isOpen = false,\n onClose,\n size = 'md',\n variant = 'default',\n hasCloseButton = true,\n closeLabel,\n isFullscreenScroll = false,\n className,\n isFullscreenOnMobile = false,\n isBlocking = false,\n zIndex,\n isOverflowVisible,\n}: Props) {\n const intl = useIntl();\n const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);\n const isMobile = useMediaQuery({ query: '(max-width: 767.98px)' });\n const showFullScreen = (isFullscreenOnMobile && isMobile);\n return (\n <ModalLayer isOpen={isOpen} onClose={onClose} isBlocking={isBlocking} zIndex={zIndex}>\n <div\n role=\"dialog\"\n aria-label={title}\n className={classNames(\n 'pgn__modal',\n {\n [`pgn__modal-${showFullScreen ? 'fullscreen' : size}`]: size,\n [`pgn__modal-${variant}`]: variant,\n 'pgn__modal-scroll-fullscreen': isFullscreenScroll,\n 'pgn__modal-visible-overflow': isOverflowVisible,\n },\n className,\n )}\n >\n {hasCloseButton && (\n <div className=\"pgn__modal-close-container\">\n <ModalCloseButton\n as={IconButton}\n iconAs={Icon}\n invertColors={variant === 'dark'}\n src={Close}\n alt={closeButtonText}\n />\n </div>\n )}\n {children}\n </div>\n </ModalLayer>\n );\n}\n\nModalDialog.propTypes = {\n /**\n * Specifies the content of the dialog\n */\n children: PropTypes.node.isRequired,\n /**\n * The aria-label of the dialog\n */\n title: PropTypes.string.isRequired,\n /**\n * A callback to close the modal dialog\n */\n onClose: PropTypes.func.isRequired,\n /**\n * Is the modal dialog open or closed\n */\n isOpen: PropTypes.bool,\n /**\n * The close 'x' icon button in the top right of the dialog box\n */\n hasCloseButton: PropTypes.bool,\n /**\n * Sizes determine the maximum width of the dialog box\n */\n size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl', 'fullscreen']),\n /**\n * The visual style of the dialog box\n */\n variant: PropTypes.oneOf(['default', 'warning', 'danger', 'success', 'dark']),\n /**\n * The label supplied to the close icon button if one is rendered\n */\n closeLabel: PropTypes.string,\n /**\n * Specifies class name to append to the base element\n */\n className: PropTypes.string,\n /**\n * Determines where a scrollbar should appear if a modal is too large for the\n * viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true\n * the browser window itself receives the scrollbar.\n */\n isFullscreenScroll: PropTypes.bool,\n /**\n * To show full screen view on mobile screens\n */\n isFullscreenOnMobile: PropTypes.bool,\n /**\n * Prevent clicking on the backdrop or pressing Esc to close the modal\n */\n isBlocking: PropTypes.bool,\n /**\n * Specifies the z-index of the modal\n */\n zIndex: PropTypes.number,\n /** Specifies whether overflow is visible in the modal */\n isOverflowVisible: PropTypes.bool.isRequired,\n};\n\nModalDialog.Header = ModalDialogHeader;\nModalDialog.Title = ModalDialogTitle;\nModalDialog.Footer = ModalDialogFooter;\nModalDialog.CloseButton = ModalCloseButton;\nModalDialog.Body = ModalDialogBody;\nModalDialog.Hero = ModalDialogHero;\n\nexport default ModalDialog;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,UAAU,MAAM,cAAc;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EAAE1B,SAAS,CAAC+C,MAAM;EAC3B;AACF;AACA;AACA;AACA;EACEtB,kBAAkB,EAAEzB,SAAS,CAACiD,IAAI;EAClC;AACF;AACA;EACEtB,oBAAoB,EAAE3B,SAAS,CAACiD,IAAI;EACpC;AACF;AACA;EACErB,UAAU,EAAE5B,SAAS,CAACiD,IAAI;EAC1B;AACF;AACA;EACEpB,MAAM,EAAE7B,SAAS,CAACmD,MAAM;EACxB;EACArB,iBAAiB,EAAE9B,SAAS,CAACiD,IAAI,CAACH;AACpC,CAAC;AAED/B,WAAW,CAACqC,MAAM,GAAG9C,iBAAiB;AACtCS,WAAW,CAACsC,KAAK,GAAG9C,gBAAgB;AACpCQ,WAAW,CAACuC,MAAM,GAAG9C,iBAAiB;AACtCO,WAAW,CAACwC,WAAW,GAAGlD,gBAAgB;AAC1CU,WAAW,CAACyC,IAAI,GAAG/C,eAAe;AAClCM,WAAW,CAAC0C,IAAI,GAAG/C,eAAe;AAElC,eAAeK,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
const messages = defineMessages({
|
|
3
|
+
closeButtonText: {
|
|
4
|
+
id: 'pgn.Modal.closeButon',
|
|
5
|
+
defaultMessage: 'Close',
|
|
6
|
+
description: 'Accessible name for the close button in the modal dialog'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export default messages;
|
|
10
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":["defineMessages","messages","closeButtonText","id","defaultMessage","description"],"sources":["../../src/Modal/messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nconst messages = defineMessages({\n closeButtonText: {\n id: 'pgn.Modal.closeButon',\n defaultMessage: 'Close',\n description: 'Accessible name for the close button in the modal dialog',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAE3C,MAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9BE,eAAe,EAAE;IACfC,EAAE,EAAE,sBAAsB;IAC1BC,cAAc,EAAE,OAAO;IACvBC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
|
@@ -46,13 +46,14 @@ export { default as useToggle, type Toggler, type ToggleHandlers } from './hooks
|
|
|
46
46
|
export { default as useArrowKeyNavigation, type ArrowKeyNavProps } from './hooks/useArrowKeyNavigationHook';
|
|
47
47
|
export { default as useIndexOfLastVisibleChild } from './hooks/useIndexOfLastVisibleChildHook';
|
|
48
48
|
export { default as useIsVisible } from './hooks/useIsVisibleHook';
|
|
49
|
+
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
50
|
+
export { default as breakpoints } from './utils/breakpoints';
|
|
49
51
|
|
|
50
52
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
51
53
|
// Things that don't have types
|
|
52
54
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
53
55
|
export const asInput: any; // from './asInput';
|
|
54
56
|
export const ActionRow: any; // from './ActionRow';
|
|
55
|
-
export const Alert: any, ALERT_CLOSE_LABEL_TEXT: string; // from './Alert';
|
|
56
57
|
export const Annotation: any; // from './Annotation';
|
|
57
58
|
export const Avatar: any; // from './Avatar';
|
|
58
59
|
export const AvatarButton: any; // from './AvatarButton';
|
|
@@ -190,7 +191,6 @@ export const Stack: any; // from './Stack';
|
|
|
190
191
|
export const ToggleButton: any, ToggleButtonGroup: any; // from './ToggleButton';
|
|
191
192
|
export const Sticky: any; // from './Sticky';
|
|
192
193
|
export const SelectableBox: any; // from './SelectableBox';
|
|
193
|
-
export const breakpoints: any; // from './utils/breakpoints';
|
|
194
194
|
export const Variant: any; // from './utils/constants';
|
|
195
195
|
export const
|
|
196
196
|
OverflowScrollContext: any,
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
|
@@ -46,13 +46,14 @@ export { default as useToggle } from './hooks/useToggleHook';
|
|
|
46
46
|
export { default as useArrowKeyNavigation } from './hooks/useArrowKeyNavigationHook';
|
|
47
47
|
export { default as useIndexOfLastVisibleChild } from './hooks/useIndexOfLastVisibleChildHook';
|
|
48
48
|
export { default as useIsVisible } from './hooks/useIsVisibleHook';
|
|
49
|
+
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
50
|
+
export { default as breakpoints } from './utils/breakpoints';
|
|
49
51
|
|
|
50
52
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
51
53
|
// Things that don't have types
|
|
52
54
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
53
55
|
export { default as asInput } from './asInput';
|
|
54
56
|
export { default as ActionRow } from './ActionRow';
|
|
55
|
-
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
56
57
|
export { default as Annotation } from './Annotation';
|
|
57
58
|
export { default as Avatar } from './Avatar';
|
|
58
59
|
export { default as AvatarButton } from './AvatarButton';
|
|
@@ -190,7 +191,6 @@ export { default as Stack } from './Stack';
|
|
|
190
191
|
export { default as ToggleButton, ToggleButtonGroup } from './ToggleButton';
|
|
191
192
|
export { default as Sticky } from './Sticky';
|
|
192
193
|
export { default as SelectableBox } from './SelectableBox';
|
|
193
|
-
export { default as breakpoints } from './utils/breakpoints';
|
|
194
194
|
export { default as Variant } from './utils/constants';
|
|
195
195
|
export {
|
|
196
196
|
OverflowScrollContext,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface BreakpointRange {
|
|
2
|
+
minWidth?: number;
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface Breakpoints {
|
|
7
|
+
extraSmall: BreakpointRange;
|
|
8
|
+
small: BreakpointRange;
|
|
9
|
+
medium: BreakpointRange;
|
|
10
|
+
large: BreakpointRange;
|
|
11
|
+
extraLarge: BreakpointRange;
|
|
12
|
+
extraExtraLarge: BreakpointRange;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Size: {
|
|
16
|
+
readonly xs: 'extraSmall';
|
|
17
|
+
readonly sm: 'small';
|
|
18
|
+
readonly md: 'medium';
|
|
19
|
+
readonly lg: 'large';
|
|
20
|
+
readonly xl: 'extraLarge';
|
|
21
|
+
readonly xxl: 'extraExtraLarge';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare const breakpoints: Breakpoints;
|
|
25
|
+
|
|
26
|
+
export default breakpoints;
|
package/package.json
CHANGED
|
@@ -7,10 +7,13 @@ import { Context as ResponsiveContext } from 'react-responsive';
|
|
|
7
7
|
import { Info } from '../../icons';
|
|
8
8
|
import breakpoints from '../utils/breakpoints';
|
|
9
9
|
import Button from '../Button';
|
|
10
|
-
import Alert from '.';
|
|
10
|
+
import Alert, { AlertProps } from '.';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** A compile time check. Whatever React elements this wraps won't run at runtime. */
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
function CompileCheck(_props: { children: React.ReactNode }) { return null; }
|
|
15
|
+
|
|
16
|
+
function AlertWrapper({ children, ...props }: AlertProps & { children: React.ReactNode }) {
|
|
14
17
|
return (
|
|
15
18
|
<IntlProvider locale="en" messages={{}}>
|
|
16
19
|
<Alert {...props}>
|
|
@@ -20,6 +23,33 @@ function AlertWrapper({ children, ...props }) {
|
|
|
20
23
|
);
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
describe('Alert component type checking', () => {
|
|
27
|
+
it('has correct typing', () => {
|
|
28
|
+
<CompileCheck>
|
|
29
|
+
<Alert>Basic alert</Alert>
|
|
30
|
+
<Alert variant="primary">Primary alert</Alert>
|
|
31
|
+
<Alert icon={Info}>Alert with icon</Alert>
|
|
32
|
+
<Alert dismissible onClose={() => {}}>Dismissible alert</Alert>
|
|
33
|
+
<Alert actions={[<Button key="action">Action</Button>]}>Alert with action</Alert>
|
|
34
|
+
<Alert stacked>Stacked alert</Alert>
|
|
35
|
+
<Alert closeLabel="Close">Custom close label</Alert>
|
|
36
|
+
<Alert.Heading>Alert heading</Alert.Heading>
|
|
37
|
+
<Alert.Link href="#">Alert link</Alert.Link>
|
|
38
|
+
|
|
39
|
+
{/* @ts-expect-error Invalid variant */}
|
|
40
|
+
<Alert variant="invalid" />
|
|
41
|
+
{/* @ts-expect-error Invalid icon type */}
|
|
42
|
+
<Alert icon="string" />
|
|
43
|
+
{/* @ts-expect-error Invalid closeLabel type */}
|
|
44
|
+
<Alert closeLabel={{}} />
|
|
45
|
+
{/* @ts-expect-error Invalid Heading props */}
|
|
46
|
+
<Alert.Heading href="#" />
|
|
47
|
+
{/* @ts-expect-error Invalid Link props */}
|
|
48
|
+
<Alert.Link variant="primary" />
|
|
49
|
+
</CompileCheck>;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
23
53
|
describe('<Alert />', () => {
|
|
24
54
|
it('renders without any props', () => {
|
|
25
55
|
const tree = renderer.create((
|
|
@@ -1,18 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react/require-default-props */
|
|
2
|
+
import React, {
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
ReactNode,
|
|
7
|
+
ElementType,
|
|
8
|
+
forwardRef,
|
|
9
|
+
FC,
|
|
10
|
+
ForwardRefExoticComponent,
|
|
11
|
+
RefAttributes,
|
|
12
|
+
cloneElement,
|
|
13
|
+
} from 'react';
|
|
2
14
|
import PropTypes from 'prop-types';
|
|
3
15
|
import classNames from 'classnames';
|
|
4
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
Alert as BaseAlert,
|
|
18
|
+
AlertProps as BaseAlertProps,
|
|
19
|
+
} from 'react-bootstrap';
|
|
5
20
|
import divWithClassName from 'react-bootstrap/divWithClassName';
|
|
6
21
|
import { FormattedMessage } from 'react-intl';
|
|
7
22
|
import { useMediaQuery } from 'react-responsive';
|
|
8
|
-
import Icon from '../Icon';
|
|
23
|
+
import Icon, { IconProps } from '../Icon';
|
|
9
24
|
import breakpoints from '../utils/breakpoints';
|
|
10
25
|
import Button from '../Button';
|
|
26
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
11
27
|
import ActionRow from '../ActionRow';
|
|
12
28
|
|
|
13
29
|
export const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';
|
|
14
30
|
|
|
15
|
-
|
|
31
|
+
export type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';
|
|
32
|
+
|
|
33
|
+
export type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;
|
|
34
|
+
|
|
35
|
+
export interface AlertProps extends BaseProps {
|
|
36
|
+
className?: string;
|
|
37
|
+
bsPrefix?: string;
|
|
38
|
+
variant?: AlertVariant;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
icon?: React.ComponentType<IconProps>;
|
|
41
|
+
show?: boolean;
|
|
42
|
+
dismissible?: boolean;
|
|
43
|
+
onClose?: () => void;
|
|
44
|
+
actions?: React.ReactElement[];
|
|
45
|
+
stacked?: boolean;
|
|
46
|
+
closeLabel?: string | ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AlertHeadingProps {
|
|
50
|
+
as?: ElementType;
|
|
51
|
+
bsPrefix?: string;
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AlertLinkProps {
|
|
56
|
+
as?: ElementType;
|
|
57
|
+
bsPrefix?: string;
|
|
58
|
+
children?: ReactNode;
|
|
59
|
+
href?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AlertComponent extends ForwardRefExoticComponent<AlertProps & RefAttributes<HTMLDivElement>> {
|
|
63
|
+
Heading: FC<AlertHeadingProps>;
|
|
64
|
+
Link: FC<AlertLinkProps>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const Alert = forwardRef<HTMLDivElement, AlertProps>(({
|
|
16
68
|
children,
|
|
17
69
|
icon,
|
|
18
70
|
actions,
|
|
@@ -35,9 +87,9 @@ const Alert = React.forwardRef(({
|
|
|
35
87
|
}, [isExtraSmall, stacked]);
|
|
36
88
|
|
|
37
89
|
const cloneActionElement = useCallback(
|
|
38
|
-
(Action) => {
|
|
90
|
+
(Action: React.ReactElement) => {
|
|
39
91
|
const addtlActionProps = { size: actionButtonSize, key: Action.props.children };
|
|
40
|
-
return
|
|
92
|
+
return cloneElement(Action, addtlActionProps);
|
|
41
93
|
},
|
|
42
94
|
[],
|
|
43
95
|
);
|
|
@@ -58,7 +110,7 @@ const Alert = React.forwardRef(({
|
|
|
58
110
|
<div className="alert-message-content">
|
|
59
111
|
{children}
|
|
60
112
|
</div>
|
|
61
|
-
{(dismissible || actions
|
|
113
|
+
{(dismissible || (actions && actions.length > 0)) && (
|
|
62
114
|
<ActionRow className="pgn__alert-actions">
|
|
63
115
|
<ActionRow.Spacer />
|
|
64
116
|
{dismissible && (
|
|
@@ -82,7 +134,7 @@ const Alert = React.forwardRef(({
|
|
|
82
134
|
</div>
|
|
83
135
|
</BaseAlert>
|
|
84
136
|
);
|
|
85
|
-
});
|
|
137
|
+
}) as AlertComponent;
|
|
86
138
|
|
|
87
139
|
// This is needed to display a default prop for Alert.Heading element
|
|
88
140
|
// Copied from react-bootstrap since BaseAlert.Heading component doesn't have defaultProps,
|
|
@@ -90,25 +142,30 @@ const Alert = React.forwardRef(({
|
|
|
90
142
|
const DivStyledAsH4 = divWithClassName('h4');
|
|
91
143
|
DivStyledAsH4.displayName = 'DivStyledAsH4';
|
|
92
144
|
|
|
93
|
-
function AlertHeading(props) {
|
|
145
|
+
function AlertHeading(props: AlertHeadingProps): JSX.Element {
|
|
94
146
|
return <BaseAlert.Heading {...props} />;
|
|
95
147
|
}
|
|
96
|
-
|
|
148
|
+
|
|
149
|
+
function AlertLink(props: AlertLinkProps): JSX.Element {
|
|
97
150
|
return <BaseAlert.Link {...props} />;
|
|
98
151
|
}
|
|
99
152
|
|
|
100
|
-
|
|
153
|
+
AlertLink.propTypes = {
|
|
101
154
|
/** Specifies the base element */
|
|
102
|
-
as: PropTypes.elementType
|
|
155
|
+
as: PropTypes.elementType as PropTypes.Validator<ElementType>,
|
|
103
156
|
/** Overrides underlying component base CSS class name */
|
|
104
157
|
bsPrefix: PropTypes.string,
|
|
105
158
|
};
|
|
106
159
|
|
|
107
|
-
|
|
108
|
-
|
|
160
|
+
AlertHeading.propTypes = {
|
|
161
|
+
/** Specifies the base element */
|
|
162
|
+
as: PropTypes.elementType as PropTypes.Validator<ElementType>,
|
|
163
|
+
/** Overrides underlying component base CSS class name */
|
|
164
|
+
bsPrefix: PropTypes.string,
|
|
165
|
+
};
|
|
109
166
|
|
|
110
167
|
AlertLink.defaultProps = {
|
|
111
|
-
as: 'a',
|
|
168
|
+
as: 'a' as ElementType,
|
|
112
169
|
bsPrefix: 'alert-link',
|
|
113
170
|
};
|
|
114
171
|
|
|
@@ -124,24 +181,27 @@ Alert.propTypes = {
|
|
|
124
181
|
/** Overrides underlying component base CSS class name */
|
|
125
182
|
bsPrefix: PropTypes.string,
|
|
126
183
|
/** Specifies variant to use. */
|
|
127
|
-
variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light']),
|
|
184
|
+
variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'] as AlertVariant[]),
|
|
128
185
|
/**
|
|
129
186
|
* Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,
|
|
130
187
|
* more detailed customization is also provided.
|
|
131
188
|
*/
|
|
132
|
-
transition: PropTypes.oneOfType([
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
189
|
+
transition: PropTypes.oneOfType([
|
|
190
|
+
PropTypes.bool,
|
|
191
|
+
PropTypes.shape({
|
|
192
|
+
in: PropTypes.bool,
|
|
193
|
+
appear: PropTypes.bool,
|
|
194
|
+
children: PropTypes.node,
|
|
195
|
+
onEnter: PropTypes.func,
|
|
196
|
+
onEntered: PropTypes.func,
|
|
197
|
+
onEntering: PropTypes.func,
|
|
198
|
+
onExit: PropTypes.func,
|
|
199
|
+
onExited: PropTypes.func,
|
|
200
|
+
onExiting: PropTypes.func,
|
|
201
|
+
}),
|
|
202
|
+
]) as PropTypes.Validator<BaseAlertProps['transition']>,
|
|
143
203
|
/** Docstring for the children prop */
|
|
144
|
-
children: PropTypes.node
|
|
204
|
+
children: PropTypes.node as PropTypes.Validator<ReactNode>,
|
|
145
205
|
/** Docstring for the icon prop... Icon that will be shown in the alert */
|
|
146
206
|
icon: PropTypes.func,
|
|
147
207
|
/** Whether the alert is shown. */
|
|
@@ -151,7 +211,7 @@ Alert.propTypes = {
|
|
|
151
211
|
/** Optional callback function for when the alert it dismissed. */
|
|
152
212
|
onClose: PropTypes.func,
|
|
153
213
|
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
|
|
154
|
-
actions: PropTypes.arrayOf(PropTypes.element)
|
|
214
|
+
actions: PropTypes.arrayOf(PropTypes.element) as PropTypes.Validator<React.ReactElement[]>,
|
|
155
215
|
/** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */
|
|
156
216
|
stacked: PropTypes.bool,
|
|
157
217
|
/** Sets the text for alert close button, defaults to 'Dismiss'. */
|
|
@@ -168,6 +228,9 @@ Alert.defaultProps = {
|
|
|
168
228
|
closeLabel: undefined,
|
|
169
229
|
show: true,
|
|
170
230
|
stacked: false,
|
|
231
|
+
className: undefined,
|
|
232
|
+
bsPrefix: undefined,
|
|
233
|
+
variant: undefined,
|
|
171
234
|
};
|
|
172
235
|
|
|
173
236
|
Alert.Heading = AlertHeading;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useMediaQuery } from 'react-responsive';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
5
6
|
import ModalLayer from './ModalLayer';
|
|
6
7
|
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
7
8
|
import ModalCloseButton from './ModalCloseButton';
|
|
@@ -18,8 +19,7 @@ import ModalDialogHero from './ModalDialogHero';
|
|
|
18
19
|
import Icon from '../Icon';
|
|
19
20
|
import IconButton from '../IconButton';
|
|
20
21
|
import { Close } from '../../icons';
|
|
21
|
-
|
|
22
|
-
export const MODAL_DIALOG_CLOSE_LABEL = 'Close';
|
|
22
|
+
import messages from './messages';
|
|
23
23
|
|
|
24
24
|
interface Props {
|
|
25
25
|
/** Specifies the content of the dialog */
|
|
@@ -64,7 +64,7 @@ function ModalDialog({
|
|
|
64
64
|
size = 'md',
|
|
65
65
|
variant = 'default',
|
|
66
66
|
hasCloseButton = true,
|
|
67
|
-
closeLabel
|
|
67
|
+
closeLabel,
|
|
68
68
|
isFullscreenScroll = false,
|
|
69
69
|
className,
|
|
70
70
|
isFullscreenOnMobile = false,
|
|
@@ -72,6 +72,8 @@ function ModalDialog({
|
|
|
72
72
|
zIndex,
|
|
73
73
|
isOverflowVisible,
|
|
74
74
|
}: Props) {
|
|
75
|
+
const intl = useIntl();
|
|
76
|
+
const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);
|
|
75
77
|
const isMobile = useMediaQuery({ query: '(max-width: 767.98px)' });
|
|
76
78
|
const showFullScreen = (isFullscreenOnMobile && isMobile);
|
|
77
79
|
return (
|
|
@@ -97,7 +99,7 @@ function ModalDialog({
|
|
|
97
99
|
iconAs={Icon}
|
|
98
100
|
invertColors={variant === 'dark'}
|
|
99
101
|
src={Close}
|
|
100
|
-
alt={
|
|
102
|
+
alt={closeButtonText}
|
|
101
103
|
/>
|
|
102
104
|
</div>
|
|
103
105
|
)}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
closeButtonText: {
|
|
5
|
+
id: 'pgn.Modal.closeButon',
|
|
6
|
+
defaultMessage: 'Close',
|
|
7
|
+
description: 'Accessible name for the close button in the modal dialog',
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default messages;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
+
import { IntlProvider } from 'react-intl';
|
|
4
5
|
import AlertModal from '../AlertModal';
|
|
5
6
|
import { Info } from '../../../icons';
|
|
6
7
|
|
|
@@ -37,15 +38,17 @@ describe('<AlertModal />', () => {
|
|
|
37
38
|
|
|
38
39
|
it('renders the body when isOpen', () => {
|
|
39
40
|
render(
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
<IntlProvider locale="en" messages={{}}>
|
|
42
|
+
<AlertModal
|
|
43
|
+
title="some title"
|
|
44
|
+
isOpen={isOpen}
|
|
45
|
+
onClose={closeFn}
|
|
46
|
+
footerNode={<p>footer</p>}
|
|
47
|
+
isOverflowVisible={false}
|
|
48
|
+
>
|
|
49
|
+
<Body />
|
|
50
|
+
</AlertModal>
|
|
51
|
+
</IntlProvider>,
|
|
49
52
|
);
|
|
50
53
|
|
|
51
54
|
const body = screen.getByText('The body of alert.');
|
|
@@ -55,16 +58,18 @@ describe('<AlertModal />', () => {
|
|
|
55
58
|
describe('with variant prop', () => {
|
|
56
59
|
it('renders warning variant', () => {
|
|
57
60
|
render(
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
<IntlProvider locale="en" messages={{}}>
|
|
62
|
+
<AlertModal
|
|
63
|
+
title="warning"
|
|
64
|
+
isOpen={isOpen}
|
|
65
|
+
onClose={closeFn}
|
|
66
|
+
icon={Info}
|
|
67
|
+
footerNode={<p>footer</p>}
|
|
68
|
+
isOverflowVisible={false}
|
|
69
|
+
>
|
|
70
|
+
<Body />
|
|
71
|
+
</AlertModal>
|
|
72
|
+
</IntlProvider>,
|
|
68
73
|
);
|
|
69
74
|
|
|
70
75
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -73,16 +78,18 @@ describe('<AlertModal />', () => {
|
|
|
73
78
|
|
|
74
79
|
it('renders success variant', () => {
|
|
75
80
|
render(
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
<IntlProvider locale="en" messages={{}}>
|
|
82
|
+
<AlertModal
|
|
83
|
+
title="success"
|
|
84
|
+
isOpen={isOpen}
|
|
85
|
+
onClose={closeFn}
|
|
86
|
+
icon={Info}
|
|
87
|
+
footerNode={<p>footer</p>}
|
|
88
|
+
isOverflowVisible={false}
|
|
89
|
+
>
|
|
90
|
+
<Body />
|
|
91
|
+
</AlertModal>
|
|
92
|
+
</IntlProvider>,
|
|
86
93
|
);
|
|
87
94
|
|
|
88
95
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -91,16 +98,18 @@ describe('<AlertModal />', () => {
|
|
|
91
98
|
|
|
92
99
|
it('renders danger variant', () => {
|
|
93
100
|
render(
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
<IntlProvider locale="en" messages={{}}>
|
|
102
|
+
<AlertModal
|
|
103
|
+
title="danger"
|
|
104
|
+
isOpen={isOpen}
|
|
105
|
+
onClose={closeFn}
|
|
106
|
+
icon={Info}
|
|
107
|
+
footerNode={<p>footer</p>}
|
|
108
|
+
isOverflowVisible={false}
|
|
109
|
+
>
|
|
110
|
+
<Body />
|
|
111
|
+
</AlertModal>
|
|
112
|
+
</IntlProvider>,
|
|
104
113
|
);
|
|
105
114
|
|
|
106
115
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
+
import { IntlProvider } from 'react-intl';
|
|
4
5
|
import ModalDialog from '../ModalDialog';
|
|
5
6
|
|
|
6
7
|
describe('ModalDialog', () => {
|
|
7
8
|
it('renders a dialog with aria-label and content', () => {
|
|
8
9
|
const onClose = jest.fn();
|
|
9
10
|
render(
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<ModalDialog.
|
|
21
|
-
|
|
11
|
+
<IntlProvider locale="en" messages={{}}>
|
|
12
|
+
<ModalDialog
|
|
13
|
+
title="My dialog"
|
|
14
|
+
isOpen
|
|
15
|
+
onClose={onClose}
|
|
16
|
+
size="md"
|
|
17
|
+
variant="default"
|
|
18
|
+
hasCloseButton
|
|
19
|
+
isOverflowVisible={false}
|
|
20
|
+
>
|
|
21
|
+
<ModalDialog.Header>
|
|
22
|
+
<ModalDialog.Title>The title</ModalDialog.Title>
|
|
23
|
+
</ModalDialog.Header>
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
<ModalDialog.Body>
|
|
26
|
+
<p>The content</p>
|
|
27
|
+
</ModalDialog.Body>
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<ModalDialog.Footer>
|
|
30
|
+
<ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
|
|
31
|
+
</ModalDialog.Footer>
|
|
32
|
+
</ModalDialog>
|
|
33
|
+
</IntlProvider>,
|
|
31
34
|
);
|
|
32
35
|
|
|
33
36
|
const dialogNode = screen.getByRole('dialog');
|
|
@@ -40,15 +43,17 @@ describe('ModalDialog', () => {
|
|
|
40
43
|
it('is hidden by default', () => {
|
|
41
44
|
const onClose = jest.fn();
|
|
42
45
|
render(
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
<IntlProvider locale="en" messages={{}}>
|
|
47
|
+
<ModalDialog
|
|
48
|
+
title="My dialog"
|
|
49
|
+
onClose={onClose}
|
|
50
|
+
isOverflowVisible={false}
|
|
51
|
+
>
|
|
52
|
+
<ModalDialog.Header><ModalDialog.Title>The title</ModalDialog.Title></ModalDialog.Header>
|
|
53
|
+
<ModalDialog.Body><p>The hidden content</p></ModalDialog.Body>
|
|
54
|
+
<ModalDialog.Footer><ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton></ModalDialog.Footer>
|
|
55
|
+
</ModalDialog>
|
|
56
|
+
</IntlProvider>,
|
|
52
57
|
);
|
|
53
58
|
|
|
54
59
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
@@ -59,30 +64,32 @@ describe('ModalDialog with Hero', () => {
|
|
|
59
64
|
it('renders a dialog with aria-label and hero with img', () => {
|
|
60
65
|
const onClose = jest.fn();
|
|
61
66
|
render(
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<ModalDialog.Hero
|
|
73
|
-
|
|
74
|
-
<ModalDialog.
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
<IntlProvider locale="en" messages={{}}>
|
|
68
|
+
<ModalDialog
|
|
69
|
+
title="My dialog"
|
|
70
|
+
isOpen
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
size="md"
|
|
73
|
+
variant="default"
|
|
74
|
+
hasCloseButton
|
|
75
|
+
isOverflowVisible={false}
|
|
76
|
+
>
|
|
77
|
+
<ModalDialog.Hero>
|
|
78
|
+
<ModalDialog.Hero.Background backgroundSrc="imageurl" />
|
|
79
|
+
<ModalDialog.Hero.Content data-testid="modal-hero-content">
|
|
80
|
+
<ModalDialog.Title>The title</ModalDialog.Title>
|
|
81
|
+
</ModalDialog.Hero.Content>
|
|
82
|
+
</ModalDialog.Hero>
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
<ModalDialog.Body>
|
|
85
|
+
<p>The content</p>
|
|
86
|
+
</ModalDialog.Body>
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
<ModalDialog.Footer>
|
|
89
|
+
<ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
|
|
90
|
+
</ModalDialog.Footer>
|
|
91
|
+
</ModalDialog>
|
|
92
|
+
</IntlProvider>,
|
|
86
93
|
);
|
|
87
94
|
const dialogNode = screen.getByRole('dialog');
|
|
88
95
|
|
package/src/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
|
@@ -46,13 +46,14 @@ export { default as useToggle, type Toggler, type ToggleHandlers } from './hooks
|
|
|
46
46
|
export { default as useArrowKeyNavigation, type ArrowKeyNavProps } from './hooks/useArrowKeyNavigationHook';
|
|
47
47
|
export { default as useIndexOfLastVisibleChild } from './hooks/useIndexOfLastVisibleChildHook';
|
|
48
48
|
export { default as useIsVisible } from './hooks/useIsVisibleHook';
|
|
49
|
+
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
50
|
+
export { default as breakpoints } from './utils/breakpoints';
|
|
49
51
|
|
|
50
52
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
51
53
|
// Things that don't have types
|
|
52
54
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
53
55
|
export const asInput: any; // from './asInput';
|
|
54
56
|
export const ActionRow: any; // from './ActionRow';
|
|
55
|
-
export const Alert: any, ALERT_CLOSE_LABEL_TEXT: string; // from './Alert';
|
|
56
57
|
export const Annotation: any; // from './Annotation';
|
|
57
58
|
export const Avatar: any; // from './Avatar';
|
|
58
59
|
export const AvatarButton: any; // from './AvatarButton';
|
|
@@ -190,7 +191,6 @@ export const Stack: any; // from './Stack';
|
|
|
190
191
|
export const ToggleButton: any, ToggleButtonGroup: any; // from './ToggleButton';
|
|
191
192
|
export const Sticky: any; // from './Sticky';
|
|
192
193
|
export const SelectableBox: any; // from './SelectableBox';
|
|
193
|
-
export const breakpoints: any; // from './utils/breakpoints';
|
|
194
194
|
export const Variant: any; // from './utils/constants';
|
|
195
195
|
export const
|
|
196
196
|
OverflowScrollContext: any,
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
|
@@ -46,13 +46,14 @@ export { default as useToggle } from './hooks/useToggleHook';
|
|
|
46
46
|
export { default as useArrowKeyNavigation } from './hooks/useArrowKeyNavigationHook';
|
|
47
47
|
export { default as useIndexOfLastVisibleChild } from './hooks/useIndexOfLastVisibleChildHook';
|
|
48
48
|
export { default as useIsVisible } from './hooks/useIsVisibleHook';
|
|
49
|
+
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
50
|
+
export { default as breakpoints } from './utils/breakpoints';
|
|
49
51
|
|
|
50
52
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
51
53
|
// Things that don't have types
|
|
52
54
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
53
55
|
export { default as asInput } from './asInput';
|
|
54
56
|
export { default as ActionRow } from './ActionRow';
|
|
55
|
-
export { default as Alert, ALERT_CLOSE_LABEL_TEXT } from './Alert';
|
|
56
57
|
export { default as Annotation } from './Annotation';
|
|
57
58
|
export { default as Avatar } from './Avatar';
|
|
58
59
|
export { default as AvatarButton } from './AvatarButton';
|
|
@@ -190,7 +191,6 @@ export { default as Stack } from './Stack';
|
|
|
190
191
|
export { default as ToggleButton, ToggleButtonGroup } from './ToggleButton';
|
|
191
192
|
export { default as Sticky } from './Sticky';
|
|
192
193
|
export { default as SelectableBox } from './SelectableBox';
|
|
193
|
-
export { default as breakpoints } from './utils/breakpoints';
|
|
194
194
|
export { default as Variant } from './utils/constants';
|
|
195
195
|
export {
|
|
196
196
|
OverflowScrollContext,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface BreakpointRange {
|
|
2
|
+
minWidth?: number;
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface Breakpoints {
|
|
7
|
+
extraSmall: BreakpointRange;
|
|
8
|
+
small: BreakpointRange;
|
|
9
|
+
medium: BreakpointRange;
|
|
10
|
+
large: BreakpointRange;
|
|
11
|
+
extraLarge: BreakpointRange;
|
|
12
|
+
extraExtraLarge: BreakpointRange;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Size: {
|
|
16
|
+
readonly xs: 'extraSmall';
|
|
17
|
+
readonly sm: 'small';
|
|
18
|
+
readonly md: 'medium';
|
|
19
|
+
readonly lg: 'large';
|
|
20
|
+
readonly xl: 'extraLarge';
|
|
21
|
+
readonly xxl: 'extraExtraLarge';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare const breakpoints: Breakpoints;
|
|
25
|
+
|
|
26
|
+
export default breakpoints;
|
|
File without changes
|