@openedx/paragon 23.10.0 → 23.11.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.
@@ -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;
@@ -1,16 +1,18 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
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/Alert';
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__*/React.forwardRef((_ref, ref) => {
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__*/React.cloneElement(Action, addtlActionProps);
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?.length > 0) && /*#__PURE__*/React.createElement(ActionRow, {
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
- const commonPropTypes = {
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;
@@ -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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,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,OAAOC,IAAI,MAAqB,SAAS;AACzC,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,MAAM,MAAM,WAAW;AAC9B;AACA,OAAOC,SAAS,MAAM,cAAc;A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CAACiE;EACvB,CAAC,CAAC,CACH,CAAsD;EACvD;EACAnD,QAAQ,EAAEd,SAAS,CAAC+D,IAAsC;EAC1D;EACAhD,IAAI,EAAEf,SAAS,CAACiE,IAAI;EACpB;EACAM,IAAI,EAAEvE,SAAS,CAAC2D,IAAI;EACpB;EACA1C,WAAW,EAAEjB,SAAS,CAAC2D,IAAI;EAC3B;EACAzC,OAAO,EAAElB,SAAS,CAACiE,IAAI;EACvB;EACAjD,OAAO,EAAEhB,SAAS,CAACwE,OAAO,CAACxE,SAAS,CAACyE,OAAO,CAA8C;EAC1F;EACArD,OAAO,EAAEpB,SAAS,CAAC2D,IAAI;EACvB;EACAxC,UAAU,EAAEnB,SAAS,CAAC0D,SAAS,CAAC,CAAC1D,SAAS,CAACsD,MAAM,EAAEtD,SAAS,CAACyE,OAAO,CAAC;AACvE,CAAC;AAEDvE,KAAK,CAACqD,YAAY,GAAG;EACnB,GAAGpD,SAAS,CAACoD,YAAY;EACzBzC,QAAQ,EAAE4D,SAAS;EACnB3D,IAAI,EAAE2D,SAAS;EACf1D,OAAO,EAAE0D,SAAS;EAClBzD,WAAW,EAAE,KAAK;EAClBC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,UAAU,EAAEuD,SAAS;EACrBH,IAAI,EAAE,IAAI;EACVnD,OAAO,EAAE,KAAK;EACdc,SAAS,EAAEwC,SAAS;EACpBrB,QAAQ,EAAEqB,SAAS;EACnBpC,OAAO,EAAEoC;AACX,CAAC;AAEDxE,KAAK,CAAC6C,OAAO,GAAGD,YAAY;AAC5B5C,KAAK,CAAC+C,IAAI,GAAGD,SAAS;AAEtB,eAAe9C,KAAK","ignoreList":[]}
@@ -60,7 +60,7 @@ declare namespace IconButtonWithTooltip {
60
60
  iconName?: string | undefined;
61
61
  icon?: any[] | undefined;
62
62
  } | undefined;
63
- variant?: "primary" | "success" | "warning" | "secondary" | "danger" | "dark" | "light" | "black" | "brand" | undefined;
63
+ variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "dark" | "light" | "black" | "brand" | undefined;
64
64
  size?: "sm" | "md" | "inline" | undefined;
65
65
  children?: undefined;
66
66
  defaultChecked?: boolean | undefined;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- export declare const MODAL_DIALOG_CLOSE_LABEL = "Close";
4
3
  interface Props {
5
4
  /** Specifies the content of the dialog */
6
5
  children: React.ReactNode;
@@ -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';
@@ -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
- export const MODAL_DIALOG_CLOSE_LABEL = 'Close';
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 = MODAL_DIALOG_CLOSE_LABEL,
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: closeLabel
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","MODAL_DIALOG_CLOSE_LABEL","ModalDialog","_ref","children","title","isOpen","onClose","size","variant","hasCloseButton","closeLabel","isFullscreenScroll","className","isFullscreenOnMobile","isBlocking","zIndex","isOverflowVisible","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 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';\n\nexport const MODAL_DIALOG_CLOSE_LABEL = 'Close';\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 = MODAL_DIALOG_CLOSE_LABEL,\n isFullscreenScroll = false,\n className,\n isFullscreenOnMobile = false,\n isBlocking = false,\n zIndex,\n isOverflowVisible,\n}: Props) {\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={closeLabel}\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 /**\n * Specifies whether overflow content inside the modal should be visible.\n * - `true` - content that exceeds the modal boundaries will remain visible outside the modal's main viewport,\n * rather than being clipped or hidden.\n * - `false` - any overflow content will be clipped to fit within the modal's dimensions.\n */\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,OAAOC,UAAU,MAAM,cAA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ACF;AACA;EACEnB,oBAAoB,EAAE1B,SAAS,CAAC6C,IAAI;EACpC;AACF;AACA;EACElB,UAAU,EAAE3B,SAAS,CAAC6C,IAAI;EAC1B;AACF;AACA;EACEjB,MAAM,EAAE5B,SAAS,CAAC+C,MAAM;EACxB;AACF;AACA;AACA;AACA;AACA;EACElB,iBAAiB,EAAE7B,SAAS,CAAC6C,IAAI,CAACH;AACpC,CAAC;AAED5B,WAAW,CAACkC,MAAM,GAAG3C,iBAAiB;AACtCS,WAAW,CAACmC,KAAK,GAAG3C,gBAAgB;AACpCQ,WAAW,CAACoC,MAAM,GAAG3C,iBAAiB;AACtCO,WAAW,CAACqC,WAAW,GAAG/C,gBAAgB;AAC1CU,WAAW,CAACsC,IAAI,GAAG5C,eAAe;AAClCM,WAAW,CAACuC,IAAI,GAAG5C,eAAe;AAElC,eAAeK,WAAW","ignoreList":[]}
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 /**\n * Specifies whether overflow content inside the modal should be visible.\n * - `true` - content that exceeds the modal boundaries will remain visible outside the modal's main viewport,\n * rather than being clipped or hidden.\n * - `false` - any overflow content will be clipped to fit within the modal's dimensions.\n */\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;AACrC;AACA,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD;AACA,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD;AACA,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD;AACA,OAAOC,eAAe,MAAM,mBAAmB;AAC/C;AACA,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,UAAU,MAAM,eAAe;AACtC,SAASC,KAAK,QAAQ,aAAa;AACnC,OAAOC,QAAQ,MAAM,YAAY;AAqCjC,SAASC,WAAWA,CAAAC,IAAA,EAeV;EAAA,IAfW;IACnBC,QAAQ;IACRC,KAAK;IACLC,MAAM,GAAG,KAAK;IACdC,OAAO;IACPC,IAAI,GAAG,IAAI;IACXC,OAAO,GAAG,SAAS;IACnBC,cAAc,GAAG,IAAI;IACrBC,UAAU;IACVC,kBAAkB,GAAG,KAAK;IAC1BC,SAAS;IACTC,oBAAoB,GAAG,KAAK;IAC5BC,UAAU,GAAG,KAAK;IACl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 @@
1
+ declare const messages: {
2
+ closeButtonText: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
8
+ export default messages;
@@ -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":[]}