carbon-react 107.1.7 → 107.2.1

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.
@@ -3,9 +3,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import React, { useRef, useContext } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import styledSystemPropTypes from "@styled-system/prop-types";
6
+ import { ModalContext } from "../modal/modal.component";
7
+ import { SidebarContext } from "../sidebar/sidebar.component";
6
8
  import FormSummary from "./__internal__/form-summary.component";
7
9
  import { StyledForm, StyledFormContent, StyledFormFooter, StyledLeftButtons, StyledRightButtons } from "./form.style";
8
- import { SidebarContext } from "../sidebar/sidebar.component";
9
10
 
10
11
  const Form = ({
11
12
  children,
@@ -25,6 +26,9 @@ const Form = ({
25
26
  const {
26
27
  isInSidebar
27
28
  } = useContext(SidebarContext);
29
+ const {
30
+ isInModal
31
+ } = useContext(ModalContext);
28
32
  const formRef = useRef();
29
33
  const formFooterRef = useRef();
30
34
  const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
@@ -39,8 +43,9 @@ const Form = ({
39
43
  height: height
40
44
  }, rest), /*#__PURE__*/React.createElement(StyledFormContent, {
41
45
  "data-element": "form-content",
46
+ className: stickyFooter ? "sticky" : "",
42
47
  stickyFooter: stickyFooter,
43
- className: stickyFooter ? "sticky" : ""
48
+ isInModal: isInModal
44
49
  }, children), renderFooter && /*#__PURE__*/React.createElement(StyledFormFooter, {
45
50
  "data-element": "form-footer",
46
51
  className: stickyFooter ? "sticky" : "",
@@ -12,10 +12,11 @@ import StyledSearch from "../search/search.style";
12
12
  import StyledTextarea from "../textarea/textarea.style";
13
13
  export const StyledFormContent = styled.div`
14
14
  ${({
15
- stickyFooter
15
+ stickyFooter,
16
+ isInModal
16
17
  }) => css`
17
18
  ${stickyFooter && css`
18
- overflow-y: auto;
19
+ overflow-y: ${isInModal ? "visible" : "auto"};
19
20
  flex: 1;
20
21
  `}
21
22
  `}
@@ -6,6 +6,7 @@ import styledSystemPropTypes from "@styled-system/prop-types";
6
6
  import { filterStyledSystemMarginProps } from "../../style/utils";
7
7
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
8
  import { StyledHeading, StyledHeadingIcon, StyledSubHeader, StyledHeader, StyledSeparator, StyledHeaderHelp, StyledHeadingTitle, StyledDivider, StyledHeaderContent, StyledHeadingBackButton, StyledHeadingPills } from "./heading.style";
9
+ import useLocale from "../../hooks/__internal__/useLocale";
9
10
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
10
11
 
11
12
  const Heading = ({
@@ -32,6 +33,8 @@ const Heading = ({
32
33
  }, help);
33
34
  };
34
35
 
36
+ const l = useLocale();
37
+
35
38
  const getBackButton = () => {
36
39
  const backButtonProps = typeof backLink === "string" ? {
37
40
  href: backLink
@@ -40,8 +43,9 @@ const Heading = ({
40
43
  };
41
44
  return /*#__PURE__*/React.createElement(StyledHeadingBackButton // this event allows an element to be focusable on click event on IE
42
45
  , _extends({
43
- onMouseDown: e => e.currentTarget.focus(),
44
- "data-element": "back"
46
+ "aria-label": l.heading.backLinkAriaLabel(),
47
+ "data-element": "back",
48
+ onMouseDown: e => e.currentTarget.focus()
45
49
  }, backButtonProps), /*#__PURE__*/React.createElement(StyledHeadingIcon, {
46
50
  type: "chevron_left",
47
51
  divider: divider
@@ -59,6 +59,7 @@ const Help = ({
59
59
 
60
60
  return /*#__PURE__*/React.createElement(StyledHelp, _extends({
61
61
  "aria-describedby": isFocused || isTooltipVisible ? tooltipId || defaultTooltipId.current : undefined,
62
+ "aria-label": helpAriaLabel || ariaLabel,
62
63
  className: className,
63
64
  as: tagType,
64
65
  href: href,
@@ -77,8 +78,7 @@ const Help = ({
77
78
  target: "_blank",
78
79
  rel: "noopener noreferrer"
79
80
  } : {
80
- role: "button",
81
- "aria-label": helpAriaLabel || ariaLabel
81
+ role: "button"
82
82
  }, filterStyledSystemMarginProps(rest), rest), /*#__PURE__*/React.createElement(Icon, {
83
83
  "aria-hidden": true,
84
84
  type: type,
@@ -191,9 +191,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
191
191
  };
192
192
 
193
193
  const handleClick = event => {
194
- if (clickToOpen) {
195
- openSubmenu();
196
- }
194
+ openSubmenu();
197
195
 
198
196
  if (onClick) {
199
197
  onClick(event);
@@ -1 +1 @@
1
- export { default } from "./modal";
1
+ export { default, ModalContext } from "./modal.component";
@@ -1 +1 @@
1
- export { default } from "./modal.component";
1
+ export { default, ModalContext } from "./modal.component";
@@ -0,0 +1,35 @@
1
+ export const ModalContext: React.Context<{}>;
2
+ export default Modal;
3
+ 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
+ import PropTypes from "prop-types";
@@ -1,5 +1,14 @@
1
1
  import * as React from "react";
2
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
+
3
12
  export interface ModalProps {
4
13
  /** Modal content */
5
14
  children?: React.ReactNode;
@@ -19,6 +28,8 @@ export interface ModalProps {
19
28
  timeout?: number;
20
29
  }
21
30
 
31
+ declare const ModelContext: React.Context<ModalContextProps>;
22
32
  declare function Modal(props: ModalProps): JSX.Element;
23
33
 
34
+ export { ModalContext };
24
35
  export default Modal;
@@ -0,0 +1,2 @@
1
+ export const StyledModal: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export const StyledModalBackground: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -57,6 +57,9 @@ const enGB = {
57
57
  }
58
58
  }
59
59
  },
60
+ heading: {
61
+ backLinkAriaLabel: () => "Back"
62
+ },
60
63
  message: {
61
64
  closeButtonAriaLabel: () => "Close"
62
65
  },
@@ -33,6 +33,9 @@ interface Locale {
33
33
  formSummary: (errors: number, warnings: number, type: string) => [string, string] | null;
34
34
  };
35
35
  };
36
+ heading: {
37
+ backLinkAriaLabel: () => string;
38
+ };
36
39
  message: {
37
40
  closeButtonAriaLabel: () => string;
38
41
  };
@@ -55,6 +55,9 @@ const plPL = {
55
55
  }
56
56
  }
57
57
  },
58
+ heading: {
59
+ backLinkAriaLabel: () => "Wstecz"
60
+ },
58
61
  message: {
59
62
  closeButtonAriaLabel: () => "Zamknij"
60
63
  },
@@ -11,12 +11,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
13
13
 
14
+ var _modal = require("../modal/modal.component");
15
+
16
+ var _sidebar = require("../sidebar/sidebar.component");
17
+
14
18
  var _formSummary = _interopRequireDefault(require("./__internal__/form-summary.component"));
15
19
 
16
20
  var _form = require("./form.style");
17
21
 
18
- var _sidebar = require("../sidebar/sidebar.component");
19
-
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -43,6 +45,9 @@ const Form = ({
43
45
  const {
44
46
  isInSidebar
45
47
  } = (0, _react.useContext)(_sidebar.SidebarContext);
48
+ const {
49
+ isInModal
50
+ } = (0, _react.useContext)(_modal.ModalContext);
46
51
  const formRef = (0, _react.useRef)();
47
52
  const formFooterRef = (0, _react.useRef)();
48
53
  const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
@@ -57,8 +62,9 @@ const Form = ({
57
62
  height: height
58
63
  }, rest), /*#__PURE__*/_react.default.createElement(_form.StyledFormContent, {
59
64
  "data-element": "form-content",
65
+ className: stickyFooter ? "sticky" : "",
60
66
  stickyFooter: stickyFooter,
61
- className: stickyFooter ? "sticky" : ""
67
+ isInModal: isInModal
62
68
  }, children), renderFooter && /*#__PURE__*/_react.default.createElement(_form.StyledFormFooter, {
63
69
  "data-element": "form-footer",
64
70
  className: stickyFooter ? "sticky" : "",
@@ -37,10 +37,11 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
37
37
 
38
38
  const StyledFormContent = _styledComponents.default.div`
39
39
  ${({
40
- stickyFooter
40
+ stickyFooter,
41
+ isInModal
41
42
  }) => (0, _styledComponents.css)`
42
43
  ${stickyFooter && (0, _styledComponents.css)`
43
- overflow-y: auto;
44
+ overflow-y: ${isInModal ? "visible" : "auto"};
44
45
  flex: 1;
45
46
  `}
46
47
  `}
@@ -17,6 +17,8 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
17
17
 
18
18
  var _heading = require("./heading.style");
19
19
 
20
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -47,6 +49,8 @@ const Heading = ({
47
49
  }, help);
48
50
  };
49
51
 
52
+ const l = (0, _useLocale.default)();
53
+
50
54
  const getBackButton = () => {
51
55
  const backButtonProps = typeof backLink === "string" ? {
52
56
  href: backLink
@@ -55,8 +59,9 @@ const Heading = ({
55
59
  };
56
60
  return /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingBackButton // this event allows an element to be focusable on click event on IE
57
61
  , _extends({
58
- onMouseDown: e => e.currentTarget.focus(),
59
- "data-element": "back"
62
+ "aria-label": l.heading.backLinkAriaLabel(),
63
+ "data-element": "back",
64
+ onMouseDown: e => e.currentTarget.focus()
60
65
  }, backButtonProps), /*#__PURE__*/_react.default.createElement(_heading.StyledHeadingIcon, {
61
66
  type: "chevron_left",
62
67
  divider: divider
@@ -83,6 +83,7 @@ const Help = ({
83
83
 
84
84
  return /*#__PURE__*/_react.default.createElement(_help.default, _extends({
85
85
  "aria-describedby": isFocused || isTooltipVisible ? tooltipId || defaultTooltipId.current : undefined,
86
+ "aria-label": helpAriaLabel || ariaLabel,
86
87
  className: className,
87
88
  as: tagType,
88
89
  href: href,
@@ -101,8 +102,7 @@ const Help = ({
101
102
  target: "_blank",
102
103
  rel: "noopener noreferrer"
103
104
  } : {
104
- role: "button",
105
- "aria-label": helpAriaLabel || ariaLabel
105
+ role: "button"
106
106
  }, (0, _utils.filterStyledSystemMarginProps)(rest), rest), /*#__PURE__*/_react.default.createElement(_icon.default, {
107
107
  "aria-hidden": true,
108
108
  type: type,
@@ -218,9 +218,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
218
218
  };
219
219
 
220
220
  const handleClick = event => {
221
- if (clickToOpen) {
222
- openSubmenu();
223
- }
221
+ openSubmenu();
224
222
 
225
223
  if (onClick) {
226
224
  onClick(event);
@@ -1 +1 @@
1
- export { default } from "./modal";
1
+ export { default, ModalContext } from "./modal.component";
@@ -9,7 +9,15 @@ Object.defineProperty(exports, "default", {
9
9
  return _modal.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "ModalContext", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _modal.ModalContext;
16
+ }
17
+ });
18
+
19
+ var _modal = _interopRequireWildcard(require("./modal.component"));
12
20
 
13
- var _modal = _interopRequireDefault(require("./modal.component"));
21
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
22
 
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,35 @@
1
+ export const ModalContext: React.Context<{}>;
2
+ export default Modal;
3
+ 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
+ import PropTypes from "prop-types";
@@ -1,5 +1,14 @@
1
1
  import * as React from "react";
2
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
+
3
12
  export interface ModalProps {
4
13
  /** Modal content */
5
14
  children?: React.ReactNode;
@@ -19,6 +28,8 @@ export interface ModalProps {
19
28
  timeout?: number;
20
29
  }
21
30
 
31
+ declare const ModelContext: React.Context<ModalContextProps>;
22
32
  declare function Modal(props: ModalProps): JSX.Element;
23
33
 
34
+ export { ModalContext };
24
35
  export default Modal;
@@ -0,0 +1,2 @@
1
+ export const StyledModal: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export const StyledModalBackground: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -64,6 +64,9 @@ const enGB = {
64
64
  }
65
65
  }
66
66
  },
67
+ heading: {
68
+ backLinkAriaLabel: () => "Back"
69
+ },
67
70
  message: {
68
71
  closeButtonAriaLabel: () => "Close"
69
72
  },
@@ -33,6 +33,9 @@ interface Locale {
33
33
  formSummary: (errors: number, warnings: number, type: string) => [string, string] | null;
34
34
  };
35
35
  };
36
+ heading: {
37
+ backLinkAriaLabel: () => string;
38
+ };
36
39
  message: {
37
40
  closeButtonAriaLabel: () => string;
38
41
  };
@@ -62,6 +62,9 @@ const plPL = {
62
62
  }
63
63
  }
64
64
  },
65
+ heading: {
66
+ backLinkAriaLabel: () => "Wstecz"
67
+ },
65
68
  message: {
66
69
  closeButtonAriaLabel: () => "Zamknij"
67
70
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "107.1.7",
3
+ "version": "107.2.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {