carbon-react 109.5.2 → 109.6.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.
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ModalProps } from "../modal/modal";
2
+ import { ModalProps } from "../modal";
3
3
 
4
4
  type PaddingValues = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ModalProps } from "../modal/modal";
2
+ import { ModalProps } from "../modal";
3
3
 
4
4
  export interface DialogFullScreenProps extends ModalProps {
5
5
  /** Prop to specify the aria-describedby property of the DialogFullscreen component */
@@ -1,9 +1,22 @@
1
- export default ModalManager;
2
- export class ModalManagerInstance {
3
- addModal: (modal: any, setTriggerRefocusFlag: any) => void;
4
- isTopmost(modal: any): boolean;
5
- removeModal(modal: any): void;
1
+ declare type SetTriggerRefocusFlag = (boolean: boolean) => void;
2
+ declare type ModalList = {
3
+ modal: HTMLElement;
4
+ setTriggerRefocusFlag?: SetTriggerRefocusFlag;
5
+ }[];
6
+ declare global {
7
+ interface Window {
8
+ __CARBON_INTERNALS_MODAL_LIST?: ModalList;
9
+ }
10
+ }
11
+ declare class ModalManagerInstance {
12
+ private modalList;
13
+ constructor();
14
+ private getTopModal;
15
+ addModal: (modal: HTMLElement | null, setTriggerRefocusFlag?: SetTriggerRefocusFlag | undefined) => void;
16
+ isTopmost(modal: HTMLElement | null): boolean;
17
+ removeModal(modal: HTMLElement | null): void;
6
18
  clearList(): void;
7
- #private;
8
19
  }
9
20
  declare const ModalManager: ModalManagerInstance;
21
+ export { ModalManagerInstance };
22
+ export default ModalManager;
@@ -6,44 +6,27 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
6
6
 
7
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
8
 
9
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
10
-
11
- function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
12
-
13
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
14
-
15
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
16
-
17
- function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
18
-
19
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
20
-
21
- var _modalList = /*#__PURE__*/new WeakMap();
22
-
23
- var _getTopModal = /*#__PURE__*/new WeakSet();
24
-
25
9
  let ModalManagerInstance = /*#__PURE__*/function () {
26
10
  function ModalManagerInstance() {
27
11
  _classCallCheck(this, ModalManagerInstance);
28
12
 
29
- _getTopModal.add(this);
30
-
31
- _modalList.set(this, {
32
- writable: true,
33
- value: void 0
34
- });
13
+ _defineProperty(this, "modalList", void 0);
35
14
 
36
15
  _defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
16
+ if (!modal) {
17
+ return;
18
+ }
19
+
37
20
  const {
38
21
  modal: topModal,
39
22
  setTriggerRefocusFlag: setTrapFlag
40
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
23
+ } = this.getTopModal();
41
24
 
42
25
  if (topModal && setTrapFlag) {
43
26
  setTrapFlag(false);
44
27
  }
45
28
 
46
- _classPrivateFieldGet(this, _modalList).push({
29
+ this.modalList.push({
47
30
  modal,
48
31
  setTriggerRefocusFlag
49
32
  });
@@ -55,15 +38,24 @@ let ModalManagerInstance = /*#__PURE__*/function () {
55
38
  window.__CARBON_INTERNALS_MODAL_LIST = [];
56
39
  }
57
40
 
58
- _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
41
+ this.modalList = window.__CARBON_INTERNALS_MODAL_LIST;
59
42
  }
60
43
 
61
44
  _createClass(ModalManagerInstance, [{
45
+ key: "getTopModal",
46
+ value: function getTopModal() {
47
+ if (!this.modalList.length) {
48
+ return {};
49
+ }
50
+
51
+ return this.modalList[this.modalList.length - 1];
52
+ }
53
+ }, {
62
54
  key: "isTopmost",
63
55
  value: function isTopmost(modal) {
64
56
  const {
65
57
  modal: topModal
66
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
58
+ } = this.getTopModal();
67
59
 
68
60
  if (!modal || !topModal) {
69
61
  return false;
@@ -74,7 +66,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
74
66
  }, {
75
67
  key: "removeModal",
76
68
  value: function removeModal(modal) {
77
- const modalIndex = _classPrivateFieldGet(this, _modalList).findIndex(({
69
+ const modalIndex = this.modalList.findIndex(({
78
70
  modal: m
79
71
  }) => m === modal);
80
72
 
@@ -82,15 +74,15 @@ let ModalManagerInstance = /*#__PURE__*/function () {
82
74
  return;
83
75
  }
84
76
 
85
- _classPrivateFieldGet(this, _modalList).splice(modalIndex, 1);
77
+ this.modalList.splice(modalIndex, 1);
86
78
 
87
- if (!_classPrivateFieldGet(this, _modalList).length) {
79
+ if (!this.modalList.length) {
88
80
  return;
89
81
  }
90
82
 
91
83
  const {
92
84
  setTriggerRefocusFlag
93
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
85
+ } = this.getTopModal();
94
86
 
95
87
  if (setTriggerRefocusFlag) {
96
88
  setTriggerRefocusFlag(true);
@@ -100,22 +92,13 @@ let ModalManagerInstance = /*#__PURE__*/function () {
100
92
  key: "clearList",
101
93
  value: function clearList() {
102
94
  window.__CARBON_INTERNALS_MODAL_LIST = [];
103
-
104
- _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
95
+ this.modalList = window.__CARBON_INTERNALS_MODAL_LIST;
105
96
  }
106
97
  }]);
107
98
 
108
99
  return ModalManagerInstance;
109
100
  }();
110
101
 
111
- function _getTopModal2() {
112
- if (!_classPrivateFieldGet(this, _modalList).length) {
113
- return {};
114
- }
115
-
116
- return _classPrivateFieldGet(this, _modalList)[_classPrivateFieldGet(this, _modalList).length - 1];
117
- }
118
-
119
102
  const ModalManager = new ModalManagerInstance();
120
103
  export { ModalManagerInstance };
121
104
  export default ModalManager;
@@ -1 +1,2 @@
1
1
  export { default, ModalContext } from "./modal.component";
2
+ export type { ModalProps, ModalContextProps } from "./modal.component";
@@ -1,35 +1,46 @@
1
- export const ModalContext: React.Context<{}>;
2
- export default Modal;
3
1
  import React from "react";
4
- declare function Modal({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, ...rest }: {
5
- [x: string]: any;
6
- children: any;
7
- open: any;
8
- onCancel: any;
9
- disableEscKey: any;
10
- disableClose: any;
11
- enableBackgroundUI: any;
12
- timeout: any;
13
- }): JSX.Element;
14
- declare namespace Modal {
15
- namespace propTypes {
16
- const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
- const onCancel: PropTypes.Requireable<(...args: any[]) => any>;
18
- const open: PropTypes.Validator<boolean>;
19
- const enableBackgroundUI: PropTypes.Requireable<boolean>;
20
- const disableEscKey: PropTypes.Requireable<boolean>;
21
- const disableClose: PropTypes.Requireable<boolean>;
22
- const timeout: PropTypes.Requireable<number>;
23
- }
24
- namespace defaultProps {
25
- const onCancel_1: null;
26
- export { onCancel_1 as onCancel };
27
- const enableBackgroundUI_1: boolean;
28
- export { enableBackgroundUI_1 as enableBackgroundUI };
29
- const disableEscKey_1: boolean;
30
- export { disableEscKey_1 as disableEscKey };
31
- const timeout_1: number;
32
- export { timeout_1 as timeout };
33
- }
34
- }
35
2
  import PropTypes from "prop-types";
3
+ export interface ModalContextProps {
4
+ isInModal?: boolean;
5
+ isAnimationComplete?: boolean;
6
+ triggerRefocusFlag?: boolean;
7
+ }
8
+ export declare const ModalContext: React.Context<ModalContextProps>;
9
+ export interface ModalProps {
10
+ /** Modal content */
11
+ children?: React.ReactNode;
12
+ /** The ARIA role to be applied to the modal */
13
+ ariaRole?: string;
14
+ /** Determines if the Esc Key closes the modal */
15
+ disableEscKey?: boolean;
16
+ /** Determines if the Dialog can be closed */
17
+ disableClose?: boolean;
18
+ /** Determines if the background is disabled when the modal is open */
19
+ enableBackgroundUI?: boolean;
20
+ /** A custom close event handler */
21
+ onCancel?: (ev: React.KeyboardEvent<HTMLElement>) => void;
22
+ /** Sets the open state of the modal */
23
+ open: boolean;
24
+ /** Transition time */
25
+ timeout?: number;
26
+ }
27
+ declare const Modal: {
28
+ ({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, ...rest }: ModalProps): JSX.Element;
29
+ propTypes: {
30
+ /** Modal content */
31
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
32
+ /** A custom close event handler */
33
+ onCancel: PropTypes.Requireable<(...args: any[]) => any>;
34
+ /** Controls the open state of the modal */
35
+ open: PropTypes.Validator<boolean>;
36
+ /** Determines if the background is disabled when the modal is open */
37
+ enableBackgroundUI: PropTypes.Requireable<boolean>;
38
+ /** Determines if the Esc Key closes the modal */
39
+ disableEscKey: PropTypes.Requireable<boolean>;
40
+ /** Determines if the Dialog can be closed */
41
+ disableClose: PropTypes.Requireable<boolean>;
42
+ /** Transition time */
43
+ timeout: PropTypes.Requireable<number>;
44
+ };
45
+ };
46
+ export default Modal;
@@ -2,6 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useEffect, useRef, useCallback, useState } from "react";
4
4
  import PropTypes from "prop-types";
5
+ import PropTypes from "prop-types";
5
6
  import { TransitionGroup, CSSTransition } from "react-transition-group";
6
7
  import useScrollBlock from "../../hooks/__internal__/useScrollBlock";
7
8
  import Portal from "../portal";
@@ -14,15 +15,15 @@ const Modal = ({
14
15
  children,
15
16
  open,
16
17
  onCancel,
17
- disableEscKey,
18
+ disableEscKey = false,
18
19
  disableClose,
19
- enableBackgroundUI,
20
- timeout,
20
+ enableBackgroundUI = false,
21
+ timeout = 300,
21
22
  ...rest
22
23
  }) => {
23
- const ref = useRef();
24
- const backgroundNodeRef = useRef();
25
- const contentNodeRef = useRef();
24
+ const ref = useRef(null);
25
+ const backgroundNodeRef = useRef(null);
26
+ const contentNodeRef = useRef(null);
26
27
  const [isAnimationComplete, setAnimationComplete] = useState(false);
27
28
  const [triggerRefocusFlag, setTriggerRefocusFlag] = useState(false);
28
29
  const {
@@ -90,9 +91,10 @@ const Modal = ({
90
91
  isAnimationComplete,
91
92
  triggerRefocusFlag,
92
93
  isInModal: true
93
- },
94
+ }
95
+ }, /*#__PURE__*/React.createElement("div", {
94
96
  ref: contentNodeRef
95
- }, content)))));
97
+ }, content))))));
96
98
  };
97
99
 
98
100
  Modal.propTypes = {
@@ -117,10 +119,4 @@ Modal.propTypes = {
117
119
  /** Transition time */
118
120
  timeout: PropTypes.number
119
121
  };
120
- Modal.defaultProps = {
121
- onCancel: null,
122
- enableBackgroundUI: false,
123
- disableEscKey: false,
124
- timeout: 300
125
- };
126
122
  export default Modal;
@@ -1,2 +1,7 @@
1
- export const StyledModal: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledModalBackground: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ declare type TransitionProps = {
2
+ transitionName: string;
3
+ transitionTime: number;
4
+ };
5
+ declare const StyledModalBackground: import("styled-components").StyledComponent<"div", any, TransitionProps, never>;
6
+ declare const StyledModal: import("styled-components").StyledComponent<"div", any, TransitionProps, never>;
7
+ export { StyledModal, StyledModalBackground };
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ModalProps } from "../modal/modal";
2
+ import { ModalProps } from "../modal";
3
3
 
4
4
  type PaddingValues = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ModalProps } from "../modal/modal";
