carbon-react 104.3.0 → 104.4.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,6 +1,9 @@
1
1
  export default Confirm;
2
- declare function Confirm({ open, children, destructive, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, ...rest }: {
2
+ declare function Confirm({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, destructive, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, ...rest }: {
3
3
  [x: string]: any;
4
+ "aria-labelledby": any;
5
+ "aria-describedby": any;
6
+ "aria-label": any;
4
7
  open: any;
5
8
  children: any;
6
9
  destructive: any;
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
+ var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
13
+
12
14
  var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
13
15
 
14
16
  var _heading = _interopRequireDefault(require("../heading"));
@@ -27,11 +29,18 @@ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLoc
27
29
 
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
32
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
33
+
34
+ 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; }
35
+
30
36
  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); }
31
37
 
32
38
  let deprecatedWarnTriggered = false;
33
39
 
34
40
  const Confirm = ({
41
+ "aria-labelledby": ariaLabelledBy,
42
+ "aria-describedby": ariaDescribedBy,
43
+ "aria-label": ariaLabel,
35
44
  open,
36
45
  children,
37
46
  destructive,
@@ -62,6 +71,25 @@ const Confirm = ({
62
71
  }
63
72
 
64
73
  const l = (0, _useLocale.default)();
74
+ const {
75
+ current: titleId
76
+ } = (0, _react.useRef)((0, _guid.default)());
77
+ const {
78
+ current: subtitleId
79
+ } = (0, _react.useRef)((0, _guid.default)());
80
+ const ariaProps = {
81
+ "aria-labelledby": ariaLabelledBy,
82
+ "aria-describedby": ariaDescribedBy,
83
+ "aria-label": ariaLabel
84
+ };
85
+
86
+ if (title && iconType) {
87
+ ariaProps["aria-labelledby"] = titleId;
88
+ }
89
+
90
+ if (subtitle && iconType) {
91
+ ariaProps["aria-describedby"] = subtitleId;
92
+ }
65
93
 
66
94
  const renderCancelButton = () => {
67
95
  if (!onCancel) return null;
@@ -100,9 +128,9 @@ const Confirm = ({
100
128
  fontSize: "medium"
101
129
  }), /*#__PURE__*/_react.default.createElement(_heading.default, {
102
130
  title: title,
103
- titleId: "carbon-dialog-title",
131
+ titleId: titleId,
104
132
  subheader: subtitle,
105
- subtitleId: "carbon-dialog-subtitle",
133
+ subtitleId: subtitleId,
106
134
  divider: false
107
135
  }));
108
136
  }
@@ -118,7 +146,7 @@ const Confirm = ({
118
146
  title: getTitle(),
119
147
  "data-component": "confirm",
120
148
  role: "alertdialog"
121
- }, rest), children, /*#__PURE__*/_react.default.createElement(_confirm.StyledConfirmButtons, null, renderCancelButton(), renderConfirmButton()));
149
+ }, ariaProps, rest), children, /*#__PURE__*/_react.default.createElement(_confirm.StyledConfirmButtons, null, renderCancelButton(), renderConfirmButton()));
122
150
  };
123
151
 
