@zendeskgarden/react-modals 8.62.1 → 8.63.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/dist/index.cjs.js +220 -134
- package/dist/index.esm.js +125 -36
- package/dist/typings/types/index.d.ts +1 -1
- package/dist/typings/utils/useModalContext.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
10
|
var React = require('react');
|
|
13
11
|
var ReactDOM = require('react-dom');
|
|
14
12
|
var styled = require('styled-components');
|
|
@@ -20,7 +18,7 @@ var mergeRefs = require('react-merge-refs');
|
|
|
20
18
|
var reactPopper = require('react-popper');
|
|
21
19
|
var reactTransitionGroup = require('react-transition-group');
|
|
22
20
|
|
|
23
|
-
function
|
|
21
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
22
|
|
|
25
23
|
function _interopNamespace(e) {
|
|
26
24
|
if (e && e.__esModule) return e;
|
|
@@ -36,16 +34,15 @@ function _interopNamespace(e) {
|
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
|
-
n
|
|
37
|
+
n.default = e;
|
|
40
38
|
return Object.freeze(n);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
42
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
43
|
+
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
44
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
45
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
49
46
|
|
|
50
47
|
function _extends$2() {
|
|
51
48
|
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -144,9 +141,9 @@ function scrollbarSize(recalc) {
|
|
|
144
141
|
|
|
145
142
|
const COMPONENT_ID$j = 'modals.backdrop';
|
|
146
143
|
const animationName$1 = styled.keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
147
|
-
const StyledBackdrop = styled__default
|
|
144
|
+
const StyledBackdrop = styled__default.default.div.attrs({
|
|
148
145
|
'data-garden-id': COMPONENT_ID$j,
|
|
149
|
-
'data-garden-version': '8.
|
|
146
|
+
'data-garden-version': '8.63.0'
|
|
150
147
|
}).withConfig({
|
|
151
148
|
displayName: "StyledBackdrop",
|
|
152
149
|
componentId: "sc-mzdjpo-0"
|
|
@@ -155,14 +152,14 @@ StyledBackdrop.defaultProps = {
|
|
|
155
152
|
theme: reactTheming.DEFAULT_THEME
|
|
156
153
|
};
|
|
157
154
|
StyledBackdrop.propTypes = {
|
|
158
|
-
isCentered: PropTypes__default
|
|
159
|
-
isAnimated: PropTypes__default
|
|
155
|
+
isCentered: PropTypes__default.default.bool,
|
|
156
|
+
isAnimated: PropTypes__default.default.bool
|
|
160
157
|
};
|
|
161
158
|
|
|
162
159
|
const COMPONENT_ID$i = 'modals.body';
|
|
163
|
-
const StyledBody = styled__default
|
|
160
|
+
const StyledBody = styled__default.default.div.attrs({
|
|
164
161
|
'data-garden-id': COMPONENT_ID$i,
|
|
165
|
-
'data-garden-version': '8.
|
|
162
|
+
'data-garden-version': '8.63.0'
|
|
166
163
|
}).withConfig({
|
|
167
164
|
displayName: "StyledBody",
|
|
168
165
|
componentId: "sc-14rzecg-0"
|
|
@@ -182,9 +179,9 @@ const BASE_MULTIPLIERS$1 = {
|
|
|
182
179
|
side: 6.5,
|
|
183
180
|
size: 10
|
|
184
181
|
};
|
|
185
|
-
const StyledClose = styled__default
|
|
182
|
+
const StyledClose = styled__default.default.button.attrs({
|
|
186
183
|
'data-garden-id': COMPONENT_ID$h,
|
|
187
|
-
'data-garden-version': '8.
|
|
184
|
+
'data-garden-version': '8.63.0'
|
|
188
185
|
}).withConfig({
|
|
189
186
|
displayName: "StyledClose",
|
|
190
187
|
componentId: "sc-iseudj-0"
|
|
@@ -194,9 +191,9 @@ StyledClose.defaultProps = {
|
|
|
194
191
|
};
|
|
195
192
|
|
|
196
193
|
const COMPONENT_ID$g = 'modals.footer';
|
|
197
|
-
const StyledFooter = styled__default
|
|
194
|
+
const StyledFooter = styled__default.default.div.attrs({
|
|
198
195
|
'data-garden-id': COMPONENT_ID$g,
|
|
199
|
-
'data-garden-version': '8.
|
|
196
|
+
'data-garden-version': '8.63.0'
|
|
200
197
|
}).withConfig({
|
|
201
198
|
displayName: "StyledFooter",
|
|
202
199
|
componentId: "sc-d8pfdu-0"
|
|
@@ -206,9 +203,9 @@ StyledFooter.defaultProps = {
|
|
|
206
203
|
};
|
|
207
204
|
|
|
208
205
|
const COMPONENT_ID$f = 'modals.footer_item';
|
|
209
|
-
const StyledFooterItem = styled__default
|
|
206
|
+
const StyledFooterItem = styled__default.default.span.attrs({
|
|
210
207
|
'data-garden-id': COMPONENT_ID$f,
|
|
211
|
-
'data-garden-version': '8.
|
|
208
|
+
'data-garden-version': '8.63.0'
|
|
212
209
|
}).withConfig({
|
|
213
210
|
displayName: "StyledFooterItem",
|
|
214
211
|
componentId: "sc-1mb76hl-0"
|
|
@@ -218,9 +215,9 @@ StyledFooterItem.defaultProps = {
|
|
|
218
215
|
};
|
|
219
216
|
|
|
220
217
|
const COMPONENT_ID$e = 'modals.header';
|
|
221
|
-
const StyledHeader = styled__default
|
|
218
|
+
const StyledHeader = styled__default.default.div.attrs({
|
|
222
219
|
'data-garden-id': COMPONENT_ID$e,
|
|
223
|
-
'data-garden-version': '8.
|
|
220
|
+
'data-garden-version': '8.63.0'
|
|
224
221
|
}).withConfig({
|
|
225
222
|
displayName: "StyledHeader",
|
|
226
223
|
componentId: "sc-1787r9v-0"
|
|
@@ -230,9 +227,7 @@ StyledHeader.defaultProps = {
|
|
|
230
227
|
};
|
|
231
228
|
|
|
232
229
|
var _g, _circle;
|
|
233
|
-
|
|
234
230
|
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : 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$1.apply(this, arguments); }
|
|
235
|
-
|
|
236
231
|
var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
237
232
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
238
233
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -240,8 +235,7 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
|
240
235
|
height: 16,
|
|
241
236
|
focusable: "false",
|
|
242
237
|
viewBox: "0 0 16 16",
|
|
243
|
-
"aria-hidden": "true"
|
|
244
|
-
role: "img"
|
|
238
|
+
"aria-hidden": "true"
|
|
245
239
|
}, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
|
|
246
240
|
fill: "none",
|
|
247
241
|
stroke: "currentColor"
|
|
@@ -260,7 +254,7 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
|
260
254
|
})));
|
|
261
255
|
};
|
|
262
256
|
|
|
263
|
-
const StyledDangerIcon = styled__default
|
|
257
|
+
const StyledDangerIcon = styled__default.default(SvgAlertErrorStroke).withConfig({
|
|
264
258
|
displayName: "StyledDangerIcon",
|
|
265
259
|
componentId: "sc-1kwbb39-0"
|
|
266
260
|
})(["position:absolute;top:", "px;", ":", ";"], props => props.theme.space.base * 5.5, props => props.theme.rtl ? 'right' : 'left', props => `${props.theme.space.base * 4}px`);
|
|
@@ -286,25 +280,25 @@ const boxShadow$1 = props => {
|
|
|
286
280
|
const sizeStyles$1 = props => {
|
|
287
281
|
return styled.css(["", "{width:", ";}"], reactTheming.mediaQuery('up', props.isLarge ? 'md' : 'sm', props.theme), props.isLarge ? props.theme.breakpoints.md : props.theme.breakpoints.sm);
|
|
288
282
|
};
|
|
289
|
-
const StyledModal = styled__default
|
|
283
|
+
const StyledModal = styled__default.default.div.attrs({
|
|
290
284
|
'data-garden-id': COMPONENT_ID$d,
|
|
291
|
-
'data-garden-version': '8.
|
|
285
|
+
'data-garden-version': '8.63.0'
|
|
292
286
|
}).withConfig({
|
|
293
287
|
displayName: "StyledModal",
|
|
294
288
|
componentId: "sc-1pe1axu-0"
|
|
295
289
|
})(["display:flex;position:fixed;flex-direction:column;margin:", ";border-radius:", ";box-shadow:", ";background-color:", ";min-height:60px;max-height:calc(100vh - ", "px);animation:", ";animation-delay:0.01s;overflow:auto;direction:", ";", " &:focus{outline:none;}@media (max-height:399px){top:", "px;bottom:auto;margin-bottom:", "px;max-height:none;}@media screen and (-ms-high-contrast:active),screen and (-ms-high-contrast:none){right:", ";bottom:", ";transform:", ";}", ";"], props => props.isCentered ? '0' : `${props.theme.space.base * 12}px`, props => props.theme.borderRadii.md, boxShadow$1, props => props.theme.colors.background, props => props.theme.space.base * 24, props => props.isAnimated && styled.css(["", " 0.3s ease-in-out"], animationName), props => props.theme.rtl && 'rtl', sizeStyles$1, props => props.theme.space.base * 6, props => props.theme.space.base * 6, props => props.isCentered && '50%', props => props.isCentered && '50%', props => props.isCentered && 'translate(50%, 50%)', props => reactTheming.retrieveComponentStyles(COMPONENT_ID$d, props));
|
|
296
290
|
StyledModal.propTypes = {
|
|
297
|
-
isLarge: PropTypes__default
|
|
298
|
-
isAnimated: PropTypes__default
|
|
291
|
+
isLarge: PropTypes__default.default.bool,
|
|
292
|
+
isAnimated: PropTypes__default.default.bool
|
|
299
293
|
};
|
|
300
294
|
StyledModal.defaultProps = {
|
|
301
295
|
theme: reactTheming.DEFAULT_THEME
|
|
302
296
|
};
|
|
303
297
|
|
|
304
298
|
const COMPONENT_ID$c = 'modals.tooltip_modal.backdrop';
|
|
305
|
-
const StyledTooltipModalBackdrop = styled__default
|
|
299
|
+
const StyledTooltipModalBackdrop = styled__default.default.div.attrs({
|
|
306
300
|
'data-garden-id': COMPONENT_ID$c,
|
|
307
|
-
'data-garden-version': '8.
|
|
301
|
+
'data-garden-version': '8.63.0'
|
|
308
302
|
}).withConfig({
|
|
309
303
|
displayName: "StyledTooltipModalBackdrop",
|
|
310
304
|
componentId: "sc-1yaomgq-0"
|
|
@@ -368,7 +362,7 @@ function getMenuPosition(popperPlacement) {
|
|
|
368
362
|
return popperPlacement ? popperPlacement.split('-')[0] : 'bottom';
|
|
369
363
|
}
|
|
370
364
|
|
|
371
|
-
const StyledTooltipWrapper = styled__default
|
|
365
|
+
const StyledTooltipWrapper = styled__default.default.div.attrs(props => ({
|
|
372
366
|
className: props.isAnimated && 'is-animated'
|
|
373
367
|
})).withConfig({
|
|
374
368
|
displayName: "StyledTooltipWrapper",
|
|
@@ -385,9 +379,9 @@ StyledTooltipWrapper.defaultProps = {
|
|
|
385
379
|
};
|
|
386
380
|
|
|
387
381
|
const COMPONENT_ID$b = 'modals.tooltip_modal';
|
|
388
|
-
const StyledTooltipModal = styled__default
|
|
382
|
+
const StyledTooltipModal = styled__default.default.div.attrs(props => ({
|
|
389
383
|
'data-garden-id': COMPONENT_ID$b,
|
|
390
|
-
'data-garden-version': '8.
|
|
384
|
+
'data-garden-version': '8.63.0',
|
|
391
385
|
className: props.isAnimated && 'is-animated'
|
|
392
386
|
})).withConfig({
|
|
393
387
|
displayName: "StyledTooltipModal",
|
|
@@ -414,9 +408,9 @@ const sizeStyles = props => `
|
|
|
414
408
|
line-height: ${reactTheming.getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md)};
|
|
415
409
|
font-size: ${props.theme.fontSizes.md};
|
|
416
410
|
`;
|
|
417
|
-
const StyledTooltipModalTitle = styled__default
|
|
411
|
+
const StyledTooltipModalTitle = styled__default.default.div.attrs({
|
|
418
412
|
'data-garden-id': COMPONENT_ID$a,
|
|
419
|
-
'data-garden-version': '8.
|
|
413
|
+
'data-garden-version': '8.63.0'
|
|
420
414
|
}).withConfig({
|
|
421
415
|
displayName: "StyledTooltipModalTitle",
|
|
422
416
|
componentId: "sc-11xjgjs-0"
|
|
@@ -426,9 +420,9 @@ StyledTooltipModalTitle.defaultProps = {
|
|
|
426
420
|
};
|
|
427
421
|
|
|
428
422
|
const COMPONENT_ID$9 = 'modals.tooltip_modal.body';
|
|
429
|
-
const StyledTooltipModalBody = styled__default
|
|
423
|
+
const StyledTooltipModalBody = styled__default.default.div.attrs({
|
|
430
424
|
'data-garden-id': COMPONENT_ID$9,
|
|
431
|
-
'data-garden-version': '8.
|
|
425
|
+
'data-garden-version': '8.63.0'
|
|
432
426
|
}).withConfig({
|
|
433
427
|
displayName: "StyledTooltipModalBody",
|
|
434
428
|
componentId: "sc-195dkzj-0"
|
|
@@ -438,9 +432,9 @@ StyledTooltipModalBody.defaultProps = {
|
|
|
438
432
|
};
|
|
439
433
|
|
|
440
434
|
const COMPONENT_ID$8 = 'modals.tooltip_modal.footer';
|
|
441
|
-
const StyledTooltipModalFooter = styled__default
|
|
435
|
+
const StyledTooltipModalFooter = styled__default.default.div.attrs({
|
|
442
436
|
'data-garden-id': COMPONENT_ID$8,
|
|
443
|
-
'data-garden-version': '8.
|
|
437
|
+
'data-garden-version': '8.63.0'
|
|
444
438
|
}).withConfig({
|
|
445
439
|
displayName: "StyledTooltipModalFooter",
|
|
446
440
|
componentId: "sc-fm36a9-0"
|
|
@@ -450,9 +444,9 @@ StyledTooltipModalFooter.defaultProps = {
|
|
|
450
444
|
};
|
|
451
445
|
|
|
452
446
|
const COMPONENT_ID$7 = 'modals.tooltip_modal.footer_item';
|
|
453
|
-
const StyledTooltipModalFooterItem = styled__default
|
|
447
|
+
const StyledTooltipModalFooterItem = styled__default.default(StyledFooterItem).attrs({
|
|
454
448
|
'data-garden-id': COMPONENT_ID$7,
|
|
455
|
-
'data-garden-version': '8.
|
|
449
|
+
'data-garden-version': '8.63.0'
|
|
456
450
|
}).withConfig({
|
|
457
451
|
displayName: "StyledTooltipModalFooterItem",
|
|
458
452
|
componentId: "sc-1nahj6p-0"
|
|
@@ -462,9 +456,9 @@ StyledTooltipModalFooterItem.defaultProps = {
|
|
|
462
456
|
};
|
|
463
457
|
|
|
464
458
|
const COMPONENT_ID$6 = 'modals.tooltip_modal.close';
|
|
465
|
-
const StyledTooltipModalClose = styled__default
|
|
459
|
+
const StyledTooltipModalClose = styled__default.default(StyledClose).attrs({
|
|
466
460
|
'data-garden-id': COMPONENT_ID$6,
|
|
467
|
-
'data-garden-version': '8.
|
|
461
|
+
'data-garden-version': '8.63.0'
|
|
468
462
|
}).withConfig({
|
|
469
463
|
displayName: "StyledTooltipModalClose",
|
|
470
464
|
componentId: "sc-1h2ke3q-0"
|
|
@@ -488,9 +482,9 @@ const boxShadow = props => {
|
|
|
488
482
|
const color = reactTheming.getColor('neutralHue', 800, theme, 0.35);
|
|
489
483
|
return shadows.lg(offsetY, blurRadius, color);
|
|
490
484
|
};
|
|
491
|
-
const StyledDrawerModal = styled__default
|
|
485
|
+
const StyledDrawerModal = styled__default.default.div.attrs({
|
|
492
486
|
'data-garden-id': COMPONENT_ID$5,
|
|
493
|
-
'data-garden-version': '8.
|
|
487
|
+
'data-garden-version': '8.63.0'
|
|
494
488
|
}).withConfig({
|
|
495
489
|
displayName: "StyledDrawerModal",
|
|
496
490
|
componentId: "sc-i1sake-0"
|
|
@@ -505,9 +499,9 @@ const BASE_MULTIPLIERS = {
|
|
|
505
499
|
side: 2,
|
|
506
500
|
size: BASE_MULTIPLIERS$1.size
|
|
507
501
|
};
|
|
508
|
-
const StyledDrawerModalClose = styled__default
|
|
502
|
+
const StyledDrawerModalClose = styled__default.default(StyledClose).attrs({
|
|
509
503
|
'data-garden-id': COMPONENT_ID$4,
|
|
510
|
-
'data-garden-version': '8.
|
|
504
|
+
'data-garden-version': '8.63.0'
|
|
511
505
|
}).withConfig({
|
|
512
506
|
displayName: "StyledDrawerModalClose",
|
|
513
507
|
componentId: "sc-hrnaom-0"
|
|
@@ -517,9 +511,9 @@ StyledDrawerModalClose.defaultProps = {
|
|
|
517
511
|
};
|
|
518
512
|
|
|
519
513
|
const COMPONENT_ID$3 = 'modals.drawer_modal.header';
|
|
520
|
-
const StyledDrawerModalHeader = styled__default
|
|
514
|
+
const StyledDrawerModalHeader = styled__default.default(StyledHeader).attrs({
|
|
521
515
|
'data-garden-id': COMPONENT_ID$3,
|
|
522
|
-
'data-garden-version': '8.
|
|
516
|
+
'data-garden-version': '8.63.0'
|
|
523
517
|
}).withConfig({
|
|
524
518
|
displayName: "StyledDrawerModalHeader",
|
|
525
519
|
componentId: "sc-1u04rqw-0"
|
|
@@ -529,9 +523,9 @@ StyledDrawerModalHeader.defaultProps = {
|
|
|
529
523
|
};
|
|
530
524
|
|
|
531
525
|
const COMPONENT_ID$2 = 'modals.drawer_modal.body';
|
|
532
|
-
const StyledDrawerModalBody = styled__default
|
|
526
|
+
const StyledDrawerModalBody = styled__default.default(StyledBody).attrs({
|
|
533
527
|
'data-garden-id': COMPONENT_ID$2,
|
|
534
|
-
'data-garden-version': '8.
|
|
528
|
+
'data-garden-version': '8.63.0'
|
|
535
529
|
}).withConfig({
|
|
536
530
|
displayName: "StyledDrawerModalBody",
|
|
537
531
|
componentId: "sc-yafe2y-0"
|
|
@@ -541,9 +535,9 @@ StyledDrawerModalBody.defaultProps = {
|
|
|
541
535
|
};
|
|
542
536
|
|
|
543
537
|
const COMPONENT_ID$1 = 'modals.drawer_modal.footer';
|
|
544
|
-
const StyledDrawerModalFooter = styled__default
|
|
538
|
+
const StyledDrawerModalFooter = styled__default.default.div.attrs({
|
|
545
539
|
'data-garden-id': COMPONENT_ID$1,
|
|
546
|
-
'data-garden-version': '8.
|
|
540
|
+
'data-garden-version': '8.63.0'
|
|
547
541
|
}).withConfig({
|
|
548
542
|
displayName: "StyledDrawerModalFooter",
|
|
549
543
|
componentId: "sc-17if4ka-0"
|
|
@@ -553,9 +547,9 @@ StyledDrawerModalFooter.defaultProps = {
|
|
|
553
547
|
};
|
|
554
548
|
|
|
555
549
|
const COMPONENT_ID = 'modals.drawer_modal.footer_item';
|
|
556
|
-
const StyledDrawerModalFooterItem = styled__default
|
|
550
|
+
const StyledDrawerModalFooterItem = styled__default.default(StyledFooterItem).attrs({
|
|
557
551
|
'data-garden-id': COMPONENT_ID,
|
|
558
|
-
'data-garden-version': '8.
|
|
552
|
+
'data-garden-version': '8.63.0'
|
|
559
553
|
}).withConfig({
|
|
560
554
|
displayName: "StyledDrawerModalFooterItem",
|
|
561
555
|
componentId: "sc-1vbl885-0"
|
|
@@ -603,6 +597,7 @@ const Modal = React.forwardRef((_ref, ref) => {
|
|
|
603
597
|
const modalRef = React.useRef(null);
|
|
604
598
|
const environment = reactTheming.useDocument(theme);
|
|
605
599
|
const [isCloseButtonPresent, setIsCloseButtonPresent] = React.useState(false);
|
|
600
|
+
const [hasHeader, setHasHeader] = React.useState(false);
|
|
606
601
|
const {
|
|
607
602
|
getBackdropProps,
|
|
608
603
|
getModalProps,
|
|
@@ -660,37 +655,53 @@ const Modal = React.forwardRef((_ref, ref) => {
|
|
|
660
655
|
const value = React.useMemo(() => ({
|
|
661
656
|
isLarge,
|
|
662
657
|
isCloseButtonPresent,
|
|
658
|
+
hasHeader,
|
|
659
|
+
setHasHeader,
|
|
663
660
|
getTitleProps,
|
|
664
661
|
getContentProps,
|
|
665
662
|
getCloseProps,
|
|
666
663
|
setIsCloseButtonPresent
|
|
667
|
-
}), [isLarge, isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
664
|
+
}), [isLarge, hasHeader, isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
665
|
+
const modalContainerProps = getModalProps({
|
|
666
|
+
'aria-describedby': undefined,
|
|
667
|
+
...(hasHeader ? {} : {
|
|
668
|
+
'aria-labelledby': undefined
|
|
669
|
+
})
|
|
670
|
+
});
|
|
671
|
+
const attribute = hasHeader ? 'aria-labelledby' : 'aria-label';
|
|
672
|
+
const defaultValue = hasHeader ? modalContainerProps['aria-labelledby'] : 'Modal dialog';
|
|
673
|
+
const labelValue = hasHeader ? modalContainerProps['aria-labelledby'] : modalProps['aria-label'];
|
|
674
|
+
const ariaProps = {
|
|
675
|
+
[attribute]: reactTheming.useText(Modal, {
|
|
676
|
+
[attribute]: labelValue
|
|
677
|
+
}, attribute, defaultValue)
|
|
678
|
+
};
|
|
668
679
|
if (!rootNode) {
|
|
669
680
|
return null;
|
|
670
681
|
}
|
|
671
|
-
return ReactDOM.createPortal(
|
|
682
|
+
return ReactDOM.createPortal( React__namespace.default.createElement(ModalsContext.Provider, {
|
|
672
683
|
value: value
|
|
673
|
-
},
|
|
684
|
+
}, React__namespace.default.createElement(StyledBackdrop, _extends$2({
|
|
674
685
|
isCentered: isCentered,
|
|
675
686
|
isAnimated: isAnimated
|
|
676
|
-
}, getBackdropProps(backdropProps)),
|
|
687
|
+
}, getBackdropProps(backdropProps)), React__namespace.default.createElement(StyledModal, _extends$2({
|
|
677
688
|
isCentered: isCentered,
|
|
678
689
|
isAnimated: isAnimated,
|
|
679
690
|
isLarge: isLarge
|
|
680
|
-
},
|
|
681
|
-
ref: mergeRefs__default
|
|
691
|
+
}, modalContainerProps, ariaProps, modalProps, {
|
|
692
|
+
ref: mergeRefs__default.default([ref, modalRef])
|
|
682
693
|
}), children))), rootNode);
|
|
683
694
|
});
|
|
684
695
|
Modal.displayName = 'Modal';
|
|
685
696
|
Modal.propTypes = {
|
|
686
|
-
backdropProps: PropTypes__default
|
|
687
|
-
isLarge: PropTypes__default
|
|
688
|
-
isAnimated: PropTypes__default
|
|
689
|
-
isCentered: PropTypes__default
|
|
690
|
-
focusOnMount: PropTypes__default
|
|
691
|
-
restoreFocus: PropTypes__default
|
|
692
|
-
onClose: PropTypes__default
|
|
693
|
-
appendToNode: PropTypes__default
|
|
697
|
+
backdropProps: PropTypes__default.default.object,
|
|
698
|
+
isLarge: PropTypes__default.default.bool,
|
|
699
|
+
isAnimated: PropTypes__default.default.bool,
|
|
700
|
+
isCentered: PropTypes__default.default.bool,
|
|
701
|
+
focusOnMount: PropTypes__default.default.bool,
|
|
702
|
+
restoreFocus: PropTypes__default.default.bool,
|
|
703
|
+
onClose: PropTypes__default.default.func,
|
|
704
|
+
appendToNode: PropTypes__default.default.any
|
|
694
705
|
};
|
|
695
706
|
Modal.defaultProps = {
|
|
696
707
|
isAnimated: true,
|
|
@@ -701,16 +712,14 @@ const Body$2 = React.forwardRef((props, ref) => {
|
|
|
701
712
|
const {
|
|
702
713
|
getContentProps
|
|
703
714
|
} = useModalContext();
|
|
704
|
-
return
|
|
715
|
+
return React__namespace.default.createElement(StyledBody, _extends$2({}, getContentProps(props), {
|
|
705
716
|
ref: ref
|
|
706
717
|
}));
|
|
707
718
|
});
|
|
708
719
|
Body$2.displayName = 'Body';
|
|
709
720
|
|
|
710
721
|
var _path;
|
|
711
|
-
|
|
712
722
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
713
|
-
|
|
714
723
|
var SvgXStroke = function SvgXStroke(props) {
|
|
715
724
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
716
725
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -718,8 +727,7 @@ var SvgXStroke = function SvgXStroke(props) {
|
|
|
718
727
|
height: 16,
|
|
719
728
|
focusable: "false",
|
|
720
729
|
viewBox: "0 0 16 16",
|
|
721
|
-
"aria-hidden": "true"
|
|
722
|
-
role: "img"
|
|
730
|
+
"aria-hidden": "true"
|
|
723
731
|
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
724
732
|
stroke: "currentColor",
|
|
725
733
|
strokeLinecap: "round",
|
|
@@ -737,27 +745,27 @@ const Close$2 = React.forwardRef((props, ref) => {
|
|
|
737
745
|
return () => setIsCloseButtonPresent(false);
|
|
738
746
|
});
|
|
739
747
|
const ariaLabel = reactTheming.useText(Close$2, props, 'aria-label', 'Close modal');
|
|
740
|
-
return
|
|
748
|
+
return React__namespace.default.createElement(StyledClose, _extends$2({}, getCloseProps({
|
|
741
749
|
...props,
|
|
742
750
|
'aria-label': ariaLabel
|
|
743
751
|
}), {
|
|
744
752
|
ref: ref
|
|
745
|
-
}),
|
|
753
|
+
}), React__namespace.default.createElement(SvgXStroke, null));
|
|
746
754
|
});
|
|
747
755
|
Close$2.displayName = 'Close';
|
|
748
756
|
|
|
749
|
-
const Footer$2 =
|
|
757
|
+
const Footer$2 = React__namespace.default.forwardRef((props, ref) => {
|
|
750
758
|
const {
|
|
751
759
|
isLarge
|
|
752
760
|
} = useModalContext();
|
|
753
|
-
return
|
|
761
|
+
return React__namespace.default.createElement(StyledFooter, _extends$2({
|
|
754
762
|
ref: ref,
|
|
755
763
|
isLarge: isLarge
|
|
756
764
|
}, props));
|
|
757
765
|
});
|
|
758
766
|
Footer$2.displayName = 'Footer';
|
|
759
767
|
|
|
760
|
-
const FooterItem$2 =
|
|
768
|
+
const FooterItem$2 = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(StyledFooterItem, _extends$2({
|
|
761
769
|
ref: ref
|
|
762
770
|
}, props)));
|
|
763
771
|
FooterItem$2.displayName = 'FooterItem';
|
|
@@ -770,18 +778,30 @@ const Header$1 = React.forwardRef((_ref, ref) => {
|
|
|
770
778
|
} = _ref;
|
|
771
779
|
const {
|
|
772
780
|
isCloseButtonPresent,
|
|
781
|
+
hasHeader,
|
|
782
|
+
setHasHeader,
|
|
773
783
|
getTitleProps
|
|
774
784
|
} = useModalContext();
|
|
775
|
-
|
|
785
|
+
React.useEffect(() => {
|
|
786
|
+
if (!hasHeader && setHasHeader) {
|
|
787
|
+
setHasHeader(true);
|
|
788
|
+
}
|
|
789
|
+
return () => {
|
|
790
|
+
if (hasHeader && setHasHeader) {
|
|
791
|
+
setHasHeader(false);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
}, [hasHeader, setHasHeader]);
|
|
795
|
+
return React__namespace.default.createElement(StyledHeader, _extends$2({}, getTitleProps(other), {
|
|
776
796
|
as: tag,
|
|
777
797
|
isCloseButtonPresent: isCloseButtonPresent,
|
|
778
798
|
ref: ref
|
|
779
|
-
}), other.isDanger &&
|
|
799
|
+
}), other.isDanger && React__namespace.default.createElement(StyledDangerIcon, null), children);
|
|
780
800
|
});
|
|
781
801
|
Header$1.displayName = 'Header';
|
|
782
802
|
Header$1.propTypes = {
|
|
783
|
-
isDanger: PropTypes__default
|
|
784
|
-
tag: PropTypes__default
|
|
803
|
+
isDanger: PropTypes__default.default.bool,
|
|
804
|
+
tag: PropTypes__default.default.any
|
|
785
805
|
};
|
|
786
806
|
Header$1.defaultProps = {
|
|
787
807
|
tag: 'div'
|
|
@@ -817,14 +837,14 @@ const TitleComponent = React.forwardRef((_ref, ref) => {
|
|
|
817
837
|
}
|
|
818
838
|
};
|
|
819
839
|
}, [hasTitle, setHasTitle]);
|
|
820
|
-
return
|
|
840
|
+
return React__namespace.default.createElement(StyledTooltipModalTitle, _extends$2({}, getTitleProps(other), {
|
|
821
841
|
as: tag,
|
|
822
842
|
ref: ref
|
|
823
843
|
}), children);
|
|
824
844
|
});
|
|
825
845
|
TitleComponent.displayName = 'TooltipModal.Title';
|
|
826
846
|
TitleComponent.propTypes = {
|
|
827
|
-
tag: PropTypes__default
|
|
847
|
+
tag: PropTypes__default.default.any
|
|
828
848
|
};
|
|
829
849
|
TitleComponent.defaultProps = {
|
|
830
850
|
tag: 'div'
|
|
@@ -835,7 +855,7 @@ const BodyComponent$1 = React.forwardRef((props, ref) => {
|
|
|
835
855
|
const {
|
|
836
856
|
getContentProps
|
|
837
857
|
} = useTooltipModalContext();
|
|
838
|
-
return
|
|
858
|
+
return React__namespace.default.createElement(StyledTooltipModalBody, _extends$2({}, getContentProps(props), {
|
|
839
859
|
ref: ref
|
|
840
860
|
}));
|
|
841
861
|
});
|
|
@@ -847,29 +867,29 @@ const CloseComponent$1 = React.forwardRef((props, ref) => {
|
|
|
847
867
|
getCloseProps
|
|
848
868
|
} = useTooltipModalContext();
|
|
849
869
|
const ariaLabel = reactTheming.useText(CloseComponent$1, props, 'aria-label', 'Close tooltip');
|
|
850
|
-
return
|
|
870
|
+
return React__namespace.default.createElement(StyledTooltipModalClose, _extends$2({}, getCloseProps({
|
|
851
871
|
...props,
|
|
852
872
|
'aria-label': ariaLabel
|
|
853
873
|
}), {
|
|
854
874
|
ref: ref
|
|
855
|
-
}),
|
|
875
|
+
}), React__namespace.default.createElement(SvgXStroke, null));
|
|
856
876
|
});
|
|
857
877
|
CloseComponent$1.displayName = 'TooltipModal.Close';
|
|
858
878
|
const Close$1 = CloseComponent$1;
|
|
859
879
|
|
|
860
|
-
const FooterComponent$1 = React.forwardRef((props, ref) =>
|
|
880
|
+
const FooterComponent$1 = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledTooltipModalFooter, _extends$2({
|
|
861
881
|
ref: ref
|
|
862
882
|
}, props)));
|
|
863
883
|
FooterComponent$1.displayName = 'TooltipModal.Footer';
|
|
864
884
|
const Footer$1 = FooterComponent$1;
|
|
865
885
|
|
|
866
|
-
const FooterItemComponent$1 = React.forwardRef((props, ref) =>
|
|
886
|
+
const FooterItemComponent$1 = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledTooltipModalFooterItem, _extends$2({
|
|
867
887
|
ref: ref
|
|
868
888
|
}, props)));
|
|
869
889
|
FooterItemComponent$1.displayName = 'TooltipModal.FooterItem';
|
|
870
890
|
const FooterItem$1 = FooterItemComponent$1;
|
|
871
891
|
|
|
872
|
-
const TooltipModalComponent =
|
|
892
|
+
const TooltipModalComponent = React__namespace.default.forwardRef((_ref, ref) => {
|
|
873
893
|
let {
|
|
874
894
|
referenceElement,
|
|
875
895
|
popperModifiers,
|
|
@@ -930,7 +950,7 @@ const TooltipModalComponent = React__default["default"].forwardRef((_ref, ref) =
|
|
|
930
950
|
})
|
|
931
951
|
});
|
|
932
952
|
const attribute = hasTitle ? 'aria-labelledby' : 'aria-label';
|
|
933
|
-
const defaultValue = hasTitle ?
|
|
953
|
+
const defaultValue = hasTitle ? modalProps['aria-labelledby'] : 'Modal dialog';
|
|
934
954
|
const labelValue = hasTitle ? modalProps['aria-labelledby'] : props['aria-label'];
|
|
935
955
|
const ariaProps = {
|
|
936
956
|
[attribute]: reactTheming.useText(TooltipModalComponent, {
|
|
@@ -944,52 +964,51 @@ const TooltipModalComponent = React__default["default"].forwardRef((_ref, ref) =
|
|
|
944
964
|
getContentProps,
|
|
945
965
|
getCloseProps
|
|
946
966
|
};
|
|
947
|
-
return
|
|
967
|
+
return React__namespace.default.createElement(reactTransitionGroup.CSSTransition, {
|
|
948
968
|
unmountOnExit: true,
|
|
949
969
|
timeout: isAnimated ? 200 : 0,
|
|
950
970
|
in: Boolean(referenceElement),
|
|
951
971
|
classNames: isAnimated ? 'garden-tooltip-modal-transition' : '',
|
|
952
972
|
nodeRef: transitionRef
|
|
953
973
|
}, transitionState => {
|
|
954
|
-
return
|
|
974
|
+
return React__namespace.default.createElement(TooltipModalContext.Provider, {
|
|
955
975
|
value: value
|
|
956
|
-
},
|
|
976
|
+
}, React__namespace.default.createElement(StyledTooltipModalBackdrop, _extends$2({}, getBackdropProps(), backdropProps, {
|
|
957
977
|
ref: transitionRef
|
|
958
|
-
}),
|
|
978
|
+
}), React__namespace.default.createElement(StyledTooltipWrapper, _extends$2({
|
|
959
979
|
ref: setPopperElement,
|
|
960
980
|
style: styles.popper,
|
|
961
981
|
placement: state ? state.placement : undefined,
|
|
962
982
|
zIndex: zIndex,
|
|
963
983
|
isAnimated: isAnimated
|
|
964
|
-
}, attributes.popper),
|
|
984
|
+
}, attributes.popper), React__namespace.default.createElement(StyledTooltipModal, _extends$2({
|
|
965
985
|
transitionState: transitionState,
|
|
966
986
|
placement: state ? state.placement : 'top',
|
|
967
987
|
hasArrow: hasArrow,
|
|
968
988
|
isAnimated: isAnimated
|
|
969
989
|
}, modalProps, ariaProps, props, {
|
|
970
|
-
ref: mergeRefs__default
|
|
990
|
+
ref: mergeRefs__default.default([modalRef, ref])
|
|
971
991
|
})))));
|
|
972
992
|
});
|
|
973
993
|
});
|
|
974
994
|
TooltipModalComponent.displayName = 'TooltipModal';
|
|
975
995
|
TooltipModalComponent.defaultProps = {
|
|
976
996
|
placement: 'auto',
|
|
977
|
-
isAnimated: true,
|
|
978
997
|
hasArrow: true,
|
|
979
998
|
focusOnMount: true,
|
|
980
999
|
restoreFocus: true
|
|
981
1000
|
};
|
|
982
1001
|
TooltipModalComponent.propTypes = {
|
|
983
|
-
referenceElement: PropTypes__default
|
|
984
|
-
popperModifiers: PropTypes__default
|
|
985
|
-
placement: PropTypes__default
|
|
986
|
-
isAnimated: PropTypes__default
|
|
987
|
-
hasArrow: PropTypes__default
|
|
988
|
-
zIndex: PropTypes__default
|
|
989
|
-
onClose: PropTypes__default
|
|
990
|
-
backdropProps: PropTypes__default
|
|
991
|
-
focusOnMount: PropTypes__default
|
|
992
|
-
restoreFocus: PropTypes__default
|
|
1002
|
+
referenceElement: PropTypes__default.default.any,
|
|
1003
|
+
popperModifiers: PropTypes__default.default.any,
|
|
1004
|
+
placement: PropTypes__default.default.any,
|
|
1005
|
+
isAnimated: PropTypes__default.default.bool,
|
|
1006
|
+
hasArrow: PropTypes__default.default.bool,
|
|
1007
|
+
zIndex: PropTypes__default.default.number,
|
|
1008
|
+
onClose: PropTypes__default.default.func,
|
|
1009
|
+
backdropProps: PropTypes__default.default.any,
|
|
1010
|
+
focusOnMount: PropTypes__default.default.bool,
|
|
1011
|
+
restoreFocus: PropTypes__default.default.bool
|
|
993
1012
|
};
|
|
994
1013
|
const TooltipModal = TooltipModalComponent;
|
|
995
1014
|
TooltipModal.Body = Body$1;
|
|
@@ -998,6 +1017,19 @@ TooltipModal.Footer = Footer$1;
|
|
|
998
1017
|
TooltipModal.FooterItem = FooterItem$1;
|
|
999
1018
|
TooltipModal.Title = Title;
|
|
1000
1019
|
|
|
1020
|
+
function activeElement(doc) {
|
|
1021
|
+
if (doc === void 0) {
|
|
1022
|
+
doc = ownerDocument();
|
|
1023
|
+
}
|
|
1024
|
+
try {
|
|
1025
|
+
var active = doc.activeElement;
|
|
1026
|
+
if (!active || !active.nodeName) return null;
|
|
1027
|
+
return active;
|
|
1028
|
+
} catch (e) {
|
|
1029
|
+
return doc.body;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1001
1033
|
const HeaderComponent = React.forwardRef((_ref, ref) => {
|
|
1002
1034
|
let {
|
|
1003
1035
|
tag,
|
|
@@ -1005,9 +1037,21 @@ const HeaderComponent = React.forwardRef((_ref, ref) => {
|
|
|
1005
1037
|
} = _ref;
|
|
1006
1038
|
const {
|
|
1007
1039
|
isCloseButtonPresent,
|
|
1040
|
+
hasHeader,
|
|
1041
|
+
setHasHeader,
|
|
1008
1042
|
getTitleProps
|
|
1009
1043
|
} = useModalContext();
|
|
1010
|
-
|
|
1044
|
+
React.useEffect(() => {
|
|
1045
|
+
if (!hasHeader && setHasHeader) {
|
|
1046
|
+
setHasHeader(true);
|
|
1047
|
+
}
|
|
1048
|
+
return () => {
|
|
1049
|
+
if (hasHeader && setHasHeader) {
|
|
1050
|
+
setHasHeader(false);
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
}, [hasHeader, setHasHeader]);
|
|
1054
|
+
return React__namespace.default.createElement(StyledDrawerModalHeader, _extends$2({}, getTitleProps(other), {
|
|
1011
1055
|
as: tag,
|
|
1012
1056
|
isCloseButtonPresent: isCloseButtonPresent,
|
|
1013
1057
|
ref: ref
|
|
@@ -1015,7 +1059,7 @@ const HeaderComponent = React.forwardRef((_ref, ref) => {
|
|
|
1015
1059
|
});
|
|
1016
1060
|
HeaderComponent.displayName = 'DrawerModal.Header';
|
|
1017
1061
|
HeaderComponent.propTypes = {
|
|
1018
|
-
tag: PropTypes__default
|
|
1062
|
+
tag: PropTypes__default.default.any
|
|
1019
1063
|
};
|
|
1020
1064
|
HeaderComponent.defaultProps = {
|
|
1021
1065
|
tag: 'div'
|
|
@@ -1026,7 +1070,7 @@ const BodyComponent = React.forwardRef((props, ref) => {
|
|
|
1026
1070
|
const {
|
|
1027
1071
|
getContentProps
|
|
1028
1072
|
} = useModalContext();
|
|
1029
|
-
return
|
|
1073
|
+
return React__namespace.default.createElement(StyledDrawerModalBody, _extends$2({}, getContentProps(props), {
|
|
1030
1074
|
ref: ref
|
|
1031
1075
|
}), props.children);
|
|
1032
1076
|
});
|
|
@@ -1043,23 +1087,23 @@ const CloseComponent = React.forwardRef((props, ref) => {
|
|
|
1043
1087
|
return () => setIsCloseButtonPresent(false);
|
|
1044
1088
|
});
|
|
1045
1089
|
const ariaLabel = reactTheming.useText(CloseComponent, props, 'aria-label', 'Close drawer');
|
|
1046
|
-
return
|
|
1090
|
+
return React__namespace.default.createElement(StyledDrawerModalClose, _extends$2({}, getCloseProps({
|
|
1047
1091
|
...props,
|
|
1048
1092
|
'aria-label': ariaLabel
|
|
1049
1093
|
}), {
|
|
1050
1094
|
ref: ref
|
|
1051
|
-
}),
|
|
1095
|
+
}), React__namespace.default.createElement(SvgXStroke, null));
|
|
1052
1096
|
});
|
|
1053
1097
|
CloseComponent.displayName = 'DrawerModal.Close';
|
|
1054
1098
|
const Close = CloseComponent;
|
|
1055
1099
|
|
|
1056
|
-
const FooterComponent = React.forwardRef((props, ref) =>
|
|
1100
|
+
const FooterComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledDrawerModalFooter, _extends$2({
|
|
1057
1101
|
ref: ref
|
|
1058
1102
|
}, props)));
|
|
1059
1103
|
FooterComponent.displayName = 'DrawerModal.Footer';
|
|
1060
1104
|
const Footer = FooterComponent;
|
|
1061
1105
|
|
|
1062
|
-
const FooterItemComponent = React.forwardRef((props, ref) =>
|
|
1106
|
+
const FooterItemComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledDrawerModalFooterItem, _extends$2({
|
|
1063
1107
|
ref: ref
|
|
1064
1108
|
}, props)));
|
|
1065
1109
|
FooterItemComponent.displayName = 'DrawerModal.FooterItem';
|
|
@@ -1078,9 +1122,11 @@ const DrawerModalComponent = React.forwardRef((_ref, ref) => {
|
|
|
1078
1122
|
} = _ref;
|
|
1079
1123
|
const modalRef = React.useRef(null);
|
|
1080
1124
|
const transitionRef = React.useRef(null);
|
|
1125
|
+
const triggerRef = React.useRef(null);
|
|
1081
1126
|
const theme = React.useContext(styled.ThemeContext);
|
|
1082
1127
|
const environment = reactTheming.useDocument(theme);
|
|
1083
1128
|
const [isCloseButtonPresent, setIsCloseButtonPresent] = React.useState(false);
|
|
1129
|
+
const [hasHeader, setHasHeader] = React.useState(false);
|
|
1084
1130
|
containerFocusvisible.useFocusVisible({
|
|
1085
1131
|
scope: modalRef,
|
|
1086
1132
|
relativeDocument: modalRef.current
|
|
@@ -1094,11 +1140,31 @@ const DrawerModalComponent = React.forwardRef((_ref, ref) => {
|
|
|
1094
1140
|
} = containerModal.useModal({
|
|
1095
1141
|
idPrefix: id,
|
|
1096
1142
|
modalRef,
|
|
1097
|
-
focusOnMount,
|
|
1098
|
-
restoreFocus,
|
|
1143
|
+
focusOnMount: false ,
|
|
1144
|
+
restoreFocus: false ,
|
|
1099
1145
|
environment,
|
|
1100
1146
|
onClose
|
|
1101
1147
|
});
|
|
1148
|
+
React.useEffect(() => {
|
|
1149
|
+
if (environment) {
|
|
1150
|
+
if (isOpen && modalRef.current) {
|
|
1151
|
+
if (restoreFocus) {
|
|
1152
|
+
triggerRef.current = activeElement(environment);
|
|
1153
|
+
}
|
|
1154
|
+
if (focusOnMount) {
|
|
1155
|
+
modalRef.current.focus();
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
if (!isOpen && triggerRef.current) {
|
|
1159
|
+
triggerRef.current.focus();
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return () => {
|
|
1163
|
+
if (!(restoreFocus && isOpen)) {
|
|
1164
|
+
triggerRef.current = null;
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
}, [environment, restoreFocus, focusOnMount, isOpen]);
|
|
1102
1168
|
React.useEffect(() => {
|
|
1103
1169
|
if (!environment) {
|
|
1104
1170
|
return undefined;
|
|
@@ -1126,36 +1192,56 @@ const DrawerModalComponent = React.forwardRef((_ref, ref) => {
|
|
|
1126
1192
|
}, [appendToNode, environment]);
|
|
1127
1193
|
const value = React.useMemo(() => ({
|
|
1128
1194
|
isCloseButtonPresent,
|
|
1195
|
+
hasHeader,
|
|
1196
|
+
setHasHeader,
|
|
1129
1197
|
getTitleProps,
|
|
1130
1198
|
getContentProps,
|
|
1131
1199
|
getCloseProps,
|
|
1132
1200
|
setIsCloseButtonPresent
|
|
1133
|
-
}), [isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
1201
|
+
}), [isCloseButtonPresent, hasHeader, getTitleProps, getContentProps, getCloseProps]);
|
|
1202
|
+
const modalProps = getModalProps({
|
|
1203
|
+
'aria-describedby': undefined,
|
|
1204
|
+
...(hasHeader ? {} : {
|
|
1205
|
+
'aria-labelledby': undefined
|
|
1206
|
+
})
|
|
1207
|
+
});
|
|
1208
|
+
const attribute = hasHeader ? 'aria-labelledby' : 'aria-label';
|
|
1209
|
+
const defaultValue = hasHeader ? modalProps['aria-labelledby'] : 'Modal dialog';
|
|
1210
|
+
const labelValue = hasHeader ? modalProps['aria-labelledby'] : props['aria-label'];
|
|
1211
|
+
const ariaProps = {
|
|
1212
|
+
[attribute]: reactTheming.useText(DrawerModalComponent, {
|
|
1213
|
+
[attribute]: labelValue
|
|
1214
|
+
}, attribute, defaultValue)
|
|
1215
|
+
};
|
|
1134
1216
|
if (!rootNode) {
|
|
1135
1217
|
return null;
|
|
1136
1218
|
}
|
|
1137
|
-
return ReactDOM__default
|
|
1219
|
+
return ReactDOM__default.default.createPortal( React__namespace.default.createElement(ModalsContext.Provider, {
|
|
1138
1220
|
value: value
|
|
1139
|
-
},
|
|
1221
|
+
}, React__namespace.default.createElement(reactTransitionGroup.CSSTransition, {
|
|
1140
1222
|
in: isOpen,
|
|
1141
1223
|
timeout: 250,
|
|
1142
1224
|
unmountOnExit: true,
|
|
1143
1225
|
classNames: "garden-drawer-transition",
|
|
1144
1226
|
nodeRef: transitionRef
|
|
1145
|
-
},
|
|
1227
|
+
}, React__namespace.default.createElement(StyledBackdrop, _extends$2({
|
|
1146
1228
|
isAnimated: true
|
|
1147
|
-
}, getBackdropProps(backdropProps)),
|
|
1148
|
-
ref: mergeRefs__default
|
|
1229
|
+
}, getBackdropProps(backdropProps)), React__namespace.default.createElement(StyledDrawerModal, _extends$2({}, modalProps, ariaProps, props, {
|
|
1230
|
+
ref: mergeRefs__default.default([ref, modalRef, transitionRef])
|
|
1149
1231
|
}))))), rootNode);
|
|
1150
1232
|
});
|
|
1151
1233
|
DrawerModalComponent.displayName = 'DrawerModal';
|
|
1152
1234
|
DrawerModalComponent.propTypes = {
|
|
1153
|
-
backdropProps: PropTypes__default
|
|
1154
|
-
focusOnMount: PropTypes__default
|
|
1155
|
-
restoreFocus: PropTypes__default
|
|
1156
|
-
onClose: PropTypes__default
|
|
1157
|
-
appendToNode: PropTypes__default
|
|
1158
|
-
isOpen: PropTypes__default
|
|
1235
|
+
backdropProps: PropTypes__default.default.object,
|
|
1236
|
+
focusOnMount: PropTypes__default.default.bool,
|
|
1237
|
+
restoreFocus: PropTypes__default.default.bool,
|
|
1238
|
+
onClose: PropTypes__default.default.func,
|
|
1239
|
+
appendToNode: PropTypes__default.default.any,
|
|
1240
|
+
isOpen: PropTypes__default.default.bool
|
|
1241
|
+
};
|
|
1242
|
+
DrawerModalComponent.defaultProps = {
|
|
1243
|
+
focusOnMount: true ,
|
|
1244
|
+
restoreFocus: true
|
|
1159
1245
|
};
|
|
1160
1246
|
const DrawerModal = DrawerModalComponent;
|
|
1161
1247
|
DrawerModal.Body = Body;
|
package/dist/index.esm.js
CHANGED
|
@@ -116,7 +116,7 @@ const COMPONENT_ID$j = 'modals.backdrop';
|
|
|
116
116
|
const animationName$1 = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
117
117
|
const StyledBackdrop = styled.div.attrs({
|
|
118
118
|
'data-garden-id': COMPONENT_ID$j,
|
|
119
|
-
'data-garden-version': '8.
|
|
119
|
+
'data-garden-version': '8.63.0'
|
|
120
120
|
}).withConfig({
|
|
121
121
|
displayName: "StyledBackdrop",
|
|
122
122
|
componentId: "sc-mzdjpo-0"
|
|
@@ -132,7 +132,7 @@ StyledBackdrop.propTypes = {
|
|
|
132
132
|
const COMPONENT_ID$i = 'modals.body';
|
|
133
133
|
const StyledBody = styled.div.attrs({
|
|
134
134
|
'data-garden-id': COMPONENT_ID$i,
|
|
135
|
-
'data-garden-version': '8.
|
|
135
|
+
'data-garden-version': '8.63.0'
|
|
136
136
|
}).withConfig({
|
|
137
137
|
displayName: "StyledBody",
|
|
138
138
|
componentId: "sc-14rzecg-0"
|
|
@@ -154,7 +154,7 @@ const BASE_MULTIPLIERS$1 = {
|
|
|
154
154
|
};
|
|
155
155
|
const StyledClose = styled.button.attrs({
|
|
156
156
|
'data-garden-id': COMPONENT_ID$h,
|
|
157
|
-
'data-garden-version': '8.
|
|
157
|
+
'data-garden-version': '8.63.0'
|
|
158
158
|
}).withConfig({
|
|
159
159
|
displayName: "StyledClose",
|
|
160
160
|
componentId: "sc-iseudj-0"
|
|
@@ -166,7 +166,7 @@ StyledClose.defaultProps = {
|
|
|
166
166
|
const COMPONENT_ID$g = 'modals.footer';
|
|
167
167
|
const StyledFooter = styled.div.attrs({
|
|
168
168
|
'data-garden-id': COMPONENT_ID$g,
|
|
169
|
-
'data-garden-version': '8.
|
|
169
|
+
'data-garden-version': '8.63.0'
|
|
170
170
|
}).withConfig({
|
|
171
171
|
displayName: "StyledFooter",
|
|
172
172
|
componentId: "sc-d8pfdu-0"
|
|
@@ -178,7 +178,7 @@ StyledFooter.defaultProps = {
|
|
|
178
178
|
const COMPONENT_ID$f = 'modals.footer_item';
|
|
179
179
|
const StyledFooterItem = styled.span.attrs({
|
|
180
180
|
'data-garden-id': COMPONENT_ID$f,
|
|
181
|
-
'data-garden-version': '8.
|
|
181
|
+
'data-garden-version': '8.63.0'
|
|
182
182
|
}).withConfig({
|
|
183
183
|
displayName: "StyledFooterItem",
|
|
184
184
|
componentId: "sc-1mb76hl-0"
|
|
@@ -190,7 +190,7 @@ StyledFooterItem.defaultProps = {
|
|
|
190
190
|
const COMPONENT_ID$e = 'modals.header';
|
|
191
191
|
const StyledHeader = styled.div.attrs({
|
|
192
192
|
'data-garden-id': COMPONENT_ID$e,
|
|
193
|
-
'data-garden-version': '8.
|
|
193
|
+
'data-garden-version': '8.63.0'
|
|
194
194
|
}).withConfig({
|
|
195
195
|
displayName: "StyledHeader",
|
|
196
196
|
componentId: "sc-1787r9v-0"
|
|
@@ -200,9 +200,7 @@ StyledHeader.defaultProps = {
|
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
var _g, _circle;
|
|
203
|
-
|
|
204
203
|
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : 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$1.apply(this, arguments); }
|
|
205
|
-
|
|
206
204
|
var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
207
205
|
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
208
206
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -210,8 +208,7 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
|
210
208
|
height: 16,
|
|
211
209
|
focusable: "false",
|
|
212
210
|
viewBox: "0 0 16 16",
|
|
213
|
-
"aria-hidden": "true"
|
|
214
|
-
role: "img"
|
|
211
|
+
"aria-hidden": "true"
|
|
215
212
|
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
216
213
|
fill: "none",
|
|
217
214
|
stroke: "currentColor"
|
|
@@ -258,7 +255,7 @@ const sizeStyles$1 = props => {
|
|
|
258
255
|
};
|
|
259
256
|
const StyledModal = styled.div.attrs({
|
|
260
257
|
'data-garden-id': COMPONENT_ID$d,
|
|
261
|
-
'data-garden-version': '8.
|
|
258
|
+
'data-garden-version': '8.63.0'
|
|
262
259
|
}).withConfig({
|
|
263
260
|
displayName: "StyledModal",
|
|
264
261
|
componentId: "sc-1pe1axu-0"
|
|
@@ -274,7 +271,7 @@ StyledModal.defaultProps = {
|
|
|
274
271
|
const COMPONENT_ID$c = 'modals.tooltip_modal.backdrop';
|
|
275
272
|
const StyledTooltipModalBackdrop = styled.div.attrs({
|
|
276
273
|
'data-garden-id': COMPONENT_ID$c,
|
|
277
|
-
'data-garden-version': '8.
|
|
274
|
+
'data-garden-version': '8.63.0'
|
|
278
275
|
}).withConfig({
|
|
279
276
|
displayName: "StyledTooltipModalBackdrop",
|
|
280
277
|
componentId: "sc-1yaomgq-0"
|
|
@@ -357,7 +354,7 @@ StyledTooltipWrapper.defaultProps = {
|
|
|
357
354
|
const COMPONENT_ID$b = 'modals.tooltip_modal';
|
|
358
355
|
const StyledTooltipModal = styled.div.attrs(props => ({
|
|
359
356
|
'data-garden-id': COMPONENT_ID$b,
|
|
360
|
-
'data-garden-version': '8.
|
|
357
|
+
'data-garden-version': '8.63.0',
|
|
361
358
|
className: props.isAnimated && 'is-animated'
|
|
362
359
|
})).withConfig({
|
|
363
360
|
displayName: "StyledTooltipModal",
|
|
@@ -386,7 +383,7 @@ const sizeStyles = props => `
|
|
|
386
383
|
`;
|
|
387
384
|
const StyledTooltipModalTitle = styled.div.attrs({
|
|
388
385
|
'data-garden-id': COMPONENT_ID$a,
|
|
389
|
-
'data-garden-version': '8.
|
|
386
|
+
'data-garden-version': '8.63.0'
|
|
390
387
|
}).withConfig({
|
|
391
388
|
displayName: "StyledTooltipModalTitle",
|
|
392
389
|
componentId: "sc-11xjgjs-0"
|
|
@@ -398,7 +395,7 @@ StyledTooltipModalTitle.defaultProps = {
|
|
|
398
395
|
const COMPONENT_ID$9 = 'modals.tooltip_modal.body';
|
|
399
396
|
const StyledTooltipModalBody = styled.div.attrs({
|
|
400
397
|
'data-garden-id': COMPONENT_ID$9,
|
|
401
|
-
'data-garden-version': '8.
|
|
398
|
+
'data-garden-version': '8.63.0'
|
|
402
399
|
}).withConfig({
|
|
403
400
|
displayName: "StyledTooltipModalBody",
|
|
404
401
|
componentId: "sc-195dkzj-0"
|
|
@@ -410,7 +407,7 @@ StyledTooltipModalBody.defaultProps = {
|
|
|
410
407
|
const COMPONENT_ID$8 = 'modals.tooltip_modal.footer';
|
|
411
408
|
const StyledTooltipModalFooter = styled.div.attrs({
|
|
412
409
|
'data-garden-id': COMPONENT_ID$8,
|
|
413
|
-
'data-garden-version': '8.
|
|
410
|
+
'data-garden-version': '8.63.0'
|
|
414
411
|
}).withConfig({
|
|
415
412
|
displayName: "StyledTooltipModalFooter",
|
|
416
413
|
componentId: "sc-fm36a9-0"
|
|
@@ -422,7 +419,7 @@ StyledTooltipModalFooter.defaultProps = {
|
|
|
422
419
|
const COMPONENT_ID$7 = 'modals.tooltip_modal.footer_item';
|
|
423
420
|
const StyledTooltipModalFooterItem = styled(StyledFooterItem).attrs({
|
|
424
421
|
'data-garden-id': COMPONENT_ID$7,
|
|
425
|
-
'data-garden-version': '8.
|
|
422
|
+
'data-garden-version': '8.63.0'
|
|
426
423
|
}).withConfig({
|
|
427
424
|
displayName: "StyledTooltipModalFooterItem",
|
|
428
425
|
componentId: "sc-1nahj6p-0"
|
|
@@ -434,7 +431,7 @@ StyledTooltipModalFooterItem.defaultProps = {
|
|
|
434
431
|
const COMPONENT_ID$6 = 'modals.tooltip_modal.close';
|
|
435
432
|
const StyledTooltipModalClose = styled(StyledClose).attrs({
|
|
436
433
|
'data-garden-id': COMPONENT_ID$6,
|
|
437
|
-
'data-garden-version': '8.
|
|
434
|
+
'data-garden-version': '8.63.0'
|
|
438
435
|
}).withConfig({
|
|
439
436
|
displayName: "StyledTooltipModalClose",
|
|
440
437
|
componentId: "sc-1h2ke3q-0"
|
|
@@ -460,7 +457,7 @@ const boxShadow = props => {
|
|
|
460
457
|
};
|
|
461
458
|
const StyledDrawerModal = styled.div.attrs({
|
|
462
459
|
'data-garden-id': COMPONENT_ID$5,
|
|
463
|
-
'data-garden-version': '8.
|
|
460
|
+
'data-garden-version': '8.63.0'
|
|
464
461
|
}).withConfig({
|
|
465
462
|
displayName: "StyledDrawerModal",
|
|
466
463
|
componentId: "sc-i1sake-0"
|
|
@@ -477,7 +474,7 @@ const BASE_MULTIPLIERS = {
|
|
|
477
474
|
};
|
|
478
475
|
const StyledDrawerModalClose = styled(StyledClose).attrs({
|
|
479
476
|
'data-garden-id': COMPONENT_ID$4,
|
|
480
|
-
'data-garden-version': '8.
|
|
477
|
+
'data-garden-version': '8.63.0'
|
|
481
478
|
}).withConfig({
|
|
482
479
|
displayName: "StyledDrawerModalClose",
|
|
483
480
|
componentId: "sc-hrnaom-0"
|
|
@@ -489,7 +486,7 @@ StyledDrawerModalClose.defaultProps = {
|
|
|
489
486
|
const COMPONENT_ID$3 = 'modals.drawer_modal.header';
|
|
490
487
|
const StyledDrawerModalHeader = styled(StyledHeader).attrs({
|
|
491
488
|
'data-garden-id': COMPONENT_ID$3,
|
|
492
|
-
'data-garden-version': '8.
|
|
489
|
+
'data-garden-version': '8.63.0'
|
|
493
490
|
}).withConfig({
|
|
494
491
|
displayName: "StyledDrawerModalHeader",
|
|
495
492
|
componentId: "sc-1u04rqw-0"
|
|
@@ -501,7 +498,7 @@ StyledDrawerModalHeader.defaultProps = {
|
|
|
501
498
|
const COMPONENT_ID$2 = 'modals.drawer_modal.body';
|
|
502
499
|
const StyledDrawerModalBody = styled(StyledBody).attrs({
|
|
503
500
|
'data-garden-id': COMPONENT_ID$2,
|
|
504
|
-
'data-garden-version': '8.
|
|
501
|
+
'data-garden-version': '8.63.0'
|
|
505
502
|
}).withConfig({
|
|
506
503
|
displayName: "StyledDrawerModalBody",
|
|
507
504
|
componentId: "sc-yafe2y-0"
|
|
@@ -513,7 +510,7 @@ StyledDrawerModalBody.defaultProps = {
|
|
|
513
510
|
const COMPONENT_ID$1 = 'modals.drawer_modal.footer';
|
|
514
511
|
const StyledDrawerModalFooter = styled.div.attrs({
|
|
515
512
|
'data-garden-id': COMPONENT_ID$1,
|
|
516
|
-
'data-garden-version': '8.
|
|
513
|
+
'data-garden-version': '8.63.0'
|
|
517
514
|
}).withConfig({
|
|
518
515
|
displayName: "StyledDrawerModalFooter",
|
|
519
516
|
componentId: "sc-17if4ka-0"
|
|
@@ -525,7 +522,7 @@ StyledDrawerModalFooter.defaultProps = {
|
|
|
525
522
|
const COMPONENT_ID = 'modals.drawer_modal.footer_item';
|
|
526
523
|
const StyledDrawerModalFooterItem = styled(StyledFooterItem).attrs({
|
|
527
524
|
'data-garden-id': COMPONENT_ID,
|
|
528
|
-
'data-garden-version': '8.
|
|
525
|
+
'data-garden-version': '8.63.0'
|
|
529
526
|
}).withConfig({
|
|
530
527
|
displayName: "StyledDrawerModalFooterItem",
|
|
531
528
|
componentId: "sc-1vbl885-0"
|
|
@@ -573,6 +570,7 @@ const Modal = forwardRef((_ref, ref) => {
|
|
|
573
570
|
const modalRef = useRef(null);
|
|
574
571
|
const environment = useDocument(theme);
|
|
575
572
|
const [isCloseButtonPresent, setIsCloseButtonPresent] = useState(false);
|
|
573
|
+
const [hasHeader, setHasHeader] = useState(false);
|
|
576
574
|
const {
|
|
577
575
|
getBackdropProps,
|
|
578
576
|
getModalProps,
|
|
@@ -630,11 +628,27 @@ const Modal = forwardRef((_ref, ref) => {
|
|
|
630
628
|
const value = useMemo(() => ({
|
|
631
629
|
isLarge,
|
|
632
630
|
isCloseButtonPresent,
|
|
631
|
+
hasHeader,
|
|
632
|
+
setHasHeader,
|
|
633
633
|
getTitleProps,
|
|
634
634
|
getContentProps,
|
|
635
635
|
getCloseProps,
|
|
636
636
|
setIsCloseButtonPresent
|
|
637
|
-
}), [isLarge, isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
637
|
+
}), [isLarge, hasHeader, isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
638
|
+
const modalContainerProps = getModalProps({
|
|
639
|
+
'aria-describedby': undefined,
|
|
640
|
+
...(hasHeader ? {} : {
|
|
641
|
+
'aria-labelledby': undefined
|
|
642
|
+
})
|
|
643
|
+
});
|
|
644
|
+
const attribute = hasHeader ? 'aria-labelledby' : 'aria-label';
|
|
645
|
+
const defaultValue = hasHeader ? modalContainerProps['aria-labelledby'] : 'Modal dialog';
|
|
646
|
+
const labelValue = hasHeader ? modalContainerProps['aria-labelledby'] : modalProps['aria-label'];
|
|
647
|
+
const ariaProps = {
|
|
648
|
+
[attribute]: useText(Modal, {
|
|
649
|
+
[attribute]: labelValue
|
|
650
|
+
}, attribute, defaultValue)
|
|
651
|
+
};
|
|
638
652
|
if (!rootNode) {
|
|
639
653
|
return null;
|
|
640
654
|
}
|
|
@@ -647,7 +661,7 @@ const Modal = forwardRef((_ref, ref) => {
|
|
|
647
661
|
isCentered: isCentered,
|
|
648
662
|
isAnimated: isAnimated,
|
|
649
663
|
isLarge: isLarge
|
|
650
|
-
},
|
|
664
|
+
}, modalContainerProps, ariaProps, modalProps, {
|
|
651
665
|
ref: mergeRefs([ref, modalRef])
|
|
652
666
|
}), children))), rootNode);
|
|
653
667
|
});
|
|
@@ -678,9 +692,7 @@ const Body$2 = forwardRef((props, ref) => {
|
|
|
678
692
|
Body$2.displayName = 'Body';
|
|
679
693
|
|
|
680
694
|
var _path;
|
|
681
|
-
|
|
682
695
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
683
|
-
|
|
684
696
|
var SvgXStroke = function SvgXStroke(props) {
|
|
685
697
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
686
698
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -688,8 +700,7 @@ var SvgXStroke = function SvgXStroke(props) {
|
|
|
688
700
|
height: 16,
|
|
689
701
|
focusable: "false",
|
|
690
702
|
viewBox: "0 0 16 16",
|
|
691
|
-
"aria-hidden": "true"
|
|
692
|
-
role: "img"
|
|
703
|
+
"aria-hidden": "true"
|
|
693
704
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
694
705
|
stroke: "currentColor",
|
|
695
706
|
strokeLinecap: "round",
|
|
@@ -740,8 +751,20 @@ const Header$1 = forwardRef((_ref, ref) => {
|
|
|
740
751
|
} = _ref;
|
|
741
752
|
const {
|
|
742
753
|
isCloseButtonPresent,
|
|
754
|
+
hasHeader,
|
|
755
|
+
setHasHeader,
|
|
743
756
|
getTitleProps
|
|
744
757
|
} = useModalContext();
|
|
758
|
+
useEffect(() => {
|
|
759
|
+
if (!hasHeader && setHasHeader) {
|
|
760
|
+
setHasHeader(true);
|
|
761
|
+
}
|
|
762
|
+
return () => {
|
|
763
|
+
if (hasHeader && setHasHeader) {
|
|
764
|
+
setHasHeader(false);
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
}, [hasHeader, setHasHeader]);
|
|
745
768
|
return React__default.createElement(StyledHeader, _extends$2({}, getTitleProps(other), {
|
|
746
769
|
as: tag,
|
|
747
770
|
isCloseButtonPresent: isCloseButtonPresent,
|
|
@@ -900,7 +923,7 @@ const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
|
900
923
|
})
|
|
901
924
|
});
|
|
902
925
|
const attribute = hasTitle ? 'aria-labelledby' : 'aria-label';
|
|
903
|
-
const defaultValue = hasTitle ?
|
|
926
|
+
const defaultValue = hasTitle ? modalProps['aria-labelledby'] : 'Modal dialog';
|
|
904
927
|
const labelValue = hasTitle ? modalProps['aria-labelledby'] : props['aria-label'];
|
|
905
928
|
const ariaProps = {
|
|
906
929
|
[attribute]: useText(TooltipModalComponent, {
|
|
@@ -944,7 +967,6 @@ const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
|
944
967
|
TooltipModalComponent.displayName = 'TooltipModal';
|
|
945
968
|
TooltipModalComponent.defaultProps = {
|
|
946
969
|
placement: 'auto',
|
|
947
|
-
isAnimated: true,
|
|
948
970
|
hasArrow: true,
|
|
949
971
|
focusOnMount: true,
|
|
950
972
|
restoreFocus: true
|
|
@@ -968,6 +990,19 @@ TooltipModal.Footer = Footer$1;
|
|
|
968
990
|
TooltipModal.FooterItem = FooterItem$1;
|
|
969
991
|
TooltipModal.Title = Title;
|
|
970
992
|
|
|
993
|
+
function activeElement(doc) {
|
|
994
|
+
if (doc === void 0) {
|
|
995
|
+
doc = ownerDocument();
|
|
996
|
+
}
|
|
997
|
+
try {
|
|
998
|
+
var active = doc.activeElement;
|
|
999
|
+
if (!active || !active.nodeName) return null;
|
|
1000
|
+
return active;
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
return doc.body;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
971
1006
|
const HeaderComponent = forwardRef((_ref, ref) => {
|
|
972
1007
|
let {
|
|
973
1008
|
tag,
|
|
@@ -975,8 +1010,20 @@ const HeaderComponent = forwardRef((_ref, ref) => {
|
|
|
975
1010
|
} = _ref;
|
|
976
1011
|
const {
|
|
977
1012
|
isCloseButtonPresent,
|
|
1013
|
+
hasHeader,
|
|
1014
|
+
setHasHeader,
|
|
978
1015
|
getTitleProps
|
|
979
1016
|
} = useModalContext();
|
|
1017
|
+
useEffect(() => {
|
|
1018
|
+
if (!hasHeader && setHasHeader) {
|
|
1019
|
+
setHasHeader(true);
|
|
1020
|
+
}
|
|
1021
|
+
return () => {
|
|
1022
|
+
if (hasHeader && setHasHeader) {
|
|
1023
|
+
setHasHeader(false);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}, [hasHeader, setHasHeader]);
|
|
980
1027
|
return React__default.createElement(StyledDrawerModalHeader, _extends$2({}, getTitleProps(other), {
|
|
981
1028
|
as: tag,
|
|
982
1029
|
isCloseButtonPresent: isCloseButtonPresent,
|
|
@@ -1048,9 +1095,11 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1048
1095
|
} = _ref;
|
|
1049
1096
|
const modalRef = useRef(null);
|
|
1050
1097
|
const transitionRef = useRef(null);
|
|
1098
|
+
const triggerRef = useRef(null);
|
|
1051
1099
|
const theme = useContext(ThemeContext);
|
|
1052
1100
|
const environment = useDocument(theme);
|
|
1053
1101
|
const [isCloseButtonPresent, setIsCloseButtonPresent] = useState(false);
|
|
1102
|
+
const [hasHeader, setHasHeader] = useState(false);
|
|
1054
1103
|
useFocusVisible({
|
|
1055
1104
|
scope: modalRef,
|
|
1056
1105
|
relativeDocument: modalRef.current
|
|
@@ -1064,11 +1113,31 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1064
1113
|
} = useModal({
|
|
1065
1114
|
idPrefix: id,
|
|
1066
1115
|
modalRef,
|
|
1067
|
-
focusOnMount,
|
|
1068
|
-
restoreFocus,
|
|
1116
|
+
focusOnMount: false ,
|
|
1117
|
+
restoreFocus: false ,
|
|
1069
1118
|
environment,
|
|
1070
1119
|
onClose
|
|
1071
1120
|
});
|
|
1121
|
+
useEffect(() => {
|
|
1122
|
+
if (environment) {
|
|
1123
|
+
if (isOpen && modalRef.current) {
|
|
1124
|
+
if (restoreFocus) {
|
|
1125
|
+
triggerRef.current = activeElement(environment);
|
|
1126
|
+
}
|
|
1127
|
+
if (focusOnMount) {
|
|
1128
|
+
modalRef.current.focus();
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (!isOpen && triggerRef.current) {
|
|
1132
|
+
triggerRef.current.focus();
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return () => {
|
|
1136
|
+
if (!(restoreFocus && isOpen)) {
|
|
1137
|
+
triggerRef.current = null;
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
}, [environment, restoreFocus, focusOnMount, isOpen]);
|
|
1072
1141
|
useEffect(() => {
|
|
1073
1142
|
if (!environment) {
|
|
1074
1143
|
return undefined;
|
|
@@ -1096,11 +1165,27 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1096
1165
|
}, [appendToNode, environment]);
|
|
1097
1166
|
const value = useMemo(() => ({
|
|
1098
1167
|
isCloseButtonPresent,
|
|
1168
|
+
hasHeader,
|
|
1169
|
+
setHasHeader,
|
|
1099
1170
|
getTitleProps,
|
|
1100
1171
|
getContentProps,
|
|
1101
1172
|
getCloseProps,
|
|
1102
1173
|
setIsCloseButtonPresent
|
|
1103
|
-
}), [isCloseButtonPresent, getTitleProps, getContentProps, getCloseProps]);
|
|
1174
|
+
}), [isCloseButtonPresent, hasHeader, getTitleProps, getContentProps, getCloseProps]);
|
|
1175
|
+
const modalProps = getModalProps({
|
|
1176
|
+
'aria-describedby': undefined,
|
|
1177
|
+
...(hasHeader ? {} : {
|
|
1178
|
+
'aria-labelledby': undefined
|
|
1179
|
+
})
|
|
1180
|
+
});
|
|
1181
|
+
const attribute = hasHeader ? 'aria-labelledby' : 'aria-label';
|
|
1182
|
+
const defaultValue = hasHeader ? modalProps['aria-labelledby'] : 'Modal dialog';
|
|
1183
|
+
const labelValue = hasHeader ? modalProps['aria-labelledby'] : props['aria-label'];
|
|
1184
|
+
const ariaProps = {
|
|
1185
|
+
[attribute]: useText(DrawerModalComponent, {
|
|
1186
|
+
[attribute]: labelValue
|
|
1187
|
+
}, attribute, defaultValue)
|
|
1188
|
+
};
|
|
1104
1189
|
if (!rootNode) {
|
|
1105
1190
|
return null;
|
|
1106
1191
|
}
|
|
@@ -1114,7 +1199,7 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1114
1199
|
nodeRef: transitionRef
|
|
1115
1200
|
}, React__default.createElement(StyledBackdrop, _extends$2({
|
|
1116
1201
|
isAnimated: true
|
|
1117
|
-
}, getBackdropProps(backdropProps)), React__default.createElement(StyledDrawerModal, _extends$2({},
|
|
1202
|
+
}, getBackdropProps(backdropProps)), React__default.createElement(StyledDrawerModal, _extends$2({}, modalProps, ariaProps, props, {
|
|
1118
1203
|
ref: mergeRefs([ref, modalRef, transitionRef])
|
|
1119
1204
|
}))))), rootNode);
|
|
1120
1205
|
});
|
|
@@ -1127,6 +1212,10 @@ DrawerModalComponent.propTypes = {
|
|
|
1127
1212
|
appendToNode: PropTypes.any,
|
|
1128
1213
|
isOpen: PropTypes.bool
|
|
1129
1214
|
};
|
|
1215
|
+
DrawerModalComponent.defaultProps = {
|
|
1216
|
+
focusOnMount: true ,
|
|
1217
|
+
restoreFocus: true
|
|
1218
|
+
};
|
|
1130
1219
|
const DrawerModal = DrawerModalComponent;
|
|
1131
1220
|
DrawerModal.Body = Body;
|
|
1132
1221
|
DrawerModal.Close = Close;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { HTMLAttributes, KeyboardEvent, MouseEvent } from 'react';
|
|
8
8
|
import { Modifier } from 'react-popper';
|
|
9
9
|
export declare const PLACEMENT: readonly ["auto", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "end", "end-top", "end-bottom", "start", "start-top", "start-bottom"];
|
|
10
|
-
export
|
|
10
|
+
export type Placement = (typeof PLACEMENT)[number];
|
|
11
11
|
export interface IModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
12
|
/**
|
|
13
13
|
* Passes HTML attributes to the backdrop element
|
|
@@ -8,6 +8,8 @@ import { IUseModalReturnValue } from '@zendeskgarden/container-modal';
|
|
|
8
8
|
export interface IModalContext {
|
|
9
9
|
isLarge?: boolean;
|
|
10
10
|
isCloseButtonPresent?: boolean;
|
|
11
|
+
hasHeader: boolean;
|
|
12
|
+
setHasHeader: (hasHeader: boolean) => void;
|
|
11
13
|
getTitleProps: IUseModalReturnValue['getTitleProps'];
|
|
12
14
|
getContentProps: IUseModalReturnValue['getContentProps'];
|
|
13
15
|
getCloseProps: IUseModalReturnValue['getCloseProps'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-modals",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.63.0",
|
|
4
4
|
"description": "Components relating to modals in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/react-transition-group": "4.4.5",
|
|
42
|
-
"@zendeskgarden/react-theming": "^8.
|
|
42
|
+
"@zendeskgarden/react-theming": "^8.63.0",
|
|
43
43
|
"@zendeskgarden/svg-icons": "6.33.0"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"zendeskgarden:src": "src/index.ts",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "4b8715305a769881b143c7195c5b31e687422926"
|
|
56
56
|
}
|