@openedx/paragon 22.15.3 → 22.16.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,6 @@
1
+ import { ReactNode } from 'react';
2
+ interface ToastContainerProps {
3
+ children: ReactNode;
4
+ }
5
+ declare function ToastContainer({ children }: ToastContainerProps): import("react").ReactPortal | null;
6
+ export default ToastContainer;
@@ -1,34 +1,24 @@
1
- import React from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- import PropTypes from 'prop-types';
4
- class ToastContainer extends React.Component {
5
- constructor(props) {
6
- super(props);
7
- this.toastRootName = 'toast-root';
8
- if (typeof document === 'undefined') {
9
- this.rootElement = null;
10
- } else if (document.getElementById(this.toastRootName)) {
11
- this.rootElement = document.getElementById(this.toastRootName);
12
- } else {
13
- const rootElement = document.createElement('div');
14
- rootElement.setAttribute('id', this.toastRootName);
15
- rootElement.setAttribute('class', 'toast-container');
16
- rootElement.setAttribute('role', 'alert');
17
- rootElement.setAttribute('aria-live', 'polite');
18
- rootElement.setAttribute('aria-atomic', 'true');
19
- this.rootElement = document.body.appendChild(rootElement);
3
+ const TOAST_ROOT_ID = 'toast-root';
4
+ function ToastContainer(_ref) {
5
+ let {
6
+ children
7
+ } = _ref;
8
+ const [rootElement, setRootElement] = useState(null);
9
+ useEffect(() => {
10
+ if (typeof document !== 'undefined') {
11
+ let existingElement = document.getElementById(TOAST_ROOT_ID);
12
+ if (!existingElement) {
13
+ existingElement = document.createElement('div');
14
+ existingElement.id = TOAST_ROOT_ID;
15
+ existingElement.className = 'toast-container';
16
+ document.body.appendChild(existingElement);
17
+ }
18
+ setRootElement(existingElement);
20
19
  }
21
- }
22
- render() {
23
- if (this.rootElement) {
24
- return /*#__PURE__*/ReactDOM.createPortal(this.props.children, this.rootElement);
25
- }
26
- return null;
27
- }
20
+ }, []);
21
+ return rootElement ? /*#__PURE__*/ReactDOM.createPortal(children, rootElement) : null;
28
22
  }
29
- ToastContainer.propTypes = {
30
- /** Specifies contents of the component. */
31
- children: PropTypes.node.isRequired
32
- };
33
23
  export default ToastContainer;
34
24
  //# sourceMappingURL=ToastContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastContainer.js","names":["React","ReactDOM","PropTypes","ToastContainer","Component","constructor","props","toastRootName","document","rootElement","getElementById","createElement","setAttribute","body","appendChild","render","createPortal","children","propTypes","node","isRequired"],"sources":["../../src/Toast/ToastContainer.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\n\nclass ToastContainer extends React.Component {\n constructor(props) {\n super(props);\n this.toastRootName = 'toast-root';\n if (typeof document === 'undefined') {\n this.rootElement = null;\n } else if (document.getElementById(this.toastRootName)) {\n this.rootElement = document.getElementById(this.toastRootName);\n } else {\n const rootElement = document.createElement('div');\n rootElement.setAttribute('id', this.toastRootName);\n rootElement.setAttribute('class', 'toast-container');\n rootElement.setAttribute('role', 'alert');\n rootElement.setAttribute('aria-live', 'polite');\n rootElement.setAttribute('aria-atomic', 'true');\n this.rootElement = document.body.appendChild(rootElement);\n }\n }\n\n render() {\n if (this.rootElement) {\n return ReactDOM.createPortal(\n this.props.children,\n this.rootElement,\n );\n }\n return null;\n }\n}\n\nToastContainer.propTypes = {\n /** Specifies contents of the component. */\n children: PropTypes.node.isRequired,\n};\n\nexport default ToastContainer;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAOC,SAAS,MAAM,YAAY;AAElC,MAAMC,cAAc,SAASH,KAAK,CAACI,SAAS,CAAC;EAC3CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,aAAa,GAAG,YAAY;IACjC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;MACnC,IAAI,CAACC,WAAW,GAAG,IAAI;IACzB,CAAC,MAAM,IAAID,QAAQ,CAACE,cAAc,CAAC,IAAI,CAACH,aAAa,CAAC,EAAE;MACtD,IAAI,CAACE,WAAW,GAAGD,QAAQ,CAACE,cAAc,CAAC,IAAI,CAACH,aAAa,CAAC;IAChE,CAAC,MAAM;MACL,MAAME,WAAW,GAAGD,QAAQ,CAACG,aAAa,CAAC,KAAK,CAAC;MACjDF,WAAW,CAACG,YAAY,CAAC,IAAI,EAAE,IAAI,CAACL,aAAa,CAAC;MAClDE,WAAW,CAACG,YAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC;MACpDH,WAAW,CAACG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC;MACzCH,WAAW,CAACG,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;MAC/CH,WAAW,CAACG,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;MAC/C,IAAI,CAACH,WAAW,GAAGD,QAAQ,CAACK,IAAI,CAACC,WAAW,CAACL,WAAW,CAAC;IAC3D;EACF;EAEAM,MAAMA,CAAA,EAAG;IACP,IAAI,IAAI,CAACN,WAAW,EAAE;MACpB,oBAAOR,QAAQ,CAACe,YAAY,CAC1B,IAAI,CAACV,KAAK,CAACW,QAAQ,EACnB,IAAI,CAACR,WACP,CAAC;IACH;IACA,OAAO,IAAI;EACb;AACF;AAEAN,cAAc,CAACe,SAAS,GAAG;EACzB;EACAD,QAAQ,EAAEf,SAAS,CAACiB,IAAI,CAACC;AAC3B,CAAC;AAED,eAAejB,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"ToastContainer.js","names":["useEffect","useState","ReactDOM","TOAST_ROOT_ID","ToastContainer","_ref","children","rootElement","setRootElement","document","existingElement","getElementById","createElement","id","className","body","appendChild","createPortal"],"sources":["../../src/Toast/ToastContainer.tsx"],"sourcesContent":["import { ReactNode, useEffect, useState } from 'react';\nimport ReactDOM from 'react-dom';\n\ninterface ToastContainerProps {\n children: ReactNode;\n}\n\nconst TOAST_ROOT_ID = 'toast-root';\n\nfunction ToastContainer({ children }: ToastContainerProps) {\n const [rootElement, setRootElement] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (typeof document !== 'undefined') {\n let existingElement = document.getElementById(TOAST_ROOT_ID);\n\n if (!existingElement) {\n existingElement = document.createElement('div');\n existingElement.id = TOAST_ROOT_ID;\n existingElement.className = 'toast-container';\n document.body.appendChild(existingElement);\n }\n setRootElement(existingElement);\n }\n }, []);\n\n return rootElement ? ReactDOM.createPortal(children, rootElement) : null;\n}\n\nexport default ToastContainer;\n"],"mappings":"AAAA,SAAoBA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACtD,OAAOC,QAAQ,MAAM,WAAW;AAMhC,MAAMC,aAAa,GAAG,YAAY;AAElC,SAASC,cAAcA,CAAAC,IAAA,EAAoC;EAAA,IAAnC;IAAEC;EAA8B,CAAC,GAAAD,IAAA;EACvD,MAAM,CAACE,WAAW,EAAEC,cAAc,CAAC,GAAGP,QAAQ,CAAqB,IAAI,CAAC;EAExED,SAAS,CAAC,MAAM;IACd,IAAI,OAAOS,QAAQ,KAAK,WAAW,EAAE;MACnC,IAAIC,eAAe,GAAGD,QAAQ,CAACE,cAAc,CAACR,aAAa,CAAC;MAE5D,IAAI,CAACO,eAAe,EAAE;QACpBA,eAAe,GAAGD,QAAQ,CAACG,aAAa,CAAC,KAAK,CAAC;QAC/CF,eAAe,CAACG,EAAE,GAAGV,aAAa;QAClCO,eAAe,CAACI,SAAS,GAAG,iBAAiB;QAC7CL,QAAQ,CAACM,IAAI,CAACC,WAAW,CAACN,eAAe,CAAC;MAC5C;MACAF,cAAc,CAACE,eAAe,CAAC;IACjC;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,WAAW,gBAAGL,QAAQ,CAACe,YAAY,CAACX,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAI;AAC1E;AAEA,eAAeH,cAAc","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ @use "sass:map";
1
2
  @import "variables";
2
3
 
3
4
  .toast-container {
@@ -11,7 +12,7 @@
11
12
  left: 0;
12
13
  }
13
14
 
14
- @media only screen and (width <= 768px) {
15
+ @media (max-width: map.get($grid-breakpoints, "md")) {
15
16
  bottom: $toast-container-gutter-sm;
16
17
  right: $toast-container-gutter-sm;
17
18
  left: $toast-container-gutter-sm;
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export declare const TOAST_CLOSE_LABEL_TEXT = "Close";
4
+ export declare const TOAST_DELAY = 5000;
5
+ interface ToastAction {
6
+ label: string;
7
+ href?: string;
8
+ onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
9
+ }
10
+ interface ToastProps {
11
+ children: string;
12
+ onClose: () => void;
13
+ show: boolean;
14
+ action?: ToastAction;
15
+ closeLabel?: string;
16
+ delay?: number;
17
+ className?: string;
18
+ }
19
+ declare function Toast({ action, children, className, closeLabel, onClose, show, ...rest }: ToastProps): import("react/jsx-runtime").JSX.Element;
20
+ declare namespace Toast {
21
+ var defaultProps: {
22
+ action: null;
23
+ closeLabel: undefined;
24
+ delay: number;
25
+ className: undefined;
26
+ };
27
+ var propTypes: {
28
+ /** A string or an element that is rendered inside the main body of the `Toast`. */
29
+ children: PropTypes.Validator<string>;
30
+ /**
31
+ * A function that is called on close. It can be used to perform
32
+ * actions upon closing of the `Toast`, such as setting the "show"
33
+ * element to false.
34
+ * */
35
+ onClose: PropTypes.Validator<(...args: any[]) => any>;
36
+ /** Boolean used to control whether the `Toast` shows */
37
+ show: PropTypes.Validator<boolean>;
38
+ /**
39
+ * Fields used to build optional action button.
40
+ * `label` is a string rendered inside the button.
41
+ * `href` is a link that will render the action button as an anchor tag.
42
+ * `onClick` is a function that is called when the button is clicked.
43
+ */
44
+ action: PropTypes.Requireable<PropTypes.InferProps<{
45
+ label: PropTypes.Validator<string>;
46
+ href: PropTypes.Requireable<string>;
47
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
48
+ }>>;
49
+ /**
50
+ * Alt text for the `Toast`'s dismiss button. Defaults to 'Close'.
51
+ */
52
+ closeLabel: PropTypes.Requireable<string>;
53
+ /** Time in milliseconds for which the `Toast` will display. */
54
+ delay: PropTypes.Requireable<number>;
55
+ /** Class names for the `BaseToast` component */
56
+ className: PropTypes.Requireable<string>;
57
+ };
58
+ }
59
+ export default Toast;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useState","classNames","PropTypes","BaseToast","useIntl","Close","ToastContainer","Button","Icon","IconButton","TOAST_CLOSE_LABEL_TEXT","TOAST_DELAY","Toast","_ref","action","children","className","closeLabel","onClose","show","rest","intl","autoHide","setAutoHide","intlCloseLabel","formatMessage","id","defaultMessage","description","createElement","autohide","onBlur","onFocus","onMouseOut","onMouseOver","iconAs","alt","src","onClick","variant","invertColors","as","href","size","label","defaultProps","undefined","delay","propTypes","string","isRequired","func","bool","shape","number"],"sources":["../../src/Toast/index.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\nimport BaseToast from 'react-bootstrap/Toast';\nimport { useIntl } from 'react-intl';\n\nimport { Close } from '../../icons';\nimport ToastContainer from './ToastContainer';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\n\nexport const TOAST_CLOSE_LABEL_TEXT = 'Close';\nexport const TOAST_DELAY = 5000;\n\nfunction Toast({\n action, children, className, closeLabel, onClose, show, ...rest\n}) {\n const intl = useIntl();\n const [autoHide, setAutoHide] = useState(true);\n const intlCloseLabel = closeLabel || intl.formatMessage({\n id: 'pgn.Toast.closeLabel',\n defaultMessage: 'Close',\n description: 'Close label for Toast component',\n });\n return (\n <ToastContainer>\n <BaseToast\n autohide={autoHide}\n className={classNames('pgn__toast', className)}\n onClose={onClose}\n onBlur={() => setAutoHide(true)}\n onFocus={() => setAutoHide(false)}\n onMouseOut={() => setAutoHide(true)}\n onMouseOver={() => setAutoHide(false)}\n show={show}\n {...rest}\n >\n <div\n className=\"toast-header\"\n >\n <p className=\"small\">{children}</p>\n <div className=\"toast-header-btn-container\">\n <IconButton\n iconAs={Icon}\n alt={intlCloseLabel}\n className=\"align-self-start\"\n src={Close}\n onClick={onClose}\n variant=\"primary\"\n invertColors\n />\n </div>\n </div>\n {action && (\n <Button\n as={action.href ? 'a' : 'button'}\n href={action.href}\n onClick={action.onClick}\n size=\"sm\"\n variant=\"inverse-outline-primary\"\n >\n {action.label}\n </Button>\n )}\n </BaseToast>\n </ToastContainer>\n );\n}\n\nToast.defaultProps = {\n action: null,\n closeLabel: undefined,\n delay: TOAST_DELAY,\n className: undefined,\n};\n\nToast.propTypes = {\n /** A string or an element that is rendered inside the main body of the `Toast`. */\n children: PropTypes.string.isRequired,\n /**\n * A function that is called on close. It can be used to perform\n * actions upon closing of the `Toast`, such as setting the \"show\"\n * element to false.\n * */\n onClose: PropTypes.func.isRequired,\n /** Boolean used to control whether the `Toast` shows */\n show: PropTypes.bool.isRequired,\n /**\n * Fields used to build optional action button.\n * `label` is a string rendered inside the button.\n * `href` is a link that will render the action button as an anchor tag.\n * `onClick` is a function that is called when the button is clicked.\n */\n action: PropTypes.shape({\n label: PropTypes.string.isRequired,\n href: PropTypes.string,\n onClick: PropTypes.func,\n }),\n /**\n * Alt text for the `Toast`'s dismiss button. Defaults to 'Close'.\n */\n closeLabel: PropTypes.string,\n /** Time in milliseconds for which the `Toast` will display. */\n delay: PropTypes.number,\n /** Class names for the `BaseToast` component */\n className: PropTypes.string,\n};\n\nexport default Toast;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,SAASC,OAAO,QAAQ,YAAY;AAEpC,SAASC,KAAK,QAAQ,aAAa;AACnC,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,IA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AF,KAAK,EAAE7C,SAAS,CAACoD,MAAM;EACvB;EACAtC,SAAS,EAAEd,SAAS,CAAC+C;AACvB,CAAC;AAED,eAAerC,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useState","classNames","PropTypes","BaseToast","useIntl","Close","ToastContainer","Button","Icon","IconButton","TOAST_CLOSE_LABEL_TEXT","TOAST_DELAY","Toast","_ref","action","children","className","closeLabel","onClose","show","rest","intl","autoHide","setAutoHide","intlCloseLabel","formatMessage","id","defaultMessage","description","createElement","autohide","onBlur","onFocus","onMouseOut","onMouseOver","iconAs","alt","src","onClick","variant","invertColors","as","href","size","label","defaultProps","undefined","delay","propTypes","string","isRequired","func","bool","shape","number"],"sources":["../../src/Toast/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport BaseToast from 'react-bootstrap/Toast';\nimport { useIntl } from 'react-intl';\n\nimport { Close } from '../../icons';\nimport ToastContainer from './ToastContainer';\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\n\nexport const TOAST_CLOSE_LABEL_TEXT = 'Close';\nexport const TOAST_DELAY = 5000;\n\ninterface ToastAction {\n label: string;\n href?: string;\n onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;\n}\n\ninterface ToastProps {\n children: string;\n onClose: () => void;\n show: boolean;\n action?: ToastAction;\n closeLabel?: string;\n delay?: number;\n className?: string;\n}\n\nfunction Toast({\n action,\n children,\n className,\n closeLabel,\n onClose,\n show,\n ...rest\n}: ToastProps) {\n const intl = useIntl();\n const [autoHide, setAutoHide] = useState(true);\n\n const intlCloseLabel = closeLabel || intl.formatMessage({\n id: 'pgn.Toast.closeLabel',\n defaultMessage: 'Close',\n description: 'Close label for Toast component',\n });\n\n return (\n <ToastContainer>\n <BaseToast\n autohide={autoHide}\n className={classNames('pgn__toast', className)}\n onClose={onClose}\n onBlur={() => setAutoHide(true)}\n onFocus={() => setAutoHide(false)}\n onMouseOut={() => setAutoHide(true)}\n onMouseOver={() => setAutoHide(false)}\n show={show}\n {...rest}\n >\n <div className=\"toast-header\">\n <p className=\"small\">{children}</p>\n <div className=\"toast-header-btn-container\">\n <IconButton\n iconAs={Icon}\n alt={intlCloseLabel}\n className=\"align-self-start\"\n src={Close}\n onClick={onClose}\n variant=\"primary\"\n invertColors\n />\n </div>\n </div>\n {action && (\n <Button\n as={action.href ? 'a' : 'button'}\n href={action.href}\n onClick={action.onClick}\n size=\"sm\"\n variant=\"inverse-outline-primary\"\n >\n {action.label}\n </Button>\n )}\n </BaseToast>\n </ToastContainer>\n );\n}\n\nToast.defaultProps = {\n action: null,\n closeLabel: undefined,\n delay: TOAST_DELAY,\n className: undefined,\n};\n\nToast.propTypes = {\n /** A string or an element that is rendered inside the main body of the `Toast`. */\n children: PropTypes.string.isRequired,\n /**\n * A function that is called on close. It can be used to perform\n * actions upon closing of the `Toast`, such as setting the \"show\"\n * element to false.\n * */\n onClose: PropTypes.func.isRequired,\n /** Boolean used to control whether the `Toast` shows */\n show: PropTypes.bool.isRequired,\n /**\n * Fields used to build optional action button.\n * `label` is a string rendered inside the button.\n * `href` is a link that will render the action button as an anchor tag.\n * `onClick` is a function that is called when the button is clicked.\n */\n action: PropTypes.shape({\n label: PropTypes.string.isRequired,\n href: PropTypes.string,\n onClick: PropTypes.func,\n }),\n /**\n * Alt text for the `Toast`'s dismiss button. Defaults to 'Close'.\n */\n closeLabel: PropTypes.string,\n /** Time in milliseconds for which the `Toast` will display. */\n delay: PropTypes.number,\n /** Class names for the `BaseToast` component */\n className: PropTypes.string,\n};\n\nexport default Toast;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,SAASC,OAAO,QAAQ,YAAY;AAEpC,SAASC,KAAK,QAA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AACiD;EACrB,CAAC,CAAC;EACF;AACF;AACA;EACElC,UAAU,EAAEf,SAAS,CAAC+C,MAAM;EAC5B;EACAF,KAAK,EAAE7C,SAAS,CAACoD,MAAM;EACvB;EACAtC,SAAS,EAAEd,SAAS,CAAC+C;AACvB,CAAC;AAED,eAAerC,KAAK","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ @use "sass:map";
1
2
  @import "variables";
2
3
  @import "~bootstrap/scss/toasts";
3
4
 
@@ -5,7 +6,7 @@
5
6
  background-color: $toast-background-color;
6
7
  box-shadow: $toast-box-shadow;
7
8
  margin: 0;
8
- padding: 1rem;
9
+ padding: $spacer;
9
10
  position: relative;
10
11
  border-radius: $toast-border-radius;
11
12
  z-index: 2;
@@ -38,15 +39,15 @@
38
39
  }
39
40
 
40
41
  & + .btn {
41
- margin-top: 1rem;
42
+ margin-top: $spacer;
42
43
  }
43
44
  }
44
45
 
45
- @media only screen and (width <= 768px) {
46
+ @media (max-width: map.get($grid-breakpoints, "md")) {
46
47
  max-width: 100%;
47
48
  }
48
49
 
49
- @media only screen and (width >= 768px) {
50
+ @media (min-width: map.get($grid-breakpoints, "md")) {
50
51
  min-width: $toast-max-width;
51
52
  max-width: $toast-max-width;
52
53
  }
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export { default as ModalDialog, MODAL_DIALOG_CLOSE_LABEL } from './Modal/ModalD
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';
42
+ export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
42
43
  export { default as Tooltip } from './Tooltip';
43
44
  export { default as useWindowSize, type WindowSizeData } from './hooks/useWindowSizeHook';
44
45
  export { default as useToggle, type Toggler, type ToggleHandlers } from './hooks/useToggleHook';
@@ -163,7 +164,6 @@ export const
163
164
  // from './Tabs';
164
165
  /** @deprecated Replaced by `Form.Control`. */
165
166
  export const TextArea: any; // from './TextArea';
166
- export const Toast: any, TOAST_CLOSE_LABEL_TEXT: string, TOAST_DELAY: number; // from './Toast';
167
167
  /** @deprecated Replaced by `Form.Group`. */
168
168
  export const ValidationFormGroup: any; // from './ValidationFormGroup';
169
169
  export const TransitionReplace: any; // from './TransitionReplace';
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ export { default as ModalDialog, MODAL_DIALOG_CLOSE_LABEL } from './Modal/ModalD
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';
42
+ export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
42
43
  export { default as Tooltip } from './Tooltip';
43
44
  export { default as useWindowSize } from './hooks/useWindowSizeHook';
44
45
  export { default as useToggle } from './hooks/useToggleHook';
@@ -163,7 +164,6 @@ export {
163
164
  } from './Tabs';
164
165
  /** @deprecated Replaced by `Form.Control`. */
165
166
  export { default as TextArea } from './TextArea';
166
- export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
167
167
  /** @deprecated Replaced by `Form.Group`. */
168
168
  export { default as ValidationFormGroup } from './ValidationFormGroup';
169
169
  export { default as TransitionReplace } from './TransitionReplace';