2
+ import { ModalProps } from "../modal";
3
3
 
4
4
  export interface DialogFullScreenProps extends ModalProps {
5
5
  /** Prop to specify the aria-describedby property of the DialogFullscreen component */
@@ -1,9 +1,22 @@
1
- export default ModalManager;
2
- export class ModalManagerInstance {
3
- addModal: (modal: any, setTriggerRefocusFlag: any) => void;
4
- isTopmost(modal: any): boolean;
5
- removeModal(modal: any): void;
1
+ declare type SetTriggerRefocusFlag = (boolean: boolean) => void;
2
+ declare type ModalList = {
3
+ modal: HTMLElement;
4
+ setTriggerRefocusFlag?: SetTriggerRefocusFlag;
5
+ }[];
6
+ declare global {
7
+ interface Window {
8
+ __CARBON_INTERNALS_MODAL_LIST?: ModalList;
9
+ }
10
+ }
11
+ declare class ModalManagerInstance {
12
+ private modalList;
13
+ constructor();
14
+ private getTopModal;
15
+ addModal: (modal: HTMLElement | null, setTriggerRefocusFlag?: SetTriggerRefocusFlag | undefined) => void;
16
+ isTopmost(modal: HTMLElement | null): boolean;
17
+ removeModal(modal: HTMLElement | null): void;
6
18
  clearList(): void;
7
- #private;
8
19
  }
9
20
  declare const ModalManager: ModalManagerInstance;
21
+ export { ModalManagerInstance };
22
+ export default ModalManager;
@@ -13,44 +13,27 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
13
13
 
14
14
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
15
 
16
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
17
-
18
- function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
19
-
20
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
21
-
22
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
23
-
24
- function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
25
-
26
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
27
-
28
- var _modalList = /*#__PURE__*/new WeakMap();
29
-
30
- var _getTopModal = /*#__PURE__*/new WeakSet();
31
-
32
16
  let ModalManagerInstance = /*#__PURE__*/function () {
33
17
  function ModalManagerInstance() {
34
18
  _classCallCheck(this, ModalManagerInstance);
35
19
 
36
- _getTopModal.add(this);
37
-
38
- _modalList.set(this, {
39
- writable: true,
40
- value: void 0
41
- });
20
+ _defineProperty(this, "modalList", void 0);
42
21
 
43
22
  _defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
23
+ if (!modal) {
24
+ return;
25
+ }
26
+
44
27
  const {
45
28
  modal: topModal,
46
29
  setTriggerRefocusFlag: setTrapFlag
47
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
30
+ } = this.getTopModal();
48
31
 
49
32
  if (topModal && setTrapFlag) {
50
33
  setTrapFlag(false);
51
34
  }
52
35
 
53
- _classPrivateFieldGet(this, _modalList).push({
36
+ this.modalList.push({
54
37
  modal,
55
38
  setTriggerRefocusFlag
56
39
  });
@@ -62,15 +45,24 @@ let ModalManagerInstance = /*#__PURE__*/function () {
62
45
  window.__CARBON_INTERNALS_MODAL_LIST = [];
63
46
  }
64
47
 
65
- _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
48
+ this.modalList = window.__CARBON_INTERNALS_MODAL_LIST;
66
49
  }
67
50
 
68
51
  _createClass(ModalManagerInstance, [{
52
+ key: "getTopModal",
53
+ value: function getTopModal() {
54
+ if (!this.modalList.length) {
55
+ return {};
56
+ }
57
+
58
+ return this.modalList[this.modalList.length - 1];
59
+ }
60
+ }, {
69
61
  key: "isTopmost",
70
62
  value: function isTopmost(modal) {
71
63
  const {
72
64
  modal: topModal
73
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
65
+ } = this.getTopModal();
74
66
 
75
67
  if (!modal || !topModal) {
76
68
  return false;
@@ -81,7 +73,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
81
73
  }, {
82
74
  key: "removeModal",
83
75
  value: function removeModal(modal) {
84
- const modalIndex = _classPrivateFieldGet(this, _modalList).findIndex(({
76
+ const modalIndex = this.modalList.findIndex(({
85
77
  modal: m
86
78
  }) => m === modal);
87
79
 
@@ -89,15 +81,15 @@ let ModalManagerInstance = /*#__PURE__*/function () {
89
81
  return;
90
82
  }
91
83
 
92
- _classPrivateFieldGet(this, _modalList).splice(modalIndex, 1);
84
+ this.modalList.splice(modalIndex, 1);
93
85
 
94
- if (!_classPrivateFieldGet(this, _modalList).length) {
86
+ if (!this.modalList.length) {
95
87
  return;
96
88
  }
97
89
 
98
90
  const {
99
91
  setTriggerRefocusFlag
100
- } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
92
+ } = this.getTopModal();
101
93
 
102
94
  if (setTriggerRefocusFlag) {
103
95
  setTriggerRefocusFlag(true);
@@ -107,8 +99,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
107
99
  key: "clearList",
108
100
  value: function clearList() {
109
101
  window.__CARBON_INTERNALS_MODAL_LIST = [];
110
-
111
- _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
102
+ this.modalList = window.__CARBON_INTERNALS_MODAL_LIST;
112
103
  }
113
104
  }]);
114
105
 
@@ -116,15 +107,6 @@ let ModalManagerInstance = /*#__PURE__*/function () {
116
107
  }();
117
108
 
118
109
  exports.ModalManagerInstance = ModalManagerInstance;
119
-
120
- function _getTopModal2() {
121
- if (!_classPrivateFieldGet(this, _modalList).length) {
122
- return {};
123
- }
124
-
125
- return _classPrivateFieldGet(this, _modalList)[_classPrivateFieldGet(this, _modalList).length - 1];
126
- }
127
-
128
110
  const ModalManager = new ModalManagerInstance();
129
111
  var _default = ModalManager;
130
112
  exports.default = _default;
@@ -1 +1,2 @@
1
1
  export { default, ModalContext } from "./modal.component";
2
+ export type { ModalProps, ModalContextProps } from "./modal.component";
@@ -1,35 +1,46 @@
1
- export const ModalContext: React.Context<{}>;
2
- export default Modal;
3
1
  import React from "react";
4
- declare function Modal({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, ...rest }: {
5
- [x: string]: any;
6
- children: any;
7
- open: any;
8
- onCancel: any;
9
- disableEscKey: any;
10
- disableClose: any;
11
- enableBackgroundUI: any;
12
- timeout: any;
13
- }): JSX.Element;
14
- declare namespace Modal {
15
- namespace propTypes {
16
- const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
- const onCancel: PropTypes.Requireable<(...args: any[]) => any>;
18
- const open: PropTypes.Validator<boolean>;
19
- const enableBackgroundUI: PropTypes.Requireable<boolean>;
20
- const disableEscKey: PropTypes.Requireable<boolean>;
21
- const disableClose: PropTypes.Requireable<boolean>;
22
- const timeout: PropTypes.Requireable<number>;
23
- }
24
- namespace defaultProps {
25
- const onCancel_1: null;
26
- export { onCancel_1 as onCancel };
27
- const enableBackgroundUI_1: boolean;
28
- export { enableBackgroundUI_1 as enableBackgroundUI };
29
- const disableEscKey_1: boolean;
30
- export { disableEscKey_1 as disableEscKey };
31
- const timeout_1: number;
32
- export { timeout_1 as timeout };
33
- }
34
- }
35
2
  import PropTypes from "prop-types";
3
+ export interface ModalContextProps {
4
+ isInModal?: boolean;
5
+ isAnimationComplete?: boolean;
6
+ triggerRefocusFlag?: boolean;
7
+ }
8
+ export declare const ModalContext: React.Context<ModalContextProps>;
9
+ export interface ModalProps {
10
+ /** Modal content */
11
+ children?: React.ReactNode;
12
+ /** The ARIA role to be applied to the modal */
13
+ ariaRole?: string;
14
+ /** Determines if the Esc Key closes the modal */
15
+ disableEscKey?: boolean;
16
+ /** Determines if the Dialog can be closed */
17
+ disableClose?: boolean;
18
+ /** Determines if the background is disabled when the modal is open */
19
+ enableBackgroundUI?: boolean;
20
+ /** A custom close event handler */
21
+ onCancel?: (ev: React.KeyboardEvent<HTMLElement>) => void;
22
+ /** Sets the open state of the modal */
23
+ open: boolean;
24
+ /** Transition time */
25
+ timeout?: number;
26
+ }
27
+ declare const Modal: {
28
+ ({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, ...rest }: ModalProps): JSX.Element;
29
+ propTypes: {
30
+ /** Modal content */
31
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
32
+ /** A custom close event handler */
33
+ onCancel: PropTypes.Requireable<(...args: any[]) => any>;
34
+ /** Controls the open state of the modal */
35
+ open: PropTypes.Validator<boolean>;
36
+ /** Determines if the background is disabled when the modal is open */
37
+ enableBackgroundUI: PropTypes.Requireable<boolean>;
38
+ /** Determines if the Esc Key closes the modal */
39
+ disableEscKey: PropTypes.Requireable<boolean>;
40
+ /** Determines if the Dialog can be closed */
41
+ disableClose: PropTypes.Requireable<boolean>;
42
+ /** Transition time */
43
+ timeout: PropTypes.Requireable<number>;
44
+ };
45
+ };
46
+ export default Modal;
@@ -37,15 +37,15 @@ const Modal = ({
37
37
  children,
38
38
  open,
39
39
  onCancel,
40
- disableEscKey,
40
+ disableEscKey = false,
41
41
  disableClose,
42
- enableBackgroundUI,
43
- timeout,
42
+ enableBackgroundUI = false,
43
+ timeout = 300,
44
44
  ...rest
45
45
  }) => {
46
- const ref = (0, _react.useRef)();
47
- const backgroundNodeRef = (0, _react.useRef)();
48
- const contentNodeRef = (0, _react.useRef)();
46
+ const ref = (0, _react.useRef)(null);
47
+ const backgroundNodeRef = (0, _react.useRef)(null);
48
+ const contentNodeRef = (0, _react.useRef)(null);
49
49
  const [isAnimationComplete, setAnimationComplete] = (0, _react.useState)(false);
50
50
  const [triggerRefocusFlag, setTriggerRefocusFlag] = (0, _react.useState)(false);
51
51
  const {
@@ -113,9 +113,10 @@ const Modal = ({
113
113
  isAnimationComplete,
114
114
  triggerRefocusFlag,
115
115
  isInModal: true
116
- },
116
+ }
117
+ }, /*#__PURE__*/_react.default.createElement("div", {
117
118
  ref: contentNodeRef
118
- }, content)))));
119
+ }, content))))));
119
120
  };
120
121
 
121
122
  Modal.propTypes = {
@@ -140,11 +141,5 @@ Modal.propTypes = {
140
141
  /** Transition time */
141
142
  timeout: _propTypes.default.number
142
143
  };
143
- Modal.defaultProps = {
144
- onCancel: null,
145
- enableBackgroundUI: false,
146
- disableEscKey: false,
147
- timeout: 300
148
- };
149
144
  var _default = Modal;
150
145
  exports.default = _default;
@@ -1,2 +1,7 @@
1
- export const StyledModal: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledModalBackground: import("styled-components").StyledComponent<"div", any, {}, never>;
1
+ declare type TransitionProps = {
2
+ transitionName: string;
3
+ transitionTime: number;
4
+ };
5
+ declare const StyledModalBackground: import("styled-components").StyledComponent<"div", any, TransitionProps, never>;
6
+ declare const StyledModal: import("styled-components").StyledComponent<"div", any, TransitionProps, never>;
7
+ export { StyledModal, StyledModalBackground };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "109.5.2",
3
+ "version": "109.6.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -98,7 +98,7 @@
98
98
  "@types/react-dom": "^17.0.2",
99
99
  "@types/react-is": "^17.0.3",
100
100
  "@types/react-test-renderer": "^17.0.1",
101
- "@types/react-transition-group": "^4.4.4",
101
+ "@types/react-transition-group": "^4.4.5",
102
102
  "@types/sprintf-js": "^1.1.2",
103
103
  "@types/styled-components": "^5.1.9",
104
104
  "@types/uuid": "^8.3.3",
@@ -192,7 +192,7 @@
192
192
  "react-dnd": "^15.1.1",
193
193
  "react-dnd-html5-backend": "^15.1.2",
194
194
  "react-is": "^17.0.2",
195
- "react-transition-group": "^4.4.1",
195
+ "react-transition-group": "^4.4.2",
196
196
  "styled-system": "^5.1.5",
197
197
  "wait-on": "^5.2.1"
198
198
  },
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface ModalContextProps {
4
- value?: {
5
- isInModal?: boolean;
6
- isAnimationComplete?: boolean;
7
- triggerRefocusFlag?: boolean;
8
- };
9
- ref?: React.MutableRefObject<React.ReactNode>;
10
- }
11
-
12
- export interface ModalProps {
13
- /** Modal content */
14
- children?: React.ReactNode;
15
- /** The ARIA role to be applied to the modal */
16
- ariaRole?: string;
17
- /** Determines if the Esc Key closes the modal */
18
- disableEscKey?: boolean;
19
- /** Determines if the Dialog can be closed */
20
- disableClose?: boolean;
21
- /** Determines if the background is disabled when the modal is open */
22
- enableBackgroundUI?: boolean;
23
- /** A custom close event handler */
24
- onCancel?: (ev: React.KeyboardEvent<HTMLElement>) => void;
25
- /** Sets the open state of the modal */
26
- open: boolean;
27
- /** Transition time */
28
- timeout?: number;
29
- }
30
-
31
- declare const ModelContext: React.Context<ModalContextProps>;
32
- declare function Modal(props: ModalProps): JSX.Element;
33
-
34
- export { ModalContext };
35
- export default Modal;
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface ModalContextProps {
4
- value?: {
5
- isInModal?: boolean;
6
- isAnimationComplete?: boolean;
7
- triggerRefocusFlag?: boolean;
8
- };
9
- ref?: React.MutableRefObject<React.ReactNode>;
10
- }
11
-
12
- export interface ModalProps {
13
- /** Modal content */
14
- children?: React.ReactNode;
15
- /** The ARIA role to be applied to the modal */
16
- ariaRole?: string;
17
- /** Determines if the Esc Key closes the modal */
18
- disableEscKey?: boolean;
19
- /** Determines if the Dialog can be closed */
20
- disableClose?: boolean;
21
- /** Determines if the background is disabled when the modal is open */
22
- enableBackgroundUI?: boolean;
23
- /** A custom close event handler */
24
- onCancel?: (ev: React.KeyboardEvent<HTMLElement>) => void;
25
- /** Sets the open state of the modal */
26
- open: boolean;
27
- /** Transition time */
28
- timeout?: number;
29
- }
30
-
31
- declare const ModelContext: React.Context<ModalContextProps>;
32
- declare function Modal(props: ModalProps): JSX.Element;
33
-
34
- export { ModalContext };
35
- export default Modal;