carbon-react 111.12.6 → 111.12.7

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.
@@ -21,6 +21,7 @@ const DialogFullScreen = ({
21
21
  "aria-labelledby": ariaLabelledBy,
22
22
  disableAutoFocus,
23
23
  focusFirstElement,
24
+ bespokeFocusTrap,
24
25
  open,
25
26
  children,
26
27
  title,
@@ -93,6 +94,7 @@ const DialogFullScreen = ({
93
94
  }, componentTags), /*#__PURE__*/React.createElement(FocusTrap, {
94
95
  autoFocus: !disableAutoFocus,
95
96
  focusFirstElement: focusFirstElement,
97
+ bespokeTrap: bespokeFocusTrap,
96
98
  wrapperRef: dialogRef,
97
99
  isOpen: open,
98
100
  additionalWrapperRefs: focusableContainers,
@@ -148,6 +150,13 @@ DialogFullScreen.propTypes = {
148
150
  /** Disables auto focus functionality on child elements */
149
151
  disableAutoFocus: PropTypes.bool,
150
152
 
153
+ /**
154
+ * Function to replace focus trap
155
+ * @ignore
156
+ * @private
157
+ */
158
+ bespokeFocusTrap: PropTypes.func,
159
+
151
160
  /** Determines if the Esc Key closes the Dialog */
152
161
  disableEscKey: PropTypes.bool,
153
162
 
@@ -28,6 +28,15 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps {
28
28
  disableEscKey?: boolean;
29
29
  /** Set this prop to false to hide the translucent background when the dialog is open. */
30
30
  enableBackgroundUI?: boolean;
31
+ /** Optional reference to an element meant to be focused on open */
32
+ focusFirstElement?: React.MutableRefObject<HTMLElement | null>;
33
+ disableAutoFocus?: boolean;
34
+ /**
35
+ * Function to replace focus trap
36
+ * @ignore
37
+ * @private
38
+ */
39
+ bespokeFocusTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
31
40
  /** Node that will be used as sidebar header. */
32
41
  header?: React.ReactNode;
33
42
  /** A custom close event handler */
@@ -21,6 +21,8 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
21
21
  "aria-label": ariaLabel,
22
22
  "aria-labelledby": ariaLabelledBy,
23
23
  open,
24
+ bespokeFocusTrap,
25
+ disableAutoFocus = false,
24
26
  disableEscKey = false,
25
27
  enableBackgroundUI = false,
26
28
  header,
@@ -29,6 +31,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
29
31
  children,
30
32
  onCancel,
31
33
  role = "dialog",
34
+ focusFirstElement,
32
35
  focusableContainers,
33
36
  focusableSelectors,
34
37
  width,
@@ -104,17 +107,22 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
104
107
  wrapperRef: sidebarRef,
105
108
  isOpen: open,
106
109
  additionalWrapperRefs: focusableContainers,
107
- focusableSelectors: focusableSelectors
110
+ focusableSelectors: focusableSelectors,
111
+ focusFirstElement: focusFirstElement,
112
+ autoFocus: !disableAutoFocus,
113
+ bespokeTrap: bespokeFocusTrap
108
114
  }, sidebar));
109
115
  });
110
116
  Sidebar.propTypes = {
111
117
  "aria-describedby": PropTypes.string,
112
118
  "aria-label": PropTypes.string,
113
119
  "aria-labelledby": PropTypes.string,
120
+ "bespokeFocusTrap": PropTypes.func,
114
121
  "children": PropTypes.node,
115
122
  "data-component": PropTypes.string,
116
123
  "data-element": PropTypes.string,
117
124
  "data-role": PropTypes.string,
125
+ "disableAutoFocus": PropTypes.bool,
118
126
  "disableEscKey": PropTypes.bool,
119
127
  "enableBackgroundUI": PropTypes.bool,
120
128
  "focusableContainers": PropTypes.arrayOf(PropTypes.shape({
@@ -127,6 +135,15 @@ Sidebar.propTypes = {
127
135
  }
128
136
  })),
129
137
  "focusableSelectors": PropTypes.string,
138
+ "focusFirstElement": PropTypes.shape({
139
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
140
+ if (props[propName] == null) {
141
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
142
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
143
+ return new Error("Expected prop '" + propName + "' to be of type Element");
144
+ }
145
+ }]).isRequired
146
+ }),
130
147
  "header": PropTypes.node,
131
148
  "onCancel": PropTypes.func,
132
149
  "open": PropTypes.bool.isRequired,
@@ -47,6 +47,7 @@ const DialogFullScreen = ({
47
47
  "aria-labelledby": ariaLabelledBy,
48
48
  disableAutoFocus,
49
49
  focusFirstElement,
50
+ bespokeFocusTrap,
50
51
  open,
51
52
  children,
52
53
  title,
@@ -119,6 +120,7 @@ const DialogFullScreen = ({
119
120
  }, componentTags), /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
120
121
  autoFocus: !disableAutoFocus,
121
122
  focusFirstElement: focusFirstElement,
123
+ bespokeTrap: bespokeFocusTrap,
122
124
  wrapperRef: dialogRef,
123
125
  isOpen: open,
124
126
  additionalWrapperRefs: focusableContainers,
@@ -174,6 +176,13 @@ DialogFullScreen.propTypes = {
174
176
  /** Disables auto focus functionality on child elements */
175
177
  disableAutoFocus: _propTypes.default.bool,
176
178
 
179
+ /**
180
+ * Function to replace focus trap
181
+ * @ignore
182
+ * @private
183
+ */
184
+ bespokeFocusTrap: _propTypes.default.func,
185
+
177
186
  /** Determines if the Esc Key closes the Dialog */
178
187
  disableEscKey: _propTypes.default.bool,
179
188
 
@@ -28,6 +28,15 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps {
28
28
  disableEscKey?: boolean;
29
29
  /** Set this prop to false to hide the translucent background when the dialog is open. */
30
30
  enableBackgroundUI?: boolean;
31
+ /** Optional reference to an element meant to be focused on open */
32
+ focusFirstElement?: React.MutableRefObject<HTMLElement | null>;
33
+ disableAutoFocus?: boolean;
34
+ /**
35
+ * Function to replace focus trap
36
+ * @ignore
37
+ * @private
38
+ */
39
+ bespokeFocusTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
31
40
  /** Node that will be used as sidebar header. */
32
41
  header?: React.ReactNode;
33
42
  /** A custom close event handler */
@@ -50,6 +50,8 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
50
50
  "aria-label": ariaLabel,
51
51
  "aria-labelledby": ariaLabelledBy,
52
52
  open,
53
+ bespokeFocusTrap,
54
+ disableAutoFocus = false,
53
55
  disableEscKey = false,
54
56
  enableBackgroundUI = false,
55
57
  header,
@@ -58,6 +60,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
58
60
  children,
59
61
  onCancel,
60
62
  role = "dialog",
63
+ focusFirstElement,
61
64
  focusableContainers,
62
65
  focusableSelectors,
63
66
  width,
@@ -135,7 +138,10 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
135
138
  wrapperRef: sidebarRef,
136
139
  isOpen: open,
137
140
  additionalWrapperRefs: focusableContainers,
138
- focusableSelectors: focusableSelectors
141
+ focusableSelectors: focusableSelectors,
142
+ focusFirstElement: focusFirstElement,
143
+ autoFocus: !disableAutoFocus,
144
+ bespokeTrap: bespokeFocusTrap
139
145
  }, sidebar));
140
146
  });
141
147
 
@@ -144,10 +150,12 @@ Sidebar.propTypes = {
144
150
  "aria-describedby": _propTypes.default.string,
145
151
  "aria-label": _propTypes.default.string,
146
152
  "aria-labelledby": _propTypes.default.string,
153
+ "bespokeFocusTrap": _propTypes.default.func,
147
154
  "children": _propTypes.default.node,
148
155
  "data-component": _propTypes.default.string,
149
156
  "data-element": _propTypes.default.string,
150
157
  "data-role": _propTypes.default.string,
158
+ "disableAutoFocus": _propTypes.default.bool,
151
159
  "disableEscKey": _propTypes.default.bool,
152
160
  "enableBackgroundUI": _propTypes.default.bool,
153
161
  "focusableContainers": _propTypes.default.arrayOf(_propTypes.default.shape({
@@ -160,6 +168,15 @@ Sidebar.propTypes = {
160
168
  }
161
169
  })),
162
170
  "focusableSelectors": _propTypes.default.string,
171
+ "focusFirstElement": _propTypes.default.shape({
172
+ "current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), function (props, propName) {
173
+ if (props[propName] == null) {
174
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
175
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
176
+ return new Error("Expected prop '" + propName + "' to be of type Element");
177
+ }
178
+ }]).isRequired
179
+ }),
163
180
  "header": _propTypes.default.node,
164
181
  "onCancel": _propTypes.default.func,
165
182
  "open": _propTypes.default.bool.isRequired,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.12.6",
3
+ "version": "111.12.7",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",