@carbon/react 1.9.0 → 1.10.0-rc.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.
- package/es/components/ComposedModal/ComposedModal.js +172 -577
- package/es/components/ComposedModal/{next/ModalFooter.js → ModalFooter.js} +4 -4
- package/es/components/ComposedModal/{next/ModalHeader.js → ModalHeader.js} +2 -2
- package/es/components/DataTable/tools/sorting.js +8 -0
- package/es/components/Icon/Icon.Skeleton.js +4 -12
- package/es/components/InlineCheckbox/InlineCheckbox.js +0 -1
- package/es/components/NumberInput/NumberInput.js +3 -3
- package/es/components/TileGroup/TileGroup.js +1 -1
- package/es/index.js +3 -2
- package/es/internal/useControllableState.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +174 -581
- package/lib/components/ComposedModal/{next/ModalFooter.js → ModalFooter.js} +4 -4
- package/lib/components/ComposedModal/{next/ModalHeader.js → ModalHeader.js} +2 -2
- package/lib/components/DataTable/tools/sorting.js +8 -0
- package/lib/components/Icon/Icon.Skeleton.js +4 -12
- package/lib/components/InlineCheckbox/InlineCheckbox.js +0 -1
- package/lib/components/NumberInput/NumberInput.js +3 -3
- package/lib/components/TileGroup/TileGroup.js +1 -1
- package/lib/index.js +53 -52
- package/lib/internal/useControllableState.js +1 -1
- package/package.json +4 -4
- package/es/components/ComposedModal/index.js +0 -19
- package/es/components/ComposedModal/next/ComposedModal.js +0 -225
- package/lib/components/ComposedModal/index.js +0 -45
- package/lib/components/ComposedModal/next/ComposedModal.js +0 -236
|
@@ -12,10 +12,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var ModalHeader = require('./ModalHeader.js');
|
|
16
|
+
var ModalFooter = require('./ModalFooter.js');
|
|
17
17
|
var cx = require('classnames');
|
|
18
|
-
var iconsReact = require('@carbon/icons-react');
|
|
19
18
|
var toggleClass = require('../../tools/toggleClass.js');
|
|
20
19
|
var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
|
|
21
20
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
@@ -27,618 +26,212 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
27
26
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
28
27
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
29
28
|
|
|
30
|
-
var
|
|
29
|
+
var _ModalBody$propTypes, _ComposedModal$propTy;
|
|
31
30
|
|
|
32
|
-
var _excluded = ["
|
|
33
|
-
_excluded2 = ["
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
var _excluded = ["className", "children", "hasForm", "hasScrollingContent"],
|
|
32
|
+
_excluded2 = ["aria-labelledby", "aria-label", "children", "className", "containerClassName", "danger", "onClose", "onKeyDown", "open", "preventCloseOnClickOutside", "selectorPrimaryFocus", "selectorsFloatingMenus", "size"];
|
|
33
|
+
var ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function ModalBody(_ref, ref) {
|
|
34
|
+
var _cx;
|
|
36
35
|
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function ComposedModal() {
|
|
43
|
-
var _this;
|
|
44
|
-
|
|
45
|
-
_rollupPluginBabelHelpers.classCallCheck(this, ComposedModal);
|
|
46
|
-
|
|
47
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
-
args[_key] = arguments[_key];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
52
|
-
|
|
53
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "state", {});
|
|
54
|
-
|
|
55
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "outerModal", /*#__PURE__*/React__default["default"].createRef());
|
|
56
|
-
|
|
57
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "innerModal", /*#__PURE__*/React__default["default"].createRef());
|
|
58
|
-
|
|
59
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "button", /*#__PURE__*/React__default["default"].createRef());
|
|
60
|
-
|
|
61
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "startSentinel", /*#__PURE__*/React__default["default"].createRef());
|
|
62
|
-
|
|
63
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "endSentinel", /*#__PURE__*/React__default["default"].createRef());
|
|
64
|
-
|
|
65
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleKeyDown", function (evt) {
|
|
66
|
-
// Esc key
|
|
67
|
-
if (evt.which === 27) {
|
|
68
|
-
_this.closeModal(evt);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_this.props.onKeyDown(evt);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleClick", function (evt) {
|
|
75
|
-
if (!_this.innerModal.current.contains(evt.target) && _this.props.preventCloseOnClickOutside) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (_this.innerModal.current && !_this.innerModal.current.contains(evt.target)) {
|
|
80
|
-
_this.closeModal(evt);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleBlur", function (_ref) {
|
|
85
|
-
var oldActiveNode = _ref.target,
|
|
86
|
-
currentActiveNode = _ref.relatedTarget;
|
|
87
|
-
var _this$props = _this.props,
|
|
88
|
-
open = _this$props.open,
|
|
89
|
-
selectorsFloatingMenus = _this$props.selectorsFloatingMenus;
|
|
90
|
-
|
|
91
|
-
if (open && currentActiveNode && oldActiveNode) {
|
|
92
|
-
var bodyNode = _this.innerModal.current;
|
|
93
|
-
var startSentinelNode = _this.startSentinel.current;
|
|
94
|
-
var endSentinelNode = _this.endSentinel.current;
|
|
95
|
-
wrapFocus["default"]({
|
|
96
|
-
bodyNode: bodyNode,
|
|
97
|
-
startSentinelNode: startSentinelNode,
|
|
98
|
-
endSentinelNode: endSentinelNode,
|
|
99
|
-
currentActiveNode: currentActiveNode,
|
|
100
|
-
oldActiveNode: oldActiveNode,
|
|
101
|
-
selectorsFloatingMenus: selectorsFloatingMenus
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "focusButton", function (focusContainerElement) {
|
|
107
|
-
if (focusContainerElement) {
|
|
108
|
-
var primaryFocusElement = focusContainerElement.querySelector(_this.props.selectorPrimaryFocus);
|
|
109
|
-
|
|
110
|
-
if (primaryFocusElement) {
|
|
111
|
-
primaryFocusElement.focus();
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (_this.button.current) {
|
|
116
|
-
_this.button.current.focus();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleTransitionEnd", function (evt) {
|
|
122
|
-
if (_this.outerModal.current.offsetWidth && _this.outerModal.current.offsetHeight && _this.beingOpen) {
|
|
123
|
-
_this.focusButton(evt.currentTarget);
|
|
124
|
-
|
|
125
|
-
_this.beingOpen = false;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "closeModal", function (evt) {
|
|
130
|
-
var onClose = _this.props.onClose;
|
|
131
|
-
|
|
132
|
-
if (!onClose || onClose(evt) !== false) {
|
|
133
|
-
_this.setState({
|
|
134
|
-
open: false
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return _this;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
_rollupPluginBabelHelpers.createClass(ComposedModal, [{
|
|
143
|
-
key: "componentDidUpdate",
|
|
144
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
145
|
-
if (!prevState.open && this.state.open) {
|
|
146
|
-
this.beingOpen = true;
|
|
147
|
-
} else if (prevState.open && !this.state.open) {
|
|
148
|
-
this.beingOpen = false;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (prevState.open !== this.state.open) {
|
|
152
|
-
toggleClass["default"](document.body, "".concat(this.context, "--body--with-modal-open"), this.state.open);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, {
|
|
156
|
-
key: "componentWillUnmount",
|
|
157
|
-
value: function componentWillUnmount() {
|
|
158
|
-
toggleClass["default"](document.body, "".concat(this.context, "--body--with-modal-open"), false);
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "componentDidMount",
|
|
162
|
-
value: function componentDidMount() {
|
|
163
|
-
toggleClass["default"](document.body, "".concat(this.context, "--body--with-modal-open"), this.props.open);
|
|
164
|
-
|
|
165
|
-
if (!this.props.open) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (this.innerModal.current) {
|
|
170
|
-
this.focusButton(this.innerModal.current);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "render",
|
|
175
|
-
value: function render() {
|
|
176
|
-
var _classNames,
|
|
177
|
-
_classNames2,
|
|
178
|
-
_this2 = this;
|
|
179
|
-
|
|
180
|
-
var open = this.state.open;
|
|
181
|
-
var prefix = this.context;
|
|
182
|
-
|
|
183
|
-
var _this$props2 = this.props,
|
|
184
|
-
ariaLabelledBy = _this$props2['aria-labelledby'],
|
|
185
|
-
ariaLabel = _this$props2['aria-label'],
|
|
186
|
-
className = _this$props2.className,
|
|
187
|
-
containerClassName = _this$props2.containerClassName,
|
|
188
|
-
children = _this$props2.children,
|
|
189
|
-
danger = _this$props2.danger;
|
|
190
|
-
_this$props2.preventCloseOnClickOutside;
|
|
191
|
-
_this$props2.selectorPrimaryFocus;
|
|
192
|
-
_this$props2.selectorsFloatingMenus;
|
|
193
|
-
var size = _this$props2.size,
|
|
194
|
-
forwardedRef = _this$props2.forwardedRef,
|
|
195
|
-
other = _rollupPluginBabelHelpers.objectWithoutProperties(_this$props2, _excluded);
|
|
196
|
-
|
|
197
|
-
var modalClass = cx__default["default"]((_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--modal"), true), _rollupPluginBabelHelpers.defineProperty(_classNames, 'is-visible', open), _rollupPluginBabelHelpers.defineProperty(_classNames, className, className), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--modal--danger"), danger), _classNames));
|
|
198
|
-
var containerClass = cx__default["default"]((_classNames2 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--modal-container"), true), _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--modal-container--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_classNames2, containerClassName, containerClassName), _classNames2)); // Generate aria-label based on Modal Header label if one is not provided (L253)
|
|
199
|
-
|
|
200
|
-
var generatedAriaLabel;
|
|
201
|
-
var childrenWithProps = React__default["default"].Children.toArray(children).map(function (child) {
|
|
202
|
-
switch (child.type) {
|
|
203
|
-
case React__default["default"].createElement(ModalHeader).type:
|
|
204
|
-
generatedAriaLabel = child.props.label;
|
|
205
|
-
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
206
|
-
closeModal: _this2.closeModal
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
case React__default["default"].createElement(ModalFooter).type:
|
|
210
|
-
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
211
|
-
closeModal: _this2.closeModal,
|
|
212
|
-
inputref: _this2.button
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
default:
|
|
216
|
-
return child;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
220
|
-
role: "presentation",
|
|
221
|
-
ref: function ref(node) {
|
|
222
|
-
if (node) {
|
|
223
|
-
_this2.outerModal.current = node;
|
|
224
|
-
|
|
225
|
-
if (typeof forwardedRef === 'function') {
|
|
226
|
-
forwardedRef(node);
|
|
227
|
-
} else if (_rollupPluginBabelHelpers["typeof"](forwardedRef) === 'object') {
|
|
228
|
-
forwardedRef.current = node;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
onBlur: this.handleBlur,
|
|
233
|
-
onClick: this.handleClick,
|
|
234
|
-
onKeyDown: this.handleKeyDown,
|
|
235
|
-
onTransitionEnd: open ? this.handleTransitionEnd : undefined,
|
|
236
|
-
className: modalClass,
|
|
237
|
-
tabIndex: "-1"
|
|
238
|
-
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
239
|
-
ref: this.startSentinel,
|
|
240
|
-
tabIndex: "0",
|
|
241
|
-
role: "link",
|
|
242
|
-
className: "".concat(prefix, "--visually-hidden")
|
|
243
|
-
}, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
244
|
-
ref: this.innerModal,
|
|
245
|
-
className: containerClass,
|
|
246
|
-
role: "dialog",
|
|
247
|
-
"aria-modal": "true",
|
|
248
|
-
"aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
|
|
249
|
-
"aria-labelledby": ariaLabelledBy
|
|
250
|
-
}, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
251
|
-
ref: this.endSentinel,
|
|
252
|
-
tabIndex: "0",
|
|
253
|
-
role: "link",
|
|
254
|
-
className: "".concat(prefix, "--visually-hidden")
|
|
255
|
-
}, "Focus sentinel"));
|
|
256
|
-
}
|
|
257
|
-
}], [{
|
|
258
|
-
key: "getDerivedStateFromProps",
|
|
259
|
-
value: function getDerivedStateFromProps(_ref2, state) {
|
|
260
|
-
var open = _ref2.open;
|
|
261
|
-
var prevOpen = state.prevOpen;
|
|
262
|
-
return prevOpen === open ? null : {
|
|
263
|
-
open: open,
|
|
264
|
-
prevOpen: open
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
}]);
|
|
268
|
-
|
|
269
|
-
return ComposedModal;
|
|
270
|
-
}(React.Component);
|
|
271
|
-
|
|
272
|
-
_rollupPluginBabelHelpers.defineProperty(ComposedModal, "contextType", usePrefix.PrefixContext);
|
|
273
|
-
|
|
274
|
-
_rollupPluginBabelHelpers.defineProperty(ComposedModal, "defaultProps", {
|
|
275
|
-
onKeyDown: function onKeyDown() {},
|
|
276
|
-
selectorPrimaryFocus: '[data-modal-primary-focus]'
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
_rollupPluginBabelHelpers.defineProperty(ComposedModal, "propTypes", (_defineProperty2 = {}, _rollupPluginBabelHelpers.defineProperty(_defineProperty2, 'aria-label', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, 'aria-labelledby', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "children", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "containerClassName", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "danger", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "onClose", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "onKeyDown", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "open", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "preventCloseOnClickOutside", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "selectorPrimaryFocus", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "selectorsFloatingMenus", PropTypes__default["default"].arrayOf(PropTypes__default["default"].string)), _rollupPluginBabelHelpers.defineProperty(_defineProperty2, "size", PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])), _defineProperty2));
|
|
280
|
-
var ModalHeader = /*#__PURE__*/function (_Component2) {
|
|
281
|
-
_rollupPluginBabelHelpers.inherits(ModalHeader, _Component2);
|
|
282
|
-
|
|
283
|
-
var _super2 = _rollupPluginBabelHelpers.createSuper(ModalHeader);
|
|
284
|
-
|
|
285
|
-
function ModalHeader() {
|
|
286
|
-
var _this3;
|
|
287
|
-
|
|
288
|
-
_rollupPluginBabelHelpers.classCallCheck(this, ModalHeader);
|
|
289
|
-
|
|
290
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
291
|
-
args[_key2] = arguments[_key2];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
295
|
-
|
|
296
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this3), "handleCloseButtonClick", function (evt) {
|
|
297
|
-
_this3.props.closeModal(evt);
|
|
298
|
-
|
|
299
|
-
_this3.props.buttonOnClick();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
return _this3;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
_rollupPluginBabelHelpers.createClass(ModalHeader, [{
|
|
306
|
-
key: "render",
|
|
307
|
-
value: function render() {
|
|
308
|
-
var _classNames3, _classNames4, _classNames5, _classNames6, _classNames7;
|
|
309
|
-
|
|
310
|
-
var _this$props3 = this.props,
|
|
311
|
-
className = _this$props3.className,
|
|
312
|
-
labelClassName = _this$props3.labelClassName,
|
|
313
|
-
titleClassName = _this$props3.titleClassName,
|
|
314
|
-
closeClassName = _this$props3.closeClassName,
|
|
315
|
-
closeIconClassName = _this$props3.closeIconClassName,
|
|
316
|
-
label = _this$props3.label,
|
|
317
|
-
title = _this$props3.title,
|
|
318
|
-
children = _this$props3.children,
|
|
319
|
-
iconDescription = _this$props3.iconDescription;
|
|
320
|
-
_this$props3.closeModal;
|
|
321
|
-
_this$props3.buttonOnClick;
|
|
322
|
-
_this$props3.preventCloseOnClickOutside;
|
|
323
|
-
var forwardedRef = _this$props3.forwardedRef,
|
|
324
|
-
other = _rollupPluginBabelHelpers.objectWithoutProperties(_this$props3, _excluded2);
|
|
325
|
-
|
|
326
|
-
var prefix = this.context;
|
|
327
|
-
var headerClass = cx__default["default"]((_classNames3 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--modal-header"), true), _rollupPluginBabelHelpers.defineProperty(_classNames3, className, className), _classNames3));
|
|
328
|
-
var labelClass = cx__default["default"]((_classNames4 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--modal-header__label ").concat(prefix, "--type-delta"), true), _rollupPluginBabelHelpers.defineProperty(_classNames4, labelClassName, labelClassName), _classNames4));
|
|
329
|
-
var titleClass = cx__default["default"]((_classNames5 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames5, "".concat(prefix, "--modal-header__heading ").concat(prefix, "--type-beta"), true), _rollupPluginBabelHelpers.defineProperty(_classNames5, titleClassName, titleClassName), _classNames5));
|
|
330
|
-
var closeClass = cx__default["default"]((_classNames6 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames6, "".concat(prefix, "--modal-close"), true), _rollupPluginBabelHelpers.defineProperty(_classNames6, closeClassName, closeClassName), _classNames6));
|
|
331
|
-
var closeIconClass = cx__default["default"]((_classNames7 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames7, "".concat(prefix, "--modal-close__icon"), true), _rollupPluginBabelHelpers.defineProperty(_classNames7, closeIconClassName, closeIconClassName), _classNames7));
|
|
332
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
333
|
-
className: headerClass
|
|
334
|
-
}, other, {
|
|
335
|
-
ref: forwardedRef
|
|
336
|
-
}), label && /*#__PURE__*/React__default["default"].createElement("h2", {
|
|
337
|
-
className: labelClass
|
|
338
|
-
}, label), title && /*#__PURE__*/React__default["default"].createElement("h3", {
|
|
339
|
-
className: titleClass
|
|
340
|
-
}, title), children, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
341
|
-
onClick: this.handleCloseButtonClick,
|
|
342
|
-
className: closeClass,
|
|
343
|
-
title: iconDescription,
|
|
344
|
-
"aria-label": iconDescription,
|
|
345
|
-
type: "button"
|
|
346
|
-
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
|
|
347
|
-
size: 20,
|
|
348
|
-
className: closeIconClass
|
|
349
|
-
})));
|
|
350
|
-
}
|
|
351
|
-
}]);
|
|
352
|
-
|
|
353
|
-
return ModalHeader;
|
|
354
|
-
}(React.Component);
|
|
355
|
-
|
|
356
|
-
_rollupPluginBabelHelpers.defineProperty(ModalHeader, "propTypes", {
|
|
357
|
-
/**
|
|
358
|
-
* Provide an optional function to be called when the close button is
|
|
359
|
-
* clicked
|
|
360
|
-
*/
|
|
361
|
-
buttonOnClick: PropTypes__default["default"].func,
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Specify the content to be placed in the ModalHeader
|
|
365
|
-
*/
|
|
366
|
-
children: PropTypes__default["default"].node,
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Specify an optional className to be applied to the modal header
|
|
370
|
-
*/
|
|
371
|
-
className: PropTypes__default["default"].string,
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Specify an optional className to be applied to the modal close node
|
|
375
|
-
*/
|
|
376
|
-
closeClassName: PropTypes__default["default"].string,
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Specify an optional className to be applied to the modal close icon node
|
|
380
|
-
*/
|
|
381
|
-
closeIconClassName: PropTypes__default["default"].string,
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Provide an optional function to be called when the modal is closed
|
|
385
|
-
*/
|
|
386
|
-
closeModal: PropTypes__default["default"].func,
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Specify a description for the close icon that can be read by screen
|
|
390
|
-
* readers
|
|
391
|
-
*/
|
|
392
|
-
iconDescription: PropTypes__default["default"].string,
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Specify an optional label to be displayed
|
|
396
|
-
*/
|
|
397
|
-
label: PropTypes__default["default"].node,
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Specify an optional className to be applied to the modal header label
|
|
401
|
-
*/
|
|
402
|
-
labelClassName: PropTypes__default["default"].string,
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Specify an optional title to be displayed
|
|
406
|
-
*/
|
|
407
|
-
title: PropTypes__default["default"].node,
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Specify an optional className to be applied to the modal heading
|
|
411
|
-
*/
|
|
412
|
-
titleClassName: PropTypes__default["default"].string
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
_rollupPluginBabelHelpers.defineProperty(ModalHeader, "contextType", usePrefix.PrefixContext);
|
|
416
|
-
|
|
417
|
-
_rollupPluginBabelHelpers.defineProperty(ModalHeader, "defaultProps", {
|
|
418
|
-
iconDescription: 'Close',
|
|
419
|
-
buttonOnClick: function buttonOnClick() {}
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
var ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function ModalBody(props, ref) {
|
|
423
|
-
var _classNames8;
|
|
424
|
-
|
|
425
|
-
var className = props.className,
|
|
426
|
-
children = props.children,
|
|
427
|
-
hasForm = props.hasForm,
|
|
428
|
-
hasScrollingContent = props.hasScrollingContent;
|
|
429
|
-
props.preventCloseOnClickOutside;
|
|
430
|
-
var other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded3);
|
|
36
|
+
var customClassName = _ref.className,
|
|
37
|
+
children = _ref.children,
|
|
38
|
+
hasForm = _ref.hasForm,
|
|
39
|
+
hasScrollingContent = _ref.hasScrollingContent,
|
|
40
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
431
41
|
|
|
432
42
|
var prefix = usePrefix.usePrefix();
|
|
433
|
-
var contentClass = cx__default["default"]((
|
|
43
|
+
var contentClass = cx__default["default"]((_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--modal-content"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--modal-content--with-form"), hasForm), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--modal-scroll-content"), hasScrollingContent), _rollupPluginBabelHelpers.defineProperty(_cx, customClassName, customClassName), _cx));
|
|
434
44
|
var hasScrollingContentProps = hasScrollingContent ? {
|
|
435
45
|
tabIndex: 0,
|
|
436
46
|
role: 'region'
|
|
437
47
|
} : {};
|
|
438
48
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
439
49
|
className: contentClass
|
|
440
|
-
}, hasScrollingContentProps,
|
|
50
|
+
}, hasScrollingContentProps, rest, {
|
|
441
51
|
ref: ref
|
|
442
52
|
}), children), hasScrollingContent && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
443
53
|
className: "".concat(prefix, "--modal-content--overflow-indicator")
|
|
444
54
|
}));
|
|
445
55
|
});
|
|
446
56
|
ModalBody.propTypes = (_ModalBody$propTypes = {}, _rollupPluginBabelHelpers.defineProperty(_ModalBody$propTypes, 'aria-label', requiredIfGivenPropIsTruthy["default"]('hasScrollingContent', PropTypes__default["default"].string)), _rollupPluginBabelHelpers.defineProperty(_ModalBody$propTypes, "children", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_ModalBody$propTypes, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ModalBody$propTypes, "hasForm", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ModalBody$propTypes, "hasScrollingContent", PropTypes__default["default"].bool), _ModalBody$propTypes);
|
|
447
|
-
var
|
|
448
|
-
|
|
57
|
+
var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function ComposedModal(_ref2, ref) {
|
|
58
|
+
var _cx2, _cx3;
|
|
59
|
+
|
|
60
|
+
var ariaLabelledBy = _ref2['aria-labelledby'],
|
|
61
|
+
ariaLabel = _ref2['aria-label'],
|
|
62
|
+
children = _ref2.children,
|
|
63
|
+
customClassName = _ref2.className,
|
|
64
|
+
containerClassName = _ref2.containerClassName,
|
|
65
|
+
danger = _ref2.danger,
|
|
66
|
+
onClose = _ref2.onClose,
|
|
67
|
+
onKeyDown = _ref2.onKeyDown,
|
|
68
|
+
open = _ref2.open,
|
|
69
|
+
preventCloseOnClickOutside = _ref2.preventCloseOnClickOutside,
|
|
70
|
+
selectorPrimaryFocus = _ref2.selectorPrimaryFocus,
|
|
71
|
+
selectorsFloatingMenus = _ref2.selectorsFloatingMenus,
|
|
72
|
+
size = _ref2.size,
|
|
73
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
|
|
449
74
|
|
|
450
|
-
var
|
|
75
|
+
var prefix = usePrefix.usePrefix();
|
|
76
|
+
|
|
77
|
+
var _useState = React.useState(open),
|
|
78
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
79
|
+
isOpen = _useState2[0],
|
|
80
|
+
setisOpen = _useState2[1];
|
|
451
81
|
|
|
452
|
-
|
|
453
|
-
|
|
82
|
+
var _useState3 = React.useState(open),
|
|
83
|
+
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
84
|
+
prevOpen = _useState4[0],
|
|
85
|
+
setPrevOpen = _useState4[1];
|
|
454
86
|
|
|
455
|
-
|
|
87
|
+
var innerModal = React.useRef();
|
|
88
|
+
var button = React.useRef();
|
|
89
|
+
var startSentinel = React.useRef();
|
|
90
|
+
var endSentinel = React.useRef();
|
|
91
|
+
|
|
92
|
+
if (open !== prevOpen) {
|
|
93
|
+
setisOpen(open);
|
|
94
|
+
setPrevOpen(open);
|
|
95
|
+
}
|
|
456
96
|
|
|
457
|
-
|
|
458
|
-
|
|
97
|
+
function handleKeyDown(evt) {
|
|
98
|
+
// Esc key
|
|
99
|
+
if (evt.which === 27) {
|
|
100
|
+
closeModal(evt);
|
|
459
101
|
}
|
|
460
102
|
|
|
461
|
-
|
|
103
|
+
onKeyDown(evt);
|
|
104
|
+
}
|
|
462
105
|
|
|
463
|
-
|
|
464
|
-
|
|
106
|
+
function handleClick(evt) {
|
|
107
|
+
if (!innerModal.current.contains(evt.target) && preventCloseOnClickOutside) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
465
110
|
|
|
466
|
-
|
|
467
|
-
|
|
111
|
+
if (innerModal.current && !innerModal.current.contains(evt.target)) {
|
|
112
|
+
closeModal(evt);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
468
115
|
|
|
469
|
-
|
|
116
|
+
function handleBlur(_ref3) {
|
|
117
|
+
var oldActiveNode = _ref3.target,
|
|
118
|
+
currentActiveNode = _ref3.relatedTarget;
|
|
119
|
+
|
|
120
|
+
if (open && currentActiveNode && oldActiveNode) {
|
|
121
|
+
var bodyNode = innerModal.current;
|
|
122
|
+
var startSentinelNode = startSentinel.current;
|
|
123
|
+
var endSentinelNode = endSentinel.current;
|
|
124
|
+
wrapFocus["default"]({
|
|
125
|
+
bodyNode: bodyNode,
|
|
126
|
+
startSentinelNode: startSentinelNode,
|
|
127
|
+
endSentinelNode: endSentinelNode,
|
|
128
|
+
currentActiveNode: currentActiveNode,
|
|
129
|
+
oldActiveNode: oldActiveNode,
|
|
130
|
+
selectorsFloatingMenus: selectorsFloatingMenus
|
|
131
|
+
});
|
|
132
|
+
}
|
|
470
133
|
}
|
|
471
134
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
var _this$props4 = this.props,
|
|
479
|
-
className = _this$props4.className,
|
|
480
|
-
primaryClassName = _this$props4.primaryClassName,
|
|
481
|
-
secondaryButtons = _this$props4.secondaryButtons,
|
|
482
|
-
secondaryClassName = _this$props4.secondaryClassName,
|
|
483
|
-
secondaryButtonText = _this$props4.secondaryButtonText,
|
|
484
|
-
primaryButtonText = _this$props4.primaryButtonText,
|
|
485
|
-
primaryButtonDisabled = _this$props4.primaryButtonDisabled;
|
|
486
|
-
_this$props4.closeModal;
|
|
487
|
-
_this$props4.onRequestClose;
|
|
488
|
-
var onRequestSubmit = _this$props4.onRequestSubmit,
|
|
489
|
-
children = _this$props4.children,
|
|
490
|
-
danger = _this$props4.danger,
|
|
491
|
-
inputref = _this$props4.inputref,
|
|
492
|
-
forwardedRef = _this$props4.forwardedRef,
|
|
493
|
-
other = _rollupPluginBabelHelpers.objectWithoutProperties(_this$props4, _excluded4);
|
|
494
|
-
|
|
495
|
-
var prefix = this.context;
|
|
496
|
-
var footerClass = cx__default["default"]((_classNames9 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames9, "".concat(prefix, "--modal-footer"), true), _rollupPluginBabelHelpers.defineProperty(_classNames9, className, className), _rollupPluginBabelHelpers.defineProperty(_classNames9, "".concat(prefix, "--modal-footer--three-button"), Array.isArray(secondaryButtons) && secondaryButtons.length === 2), _classNames9));
|
|
497
|
-
var primaryClass = cx__default["default"](_rollupPluginBabelHelpers.defineProperty({}, primaryClassName, primaryClassName));
|
|
498
|
-
var secondaryClass = cx__default["default"](_rollupPluginBabelHelpers.defineProperty({}, secondaryClassName, secondaryClassName));
|
|
499
|
-
|
|
500
|
-
var SecondaryButtonSet = function SecondaryButtonSet() {
|
|
501
|
-
if (Array.isArray(secondaryButtons) && secondaryButtons.length <= 2) {
|
|
502
|
-
return secondaryButtons.map(function (_ref3, i) {
|
|
503
|
-
var buttonText = _ref3.buttonText,
|
|
504
|
-
onButtonClick = _ref3.onClick;
|
|
505
|
-
return /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
506
|
-
key: "".concat(buttonText, "-").concat(i),
|
|
507
|
-
className: secondaryClass,
|
|
508
|
-
kind: "secondary",
|
|
509
|
-
onClick: onButtonClick || _this5.handleRequestClose
|
|
510
|
-
}, buttonText);
|
|
511
|
-
});
|
|
512
|
-
}
|
|
135
|
+
function closeModal(evt) {
|
|
136
|
+
if (!onClose || onClose(evt) !== false) {
|
|
137
|
+
setisOpen(false);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
513
140
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
className: secondaryClass,
|
|
517
|
-
onClick: _this5.handleRequestClose,
|
|
518
|
-
kind: "secondary"
|
|
519
|
-
}, secondaryButtonText);
|
|
520
|
-
}
|
|
141
|
+
var modalClass = cx__default["default"]((_cx2 = {}, _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--modal"), true), _rollupPluginBabelHelpers.defineProperty(_cx2, 'is-visible', isOpen), _rollupPluginBabelHelpers.defineProperty(_cx2, customClassName, customClassName), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--modal--danger"), danger), _cx2));
|
|
142
|
+
var containerClass = cx__default["default"]((_cx3 = {}, _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--modal-container"), true), _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--modal-container--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx3, containerClassName, containerClassName), _cx3)); // Generate aria-label based on Modal Header label if one is not provided (L253)
|
|
521
143
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
onClick: onRequestSubmit,
|
|
531
|
-
className: primaryClass,
|
|
532
|
-
disabled: primaryButtonDisabled,
|
|
533
|
-
kind: danger ? 'danger' : 'primary',
|
|
534
|
-
ref: inputref
|
|
535
|
-
}, primaryButtonText), children);
|
|
536
|
-
}
|
|
537
|
-
}]);
|
|
538
|
-
|
|
539
|
-
return ModalFooter;
|
|
540
|
-
}(React.Component);
|
|
541
|
-
|
|
542
|
-
_rollupPluginBabelHelpers.defineProperty(ModalFooter, "propTypes", {
|
|
543
|
-
/**
|
|
544
|
-
* Pass in content that will be rendered in the Modal Footer
|
|
545
|
-
*/
|
|
546
|
-
children: PropTypes__default["default"].node,
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Specify a custom className to be applied to the Modal Footer container
|
|
550
|
-
*/
|
|
551
|
-
className: PropTypes__default["default"].string,
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Specify an optional function that is called whenever the modal is closed
|
|
555
|
-
*/
|
|
556
|
-
closeModal: PropTypes__default["default"].func,
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Specify whether the primary button should be replaced with danger button.
|
|
560
|
-
* Note that this prop is not applied if you render primary/danger button by yourself
|
|
561
|
-
*/
|
|
562
|
-
danger: PropTypes__default["default"].bool,
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* The `ref` callback for the primary button.
|
|
566
|
-
*/
|
|
567
|
-
inputref: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].shape({
|
|
568
|
-
current: PropTypes__default["default"].any
|
|
569
|
-
})]),
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Specify an optional function for when the modal is requesting to be
|
|
573
|
-
* closed
|
|
574
|
-
*/
|
|
575
|
-
onRequestClose: PropTypes__default["default"].func,
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Specify an optional function for when the modal is requesting to be
|
|
579
|
-
* submitted
|
|
580
|
-
*/
|
|
581
|
-
onRequestSubmit: PropTypes__default["default"].func,
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* Specify whether the primary button should be disabled
|
|
585
|
-
*/
|
|
586
|
-
primaryButtonDisabled: PropTypes__default["default"].bool,
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* Specify the text for the primary button
|
|
590
|
-
*/
|
|
591
|
-
primaryButtonText: PropTypes__default["default"].string,
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Specify a custom className to be applied to the primary button
|
|
595
|
-
*/
|
|
596
|
-
primaryClassName: PropTypes__default["default"].string,
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Specify the text for the secondary button
|
|
600
|
-
*/
|
|
601
|
-
secondaryButtonText: PropTypes__default["default"].string,
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Specify an array of config objects for secondary buttons
|
|
605
|
-
* (`Array<{
|
|
606
|
-
* buttonText: string,
|
|
607
|
-
* onClick: function,
|
|
608
|
-
* }>`).
|
|
609
|
-
*/
|
|
610
|
-
secondaryButtons: function secondaryButtons(props, propName, componentName) {
|
|
611
|
-
if (props.secondaryButtons) {
|
|
612
|
-
if (!Array.isArray(props.secondaryButtons) || props.secondaryButtons.length !== 2) {
|
|
613
|
-
return new Error("".concat(propName, " needs to be an array of two button config objects"));
|
|
614
|
-
}
|
|
144
|
+
var generatedAriaLabel;
|
|
145
|
+
var childrenWithProps = React__default["default"].Children.toArray(children).map(function (child) {
|
|
146
|
+
switch (child.type) {
|
|
147
|
+
case React__default["default"].createElement(ModalHeader.ModalHeader).type:
|
|
148
|
+
generatedAriaLabel = child.props.label;
|
|
149
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
150
|
+
closeModal: closeModal
|
|
151
|
+
});
|
|
615
152
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
153
|
+
case React__default["default"].createElement(ModalFooter.ModalFooter).type:
|
|
154
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
155
|
+
closeModal: closeModal,
|
|
156
|
+
inputref: button
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
default:
|
|
160
|
+
return child;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
React.useEffect(function () {
|
|
164
|
+
if (prevOpen !== isOpen) {
|
|
165
|
+
toggleClass["default"](document.body, "".concat(prefix, "--body--with-modal-open"), isOpen);
|
|
623
166
|
}
|
|
167
|
+
});
|
|
168
|
+
React.useEffect(function () {
|
|
169
|
+
return function () {
|
|
170
|
+
return toggleClass["default"](document.body, "".concat(prefix, "--body--with-modal-open"), false);
|
|
171
|
+
};
|
|
172
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
173
|
+
|
|
174
|
+
React.useEffect(function () {
|
|
175
|
+
toggleClass["default"](document.body, "".concat(prefix, "--body--with-modal-open"), open);
|
|
176
|
+
}, [open, prefix]);
|
|
177
|
+
React.useEffect(function () {
|
|
178
|
+
var focusButton = function focusButton(focusContainerElement) {
|
|
179
|
+
if (focusContainerElement) {
|
|
180
|
+
var primaryFocusElement = focusContainerElement.querySelector(selectorPrimaryFocus);
|
|
624
181
|
|
|
625
|
-
|
|
626
|
-
|
|
182
|
+
if (primaryFocusElement) {
|
|
183
|
+
primaryFocusElement.focus();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
627
186
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
187
|
+
if (button.current) {
|
|
188
|
+
button.current.focus();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
633
192
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
});
|
|
193
|
+
if (!open) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
638
196
|
|
|
639
|
-
|
|
197
|
+
if (innerModal.current) {
|
|
198
|
+
focusButton(innerModal.current);
|
|
199
|
+
}
|
|
200
|
+
}, [open, selectorPrimaryFocus]);
|
|
201
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
202
|
+
role: "presentation",
|
|
203
|
+
ref: ref,
|
|
204
|
+
"aria-hidden": !open,
|
|
205
|
+
onBlur: handleBlur,
|
|
206
|
+
onClick: handleClick,
|
|
207
|
+
onKeyDown: handleKeyDown,
|
|
208
|
+
className: modalClass,
|
|
209
|
+
tabIndex: "-1"
|
|
210
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
211
|
+
className: containerClass,
|
|
212
|
+
role: "dialog",
|
|
213
|
+
"aria-modal": "true",
|
|
214
|
+
"aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
|
|
215
|
+
"aria-labelledby": ariaLabelledBy
|
|
216
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
ref: startSentinel,
|
|
219
|
+
className: "".concat(prefix, "--visually-hidden")
|
|
220
|
+
}, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
221
|
+
ref: innerModal,
|
|
222
|
+
className: "".concat(prefix, "--modal-container-body")
|
|
223
|
+
}, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
224
|
+
type: "button",
|
|
225
|
+
ref: endSentinel,
|
|
226
|
+
className: "".concat(prefix, "--visually-hidden")
|
|
227
|
+
}, "Focus sentinel")));
|
|
228
|
+
});
|
|
229
|
+
ComposedModal.propTypes = (_ComposedModal$propTy = {}, _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, 'aria-label', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, 'aria-labelledby', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "children", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "containerClassName", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "danger", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "onClose", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "onKeyDown", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "open", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "preventCloseOnClickOutside", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "selectorPrimaryFocus", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "selectorsFloatingMenus", PropTypes__default["default"].arrayOf(PropTypes__default["default"].string)), _rollupPluginBabelHelpers.defineProperty(_ComposedModal$propTy, "size", PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])), _ComposedModal$propTy);
|
|
230
|
+
ComposedModal.defaultProps = {
|
|
231
|
+
onKeyDown: function onKeyDown() {},
|
|
232
|
+
selectorPrimaryFocus: '[data-modal-primary-focus]'
|
|
233
|
+
};
|
|
234
|
+
var ComposedModal$1 = ComposedModal;
|
|
640
235
|
|
|
641
236
|
exports.ModalBody = ModalBody;
|
|
642
|
-
exports
|
|
643
|
-
exports.ModalHeader = ModalHeader;
|
|
644
|
-
exports["default"] = ComposedModal;
|
|
237
|
+
exports["default"] = ComposedModal$1;
|