124
152
  Confirm.defaultProps = {
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
+ var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
13
+
12
14
  var _modal = _interopRequireDefault(require("../modal"));
13
15
 
14
16
  var _heading = _interopRequireDefault(require("../heading"));
@@ -58,6 +60,12 @@ const Dialog = ({
58
60
  const innerContentRef = (0, _react.useRef)();
59
61
  const titleRef = (0, _react.useRef)();
60
62
  const listenersAdded = (0, _react.useRef)(false);
63
+ const {
64
+ current: titleId
65
+ } = (0, _react.useRef)((0, _guid.default)());
66
+ const {
67
+ current: subtitleId
68
+ } = (0, _react.useRef)((0, _guid.default)());
61
69
  const centerDialog = (0, _react.useCallback)(() => {
62
70
  const {
63
71
  width: dialogWidth,
@@ -133,9 +141,9 @@ const Dialog = ({
133
141
  }, typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_heading.default, {
134
142
  "data-element": "dialog-title",
135
143
  title: title,
136
- titleId: "carbon-dialog-title",
144
+ titleId: titleId,
137
145
  subheader: subtitle,
138
- subtitleId: "carbon-dialog-subtitle",
146
+ subtitleId: subtitleId,
139
147
  divider: false,
140
148
  help: help
141
149
  }) : title);
@@ -150,15 +158,10 @@ const Dialog = ({
150
158
  const dialogProps = {
151
159
  size,
152
160
  dialogHeight,
153
- "aria-labelledby": rest["aria-labelledby"],
154
- "aria-describedby": subtitle ? "carbon-dialog-subtitle" : rest["aria-describedby"],
161
+ "aria-labelledby": title && typeof title === "string" ? titleId : rest["aria-labelledby"],
162
+ "aria-describedby": subtitle ? subtitleId : rest["aria-describedby"],
155
163
  "aria-label": rest["aria-label"]
156
164
  };
157
-
158
- if (title && typeof title === "string") {
159
- dialogProps["aria-labelledby"] = "carbon-dialog-title";
160
- }
161
-
162
165
  const componentTags = {
163
166
  "data-component": rest["data-component"] || "dialog",
164
167
  "data-element": rest["data-element"],
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
+ var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
13
+
12
14
  var _modal = _interopRequireDefault(require("../modal"));
13
15
 
14
16
  var _heading = _interopRequireDefault(require("../heading"));
@@ -51,11 +53,17 @@ const DialogFullScreen = ({
51
53
  onCancel,
52
54
  contentRef,
53
55
  help,
54
- role = "region",
56
+ role = "dialog",
55
57
  ...rest
56
58
  }) => {
57
59
  const dialogRef = (0, _react.useRef)();
58
60
  const headingRef = (0, _react.useRef)();
61
+ const {
62
+ current: titleId
63
+ } = (0, _react.useRef)((0, _guid.default)());
64
+ const {
65
+ current: subtitleId
66
+ } = (0, _react.useRef)((0, _guid.default)());
59
67
 
60
68
  const closeIcon = () => {
61
69
  if (!showCloseIcon || !onCancel) return null;
@@ -74,13 +82,18 @@ const DialogFullScreen = ({
74
82
  }, typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_heading.default, {
75
83
  "data-element": "dialog-title",
76
84
  title: title,
77
- titleId: "carbon-dialog-title",
85
+ titleId: titleId,
78
86
  subheader: subtitle,
79
- subtitleId: "carbon-dialog-subtitle",
87
+ subtitleId: subtitleId,
80
88
  divider: false,
81
89
  help: help
82
90
  }) : title, headerChildren);
83
91
 
92
+ const ariaProps = {
93
+ "aria-labelledby": title && typeof title === "string" ? titleId : ariaLabelledBy,
94
+ "aria-describedby": subtitle ? subtitleId : ariaDescribedBy,
95
+ "aria-label": ariaLabel
96
+ };
84
97
  const componentTags = {
85
98
  "data-component": "dialog-full-screen",
86
99
  "data-element": rest["data-element"],
@@ -94,16 +107,14 @@ const DialogFullScreen = ({
94
107
  autoFocus: !disableAutoFocus,
95
108
  focusFirstElement: focusFirstElement,
96
109
  wrapperRef: dialogRef
97
- }, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, {
98
- "aria-modal": true,
99
- "aria-describedby": ariaDescribedBy,
100
- "aria-label": ariaLabel,
101
- "aria-labelledby": ariaLabelledBy || "carbon-dialog-title",
110
+ }, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, _extends({
111
+ "aria-modal": true
112
+ }, ariaProps, {
102
113
  ref: dialogRef,
103
114
  "data-element": "dialog-full-screen",
104
115
  pagesStyling: pagesStyling,
105
116
  role: role
106
- }, dialogTitle(), /*#__PURE__*/_react.default.createElement(_content.default, {
117
+ }), dialogTitle(), /*#__PURE__*/_react.default.createElement(_content.default, {
107
118
  hasHeader: title !== undefined,
108
119
  "data-element": "content",
109
120
  ref: contentRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.3.0",
3
+ "version": "104.4.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {