@zendeskgarden/react-modals 9.0.0-next.1 → 9.0.0-next.2
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/README.md +58 -0
- package/dist/index.cjs.js +108 -153
- package/dist/index.esm.js +109 -154
- package/dist/typings/elements/{DrawerModal/DrawerModal.d.ts → Drawer/Drawer.d.ts} +2 -2
- package/dist/typings/elements/{DrawerModal → Drawer}/Header.d.ts +2 -2
- package/dist/typings/index.d.ts +2 -2
- package/dist/typings/styled/{StyledDrawerModal.d.ts → StyledDrawer.d.ts} +1 -1
- package/dist/typings/styled/{StyledDrawerModalBody.d.ts → StyledDrawerBody.d.ts} +1 -1
- package/dist/typings/styled/{StyledDrawerModalClose.d.ts → StyledDrawerClose.d.ts} +1 -1
- package/dist/typings/styled/{StyledDrawerModalFooterItem.d.ts → StyledDrawerFooter.d.ts} +1 -1
- package/dist/typings/styled/{StyledDrawerModalFooter.d.ts → StyledDrawerFooterItem.d.ts} +1 -1
- package/dist/typings/styled/{StyledDrawerModalHeader.d.ts → StyledDrawerHeader.d.ts} +1 -1
- package/dist/typings/styled/StyledTooltipModal.d.ts +1 -1
- package/dist/typings/styled/StyledTooltipWrapper.d.ts +2 -2
- package/dist/typings/styled/index.d.ts +6 -6
- package/dist/typings/types/index.d.ts +2 -7
- package/package.json +4 -5
- package/dist/typings/utils/gardenPlacements.d.ts +0 -28
- /package/dist/typings/elements/{DrawerModal → Drawer}/Body.d.ts +0 -0
- /package/dist/typings/elements/{DrawerModal → Drawer}/Close.d.ts +0 -0
- /package/dist/typings/elements/{DrawerModal → Drawer}/Footer.d.ts +0 -0
- /package/dist/typings/elements/{DrawerModal → Drawer}/FooterItem.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -10,7 +10,7 @@ import React__default, { createContext, useContext, forwardRef, useRef, useState
|
|
|
10
10
|
import ReactDOM, { createPortal } from 'react-dom';
|
|
11
11
|
import styled, { keyframes, css, ThemeContext } from 'styled-components';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
|
-
import { getColor, retrieveComponentStyles, DEFAULT_THEME, getLineHeight, focusStyles, mediaQuery, menuStyles, arrowStyles, useDocument, useText } from '@zendeskgarden/react-theming';
|
|
13
|
+
import { getColor, retrieveComponentStyles, DEFAULT_THEME, getLineHeight, focusStyles, mediaQuery, menuStyles, getMenuPosition, arrowStyles, getArrowPosition, useDocument, useText, getFloatingPlacements, PLACEMENT as PLACEMENT$1 } from '@zendeskgarden/react-theming';
|
|
14
14
|
import { useModal } from '@zendeskgarden/container-modal';
|
|
15
15
|
import { useFocusVisible } from '@zendeskgarden/container-focusvisible';
|
|
16
16
|
import { mergeRefs } from 'react-merge-refs';
|
|
@@ -19,8 +19,8 @@ import ownerDocument from 'dom-helpers/ownerDocument';
|
|
|
19
19
|
import ownerWindow from 'dom-helpers/ownerWindow';
|
|
20
20
|
import css$1 from 'dom-helpers/css';
|
|
21
21
|
import getScrollbarSize from 'dom-helpers/scrollbarSize';
|
|
22
|
-
import { usePopper } from 'react-popper';
|
|
23
22
|
import { CSSTransition } from 'react-transition-group';
|
|
23
|
+
import { useFloating, offset, autoPlacement, autoUpdate } from '@floating-ui/react-dom';
|
|
24
24
|
import activeElement from 'dom-helpers/activeElement';
|
|
25
25
|
|
|
26
26
|
function _extends$2() {
|
|
@@ -48,7 +48,7 @@ const animationStyles$1 = props => {
|
|
|
48
48
|
};
|
|
49
49
|
const StyledBackdrop = styled.div.attrs({
|
|
50
50
|
'data-garden-id': COMPONENT_ID$j,
|
|
51
|
-
'data-garden-version': '9.0.0-next.
|
|
51
|
+
'data-garden-version': '9.0.0-next.2'
|
|
52
52
|
}).withConfig({
|
|
53
53
|
displayName: "StyledBackdrop",
|
|
54
54
|
componentId: "sc-mzdjpo-0"
|
|
@@ -64,7 +64,7 @@ StyledBackdrop.propTypes = {
|
|
|
64
64
|
const COMPONENT_ID$i = 'modals.body';
|
|
65
65
|
const StyledBody = styled.div.attrs({
|
|
66
66
|
'data-garden-id': COMPONENT_ID$i,
|
|
67
|
-
'data-garden-version': '9.0.0-next.
|
|
67
|
+
'data-garden-version': '9.0.0-next.2'
|
|
68
68
|
}).withConfig({
|
|
69
69
|
displayName: "StyledBody",
|
|
70
70
|
componentId: "sc-14rzecg-0"
|
|
@@ -89,7 +89,7 @@ const BASE_MULTIPLIERS$1 = {
|
|
|
89
89
|
};
|
|
90
90
|
const StyledClose = styled.button.attrs({
|
|
91
91
|
'data-garden-id': COMPONENT_ID$h,
|
|
92
|
-
'data-garden-version': '9.0.0-next.
|
|
92
|
+
'data-garden-version': '9.0.0-next.2'
|
|
93
93
|
}).withConfig({
|
|
94
94
|
displayName: "StyledClose",
|
|
95
95
|
componentId: "sc-iseudj-0"
|
|
@@ -101,7 +101,7 @@ StyledClose.defaultProps = {
|
|
|
101
101
|
const COMPONENT_ID$g = 'modals.footer';
|
|
102
102
|
const StyledFooter = styled.div.attrs({
|
|
103
103
|
'data-garden-id': COMPONENT_ID$g,
|
|
104
|
-
'data-garden-version': '9.0.0-next.
|
|
104
|
+
'data-garden-version': '9.0.0-next.2'
|
|
105
105
|
}).withConfig({
|
|
106
106
|
displayName: "StyledFooter",
|
|
107
107
|
componentId: "sc-d8pfdu-0"
|
|
@@ -113,7 +113,7 @@ StyledFooter.defaultProps = {
|
|
|
113
113
|
const COMPONENT_ID$f = 'modals.footer_item';
|
|
114
114
|
const StyledFooterItem = styled.span.attrs({
|
|
115
115
|
'data-garden-id': COMPONENT_ID$f,
|
|
116
|
-
'data-garden-version': '9.0.0-next.
|
|
116
|
+
'data-garden-version': '9.0.0-next.2'
|
|
117
117
|
}).withConfig({
|
|
118
118
|
displayName: "StyledFooterItem",
|
|
119
119
|
componentId: "sc-1mb76hl-0"
|
|
@@ -125,7 +125,7 @@ StyledFooterItem.defaultProps = {
|
|
|
125
125
|
const COMPONENT_ID$e = 'modals.header';
|
|
126
126
|
const StyledHeader = styled.div.attrs({
|
|
127
127
|
'data-garden-id': COMPONENT_ID$e,
|
|
128
|
-
'data-garden-version': '9.0.0-next.
|
|
128
|
+
'data-garden-version': '9.0.0-next.2'
|
|
129
129
|
}).withConfig({
|
|
130
130
|
displayName: "StyledHeader",
|
|
131
131
|
componentId: "sc-1787r9v-0"
|
|
@@ -196,7 +196,7 @@ const sizeStyles$1 = props => {
|
|
|
196
196
|
};
|
|
197
197
|
const StyledModal = styled.div.attrs({
|
|
198
198
|
'data-garden-id': COMPONENT_ID$d,
|
|
199
|
-
'data-garden-version': '9.0.0-next.
|
|
199
|
+
'data-garden-version': '9.0.0-next.2'
|
|
200
200
|
}).withConfig({
|
|
201
201
|
displayName: "StyledModal",
|
|
202
202
|
componentId: "sc-1pe1axu-0"
|
|
@@ -212,7 +212,7 @@ StyledModal.defaultProps = {
|
|
|
212
212
|
const COMPONENT_ID$c = 'modals.tooltip_modal.backdrop';
|
|
213
213
|
const StyledTooltipModalBackdrop = styled.div.attrs({
|
|
214
214
|
'data-garden-id': COMPONENT_ID$c,
|
|
215
|
-
'data-garden-version': '9.0.0-next.
|
|
215
|
+
'data-garden-version': '9.0.0-next.2'
|
|
216
216
|
}).withConfig({
|
|
217
217
|
displayName: "StyledTooltipModalBackdrop",
|
|
218
218
|
componentId: "sc-1yaomgq-0"
|
|
@@ -221,70 +221,14 @@ StyledTooltipModalBackdrop.defaultProps = {
|
|
|
221
221
|
theme: DEFAULT_THEME
|
|
222
222
|
};
|
|
223
223
|
|
|
224
|
-
function getPopperPlacement(gardenPlacement) {
|
|
225
|
-
const gardenToPopperMapping = {
|
|
226
|
-
auto: 'auto',
|
|
227
|
-
top: 'top',
|
|
228
|
-
'top-start': 'top-start',
|
|
229
|
-
'top-end': 'top-end',
|
|
230
|
-
bottom: 'bottom',
|
|
231
|
-
'bottom-start': 'bottom-start',
|
|
232
|
-
'bottom-end': 'bottom-end',
|
|
233
|
-
end: 'right',
|
|
234
|
-
'end-top': 'right-start',
|
|
235
|
-
'end-bottom': 'right-end',
|
|
236
|
-
start: 'left',
|
|
237
|
-
'start-top': 'left-start',
|
|
238
|
-
'start-bottom': 'left-end'
|
|
239
|
-
};
|
|
240
|
-
return gardenToPopperMapping[gardenPlacement];
|
|
241
|
-
}
|
|
242
|
-
function getRtlPopperPlacement(gardenPlacement) {
|
|
243
|
-
const rtlPlacementMappings = {
|
|
244
|
-
left: 'right',
|
|
245
|
-
'left-start': 'right-start',
|
|
246
|
-
'left-end': 'right-end',
|
|
247
|
-
'top-start': 'top-end',
|
|
248
|
-
'top-end': 'top-start',
|
|
249
|
-
right: 'left',
|
|
250
|
-
'right-start': 'left-start',
|
|
251
|
-
'right-end': 'left-end',
|
|
252
|
-
'bottom-start': 'bottom-end',
|
|
253
|
-
'bottom-end': 'bottom-start'
|
|
254
|
-
};
|
|
255
|
-
const popperPlacement = getPopperPlacement(gardenPlacement);
|
|
256
|
-
return rtlPlacementMappings[popperPlacement] || popperPlacement;
|
|
257
|
-
}
|
|
258
|
-
function getArrowPosition(popperPlacement) {
|
|
259
|
-
const arrowPositionMappings = {
|
|
260
|
-
top: 'bottom',
|
|
261
|
-
'top-start': 'bottom-left',
|
|
262
|
-
'top-end': 'bottom-right',
|
|
263
|
-
right: 'left',
|
|
264
|
-
'right-start': 'left-top',
|
|
265
|
-
'right-end': 'left-bottom',
|
|
266
|
-
bottom: 'top',
|
|
267
|
-
'bottom-start': 'top-left',
|
|
268
|
-
'bottom-end': 'top-right',
|
|
269
|
-
left: 'right',
|
|
270
|
-
'left-start': 'right-top',
|
|
271
|
-
'left-end': 'right-bottom'
|
|
272
|
-
};
|
|
273
|
-
return arrowPositionMappings[popperPlacement] || 'top';
|
|
274
|
-
}
|
|
275
|
-
function getMenuPosition(popperPlacement) {
|
|
276
|
-
return popperPlacement ? popperPlacement.split('-')[0] : 'bottom';
|
|
277
|
-
}
|
|
278
|
-
|
|
279
224
|
const StyledTooltipWrapper = styled.div.attrs(props => ({
|
|
280
225
|
className: props.isAnimated && 'is-animated'
|
|
281
226
|
})).withConfig({
|
|
282
227
|
displayName: "StyledTooltipWrapper",
|
|
283
228
|
componentId: "sc-1xk05kf-0"
|
|
284
|
-
})(["", ";"], props => menuStyles(getMenuPosition(props.placement), {
|
|
229
|
+
})(["top:0;left:0;", ";"], props => menuStyles(getMenuPosition(props.placement), {
|
|
285
230
|
theme: props.theme,
|
|
286
231
|
hidden: false,
|
|
287
|
-
margin: '0',
|
|
288
232
|
zIndex: props.zIndex,
|
|
289
233
|
animationModifier: '.is-animated'
|
|
290
234
|
}));
|
|
@@ -295,13 +239,13 @@ StyledTooltipWrapper.defaultProps = {
|
|
|
295
239
|
const COMPONENT_ID$b = 'modals.tooltip_modal';
|
|
296
240
|
const StyledTooltipModal = styled.div.attrs(props => ({
|
|
297
241
|
'data-garden-id': COMPONENT_ID$b,
|
|
298
|
-
'data-garden-version': '9.0.0-next.
|
|
242
|
+
'data-garden-version': '9.0.0-next.2',
|
|
299
243
|
className: props.isAnimated && 'is-animated'
|
|
300
244
|
})).withConfig({
|
|
301
245
|
displayName: "StyledTooltipModal",
|
|
302
246
|
componentId: "sc-42ubfr-0"
|
|
303
247
|
})(["padding:", "px;width:400px;", ";", ";"], props => props.theme.space.base * 5, props => {
|
|
304
|
-
const computedArrowStyles = arrowStyles(getArrowPosition(props.placement), {
|
|
248
|
+
const computedArrowStyles = arrowStyles(getArrowPosition(props.theme, props.placement), {
|
|
305
249
|
size: `${props.theme.space.base * 2}px`,
|
|
306
250
|
inset: '1px',
|
|
307
251
|
animationModifier: '.is-animated'
|
|
@@ -324,7 +268,7 @@ const sizeStyles = props => `
|
|
|
324
268
|
`;
|
|
325
269
|
const StyledTooltipModalTitle = styled.div.attrs({
|
|
326
270
|
'data-garden-id': COMPONENT_ID$a,
|
|
327
|
-
'data-garden-version': '9.0.0-next.
|
|
271
|
+
'data-garden-version': '9.0.0-next.2'
|
|
328
272
|
}).withConfig({
|
|
329
273
|
displayName: "StyledTooltipModalTitle",
|
|
330
274
|
componentId: "sc-11xjgjs-0"
|
|
@@ -336,7 +280,7 @@ StyledTooltipModalTitle.defaultProps = {
|
|
|
336
280
|
const COMPONENT_ID$9 = 'modals.tooltip_modal.body';
|
|
337
281
|
const StyledTooltipModalBody = styled.div.attrs({
|
|
338
282
|
'data-garden-id': COMPONENT_ID$9,
|
|
339
|
-
'data-garden-version': '9.0.0-next.
|
|
283
|
+
'data-garden-version': '9.0.0-next.2'
|
|
340
284
|
}).withConfig({
|
|
341
285
|
displayName: "StyledTooltipModalBody",
|
|
342
286
|
componentId: "sc-195dkzj-0"
|
|
@@ -348,7 +292,7 @@ StyledTooltipModalBody.defaultProps = {
|
|
|
348
292
|
const COMPONENT_ID$8 = 'modals.tooltip_modal.footer';
|
|
349
293
|
const StyledTooltipModalFooter = styled.div.attrs({
|
|
350
294
|
'data-garden-id': COMPONENT_ID$8,
|
|
351
|
-
'data-garden-version': '9.0.0-next.
|
|
295
|
+
'data-garden-version': '9.0.0-next.2'
|
|
352
296
|
}).withConfig({
|
|
353
297
|
displayName: "StyledTooltipModalFooter",
|
|
354
298
|
componentId: "sc-fm36a9-0"
|
|
@@ -360,7 +304,7 @@ StyledTooltipModalFooter.defaultProps = {
|
|
|
360
304
|
const COMPONENT_ID$7 = 'modals.tooltip_modal.footer_item';
|
|
361
305
|
const StyledTooltipModalFooterItem = styled(StyledFooterItem).attrs({
|
|
362
306
|
'data-garden-id': COMPONENT_ID$7,
|
|
363
|
-
'data-garden-version': '9.0.0-next.
|
|
307
|
+
'data-garden-version': '9.0.0-next.2'
|
|
364
308
|
}).withConfig({
|
|
365
309
|
displayName: "StyledTooltipModalFooterItem",
|
|
366
310
|
componentId: "sc-1nahj6p-0"
|
|
@@ -372,7 +316,7 @@ StyledTooltipModalFooterItem.defaultProps = {
|
|
|
372
316
|
const COMPONENT_ID$6 = 'modals.tooltip_modal.close';
|
|
373
317
|
const StyledTooltipModalClose = styled(StyledClose).attrs({
|
|
374
318
|
'data-garden-id': COMPONENT_ID$6,
|
|
375
|
-
'data-garden-version': '9.0.0-next.
|
|
319
|
+
'data-garden-version': '9.0.0-next.2'
|
|
376
320
|
}).withConfig({
|
|
377
321
|
displayName: "StyledTooltipModalClose",
|
|
378
322
|
componentId: "sc-1h2ke3q-0"
|
|
@@ -396,14 +340,14 @@ const boxShadow = props => {
|
|
|
396
340
|
const color = getColor('neutralHue', 800, theme, 0.35);
|
|
397
341
|
return shadows.lg(offsetY, blurRadius, color);
|
|
398
342
|
};
|
|
399
|
-
const
|
|
343
|
+
const StyledDrawer = styled.div.attrs({
|
|
400
344
|
'data-garden-id': COMPONENT_ID$5,
|
|
401
|
-
'data-garden-version': '9.0.0-next.
|
|
345
|
+
'data-garden-version': '9.0.0-next.2'
|
|
402
346
|
}).withConfig({
|
|
403
|
-
displayName: "
|
|
404
|
-
componentId: "sc-
|
|
347
|
+
displayName: "StyledDrawer",
|
|
348
|
+
componentId: "sc-zp66t3-0"
|
|
405
349
|
})(["display:flex;position:fixed;top:0;", ":0;flex-direction:column;z-index:500;box-shadow:", ";background:", ";width:", "px;height:100%;overflow:auto;-webkit-overflow-scrolling:touch;font-family:", ";direction:", ";&.garden-drawer-transition-enter{transform:translateX(", "px);}&.garden-drawer-transition-enter-active{transform:translateX(0);transition:transform 0.25s ease-in-out;}&.garden-drawer-transition-exit-active{transform:translateX(", "px);transition:transform 0.25s ease-in-out;}&:focus{outline:none;}", ";"], props => props.theme.rtl ? 'left' : 'right', boxShadow, props => props.theme.colors.background, DRAWER_WIDTH, props => props.theme.fonts.system, props => props.theme.rtl && 'rtl', props => props.theme.rtl ? -DRAWER_WIDTH : DRAWER_WIDTH, props => props.theme.rtl ? -DRAWER_WIDTH : DRAWER_WIDTH, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
406
|
-
|
|
350
|
+
StyledDrawer.defaultProps = {
|
|
407
351
|
theme: DEFAULT_THEME
|
|
408
352
|
};
|
|
409
353
|
|
|
@@ -413,62 +357,62 @@ const BASE_MULTIPLIERS = {
|
|
|
413
357
|
side: 2,
|
|
414
358
|
size: BASE_MULTIPLIERS$1.size
|
|
415
359
|
};
|
|
416
|
-
const
|
|
360
|
+
const StyledDrawerClose = styled(StyledClose).attrs({
|
|
417
361
|
'data-garden-id': COMPONENT_ID$4,
|
|
418
|
-
'data-garden-version': '9.0.0-next.
|
|
362
|
+
'data-garden-version': '9.0.0-next.2'
|
|
419
363
|
}).withConfig({
|
|
420
|
-
displayName: "
|
|
421
|
-
componentId: "sc-
|
|
364
|
+
displayName: "StyledDrawerClose",
|
|
365
|
+
componentId: "sc-1a0xt3x-0"
|
|
422
366
|
})(["", ":", ";", ";"], props => props.theme.rtl ? 'left' : 'right', props => `${props.theme.space.base * BASE_MULTIPLIERS.side}px`, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
423
|
-
|
|
367
|
+
StyledDrawerClose.defaultProps = {
|
|
424
368
|
theme: DEFAULT_THEME
|
|
425
369
|
};
|
|
426
370
|
|
|
427
371
|
const COMPONENT_ID$3 = 'modals.drawer_modal.header';
|
|
428
|
-
const
|
|
372
|
+
const StyledDrawerHeader = styled(StyledHeader).attrs({
|
|
429
373
|
'data-garden-id': COMPONENT_ID$3,
|
|
430
|
-
'data-garden-version': '9.0.0-next.
|
|
374
|
+
'data-garden-version': '9.0.0-next.2'
|
|
431
375
|
}).withConfig({
|
|
432
|
-
displayName: "
|
|
433
|
-
componentId: "sc-
|
|
376
|
+
displayName: "StyledDrawerHeader",
|
|
377
|
+
componentId: "sc-y4mgkj-0"
|
|
434
378
|
})(["padding:", "px;", " ", ";"], props => props.theme.space.base * 5, props => props.isCloseButtonPresent && `padding-${props.theme.rtl ? 'left' : 'right'}: ${props.theme.space.base * (BASE_MULTIPLIERS.size + BASE_MULTIPLIERS.side + 2)}px;`, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
435
|
-
|
|
379
|
+
StyledDrawerHeader.defaultProps = {
|
|
436
380
|
theme: DEFAULT_THEME
|
|
437
381
|
};
|
|
438
382
|
|
|
439
383
|
const COMPONENT_ID$2 = 'modals.drawer_modal.body';
|
|
440
|
-
const
|
|
384
|
+
const StyledDrawerBody = styled(StyledBody).attrs({
|
|
441
385
|
'data-garden-id': COMPONENT_ID$2,
|
|
442
|
-
'data-garden-version': '9.0.0-next.
|
|
386
|
+
'data-garden-version': '9.0.0-next.2'
|
|
443
387
|
}).withConfig({
|
|
444
|
-
displayName: "
|
|
445
|
-
componentId: "sc-
|
|
388
|
+
displayName: "StyledDrawerBody",
|
|
389
|
+
componentId: "sc-13qufyn-0"
|
|
446
390
|
})(["padding:", "px;", ";"], props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
447
|
-
|
|
391
|
+
StyledDrawerBody.defaultProps = {
|
|
448
392
|
theme: DEFAULT_THEME
|
|
449
393
|
};
|
|
450
394
|
|
|
451
395
|
const COMPONENT_ID$1 = 'modals.drawer_modal.footer';
|
|
452
|
-
const
|
|
396
|
+
const StyledDrawerFooter = styled.div.attrs({
|
|
453
397
|
'data-garden-id': COMPONENT_ID$1,
|
|
454
|
-
'data-garden-version': '9.0.0-next.
|
|
398
|
+
'data-garden-version': '9.0.0-next.2'
|
|
455
399
|
}).withConfig({
|
|
456
|
-
displayName: "
|
|
457
|
-
componentId: "sc-
|
|
400
|
+
displayName: "StyledDrawerFooter",
|
|
401
|
+
componentId: "sc-kc7e6p-0"
|
|
458
402
|
})(["display:flex;flex-shrink:0;justify-content:flex-end;border-top:", ";padding:", "px;", ";"], props => `${props.theme.borders.sm} ${getColor('neutralHue', 200, props.theme)}`, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
459
|
-
|
|
403
|
+
StyledDrawerFooter.defaultProps = {
|
|
460
404
|
theme: DEFAULT_THEME
|
|
461
405
|
};
|
|
462
406
|
|
|
463
407
|
const COMPONENT_ID = 'modals.drawer_modal.footer_item';
|
|
464
|
-
const
|
|
408
|
+
const StyledDrawerFooterItem = styled(StyledFooterItem).attrs({
|
|
465
409
|
'data-garden-id': COMPONENT_ID,
|
|
466
|
-
'data-garden-version': '9.0.0-next.
|
|
410
|
+
'data-garden-version': '9.0.0-next.2'
|
|
467
411
|
}).withConfig({
|
|
468
|
-
displayName: "
|
|
469
|
-
componentId: "sc-
|
|
412
|
+
displayName: "StyledDrawerFooterItem",
|
|
413
|
+
componentId: "sc-m2yul4-0"
|
|
470
414
|
})(["", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
471
|
-
|
|
415
|
+
StyledDrawerFooterItem.defaultProps = {
|
|
472
416
|
theme: DEFAULT_THEME
|
|
473
417
|
};
|
|
474
418
|
|
|
@@ -803,12 +747,12 @@ const FooterItemComponent$1 = forwardRef((props, ref) => React__default.createEl
|
|
|
803
747
|
FooterItemComponent$1.displayName = 'TooltipModal.FooterItem';
|
|
804
748
|
const FooterItem$1 = FooterItemComponent$1;
|
|
805
749
|
|
|
750
|
+
const PLACEMENT_DEFAULT = 'top';
|
|
806
751
|
const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
807
752
|
let {
|
|
808
753
|
appendToNode,
|
|
809
754
|
referenceElement,
|
|
810
|
-
|
|
811
|
-
placement,
|
|
755
|
+
placement: _placement,
|
|
812
756
|
onClose,
|
|
813
757
|
hasArrow,
|
|
814
758
|
isAnimated,
|
|
@@ -819,11 +763,11 @@ const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
|
819
763
|
id,
|
|
820
764
|
...props
|
|
821
765
|
} = _ref;
|
|
822
|
-
const theme = useContext(ThemeContext);
|
|
766
|
+
const theme = useContext(ThemeContext) || DEFAULT_THEME;
|
|
823
767
|
const previousReferenceElementRef = useRef();
|
|
824
768
|
const modalRef = useRef(null);
|
|
825
769
|
const transitionRef = useRef(null);
|
|
826
|
-
const [
|
|
770
|
+
const [floatingElement, setFloatingElement] = useState();
|
|
827
771
|
const [hasTitle, setHasTitle] = useState(false);
|
|
828
772
|
const {
|
|
829
773
|
getTitleProps,
|
|
@@ -838,27 +782,37 @@ const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
|
838
782
|
focusOnMount,
|
|
839
783
|
restoreFocus: false
|
|
840
784
|
});
|
|
785
|
+
const [floatingPlacement] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
|
|
786
|
+
const {
|
|
787
|
+
refs,
|
|
788
|
+
placement,
|
|
789
|
+
update,
|
|
790
|
+
floatingStyles: {
|
|
791
|
+
transform
|
|
792
|
+
}
|
|
793
|
+
} = useFloating({
|
|
794
|
+
elements: {
|
|
795
|
+
reference: referenceElement,
|
|
796
|
+
floating: floatingElement
|
|
797
|
+
},
|
|
798
|
+
placement: floatingPlacement,
|
|
799
|
+
middleware: [offset(theme.space.base * 3), _placement === 'auto' ? autoPlacement() : undefined]
|
|
800
|
+
});
|
|
801
|
+
useEffect(() => {
|
|
802
|
+
let cleanup;
|
|
803
|
+
if (referenceElement && floatingElement && refs.reference.current && refs.floating.current) {
|
|
804
|
+
cleanup = autoUpdate(refs.reference.current, refs.floating.current, update, {
|
|
805
|
+
elementResize: typeof ResizeObserver === 'function'
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
return () => cleanup && cleanup();
|
|
809
|
+
}, [referenceElement, floatingElement, refs.reference, refs.floating, update]);
|
|
841
810
|
useEffect(() => {
|
|
842
811
|
if (!referenceElement && previousReferenceElementRef.current && restoreFocus) {
|
|
843
812
|
previousReferenceElementRef.current.focus();
|
|
844
813
|
}
|
|
845
814
|
previousReferenceElementRef.current = referenceElement;
|
|
846
815
|
}, [referenceElement, restoreFocus]);
|
|
847
|
-
const popperPlacement = useMemo(() => theme.rtl ? getRtlPopperPlacement(placement) : getPopperPlacement(placement), [placement, theme.rtl]);
|
|
848
|
-
const {
|
|
849
|
-
styles,
|
|
850
|
-
attributes,
|
|
851
|
-
state
|
|
852
|
-
} = usePopper(referenceElement, popperElement, {
|
|
853
|
-
placement: popperPlacement,
|
|
854
|
-
modifiers: [{
|
|
855
|
-
name: 'offset',
|
|
856
|
-
options: {
|
|
857
|
-
offset: [0, theme.space.base * 3]
|
|
858
|
-
}
|
|
859
|
-
},
|
|
860
|
-
...(popperModifiers || [])]
|
|
861
|
-
});
|
|
862
816
|
const modalProps = getModalProps({
|
|
863
817
|
'aria-describedby': undefined,
|
|
864
818
|
...(hasTitle ? {} : {
|
|
@@ -891,15 +845,17 @@ const TooltipModalComponent = React__default.forwardRef((_ref, ref) => {
|
|
|
891
845
|
value: value
|
|
892
846
|
}, React__default.createElement(StyledTooltipModalBackdrop, _extends$2({}, getBackdropProps(), backdropProps, {
|
|
893
847
|
ref: transitionRef
|
|
894
|
-
}), React__default.createElement(StyledTooltipWrapper,
|
|
895
|
-
ref:
|
|
896
|
-
style:
|
|
897
|
-
|
|
848
|
+
}), React__default.createElement(StyledTooltipWrapper, {
|
|
849
|
+
ref: setFloatingElement,
|
|
850
|
+
style: {
|
|
851
|
+
transform
|
|
852
|
+
},
|
|
853
|
+
placement: placement,
|
|
898
854
|
zIndex: zIndex,
|
|
899
855
|
isAnimated: isAnimated
|
|
900
|
-
},
|
|
856
|
+
}, React__default.createElement(StyledTooltipModal, _extends$2({
|
|
901
857
|
transitionState: transitionState,
|
|
902
|
-
placement:
|
|
858
|
+
placement: placement,
|
|
903
859
|
hasArrow: hasArrow,
|
|
904
860
|
isAnimated: isAnimated
|
|
905
861
|
}, modalProps, ariaProps, props, {
|
|
@@ -918,7 +874,6 @@ TooltipModalComponent.defaultProps = {
|
|
|
918
874
|
TooltipModalComponent.propTypes = {
|
|
919
875
|
appendToNode: PropTypes.any,
|
|
920
876
|
referenceElement: PropTypes.any,
|
|
921
|
-
popperModifiers: PropTypes.any,
|
|
922
877
|
placement: PropTypes.any,
|
|
923
878
|
isAnimated: PropTypes.bool,
|
|
924
879
|
hasArrow: PropTypes.bool,
|
|
@@ -956,13 +911,13 @@ const HeaderComponent = forwardRef((_ref, ref) => {
|
|
|
956
911
|
}
|
|
957
912
|
};
|
|
958
913
|
}, [hasHeader, setHasHeader]);
|
|
959
|
-
return React__default.createElement(
|
|
914
|
+
return React__default.createElement(StyledDrawerHeader, _extends$2({}, getTitleProps(other), {
|
|
960
915
|
as: tag,
|
|
961
916
|
isCloseButtonPresent: isCloseButtonPresent,
|
|
962
917
|
ref: ref
|
|
963
918
|
}));
|
|
964
919
|
});
|
|
965
|
-
HeaderComponent.displayName = '
|
|
920
|
+
HeaderComponent.displayName = 'Drawer.Header';
|
|
966
921
|
HeaderComponent.propTypes = {
|
|
967
922
|
tag: PropTypes.any
|
|
968
923
|
};
|
|
@@ -975,11 +930,11 @@ const BodyComponent = forwardRef((props, ref) => {
|
|
|
975
930
|
const {
|
|
976
931
|
getContentProps
|
|
977
932
|
} = useModalContext();
|
|
978
|
-
return React__default.createElement(
|
|
933
|
+
return React__default.createElement(StyledDrawerBody, _extends$2({}, getContentProps(props), {
|
|
979
934
|
ref: ref
|
|
980
935
|
}), props.children);
|
|
981
936
|
});
|
|
982
|
-
BodyComponent.displayName = '
|
|
937
|
+
BodyComponent.displayName = 'Drawer.Body';
|
|
983
938
|
const Body = BodyComponent;
|
|
984
939
|
|
|
985
940
|
const CloseComponent = forwardRef((props, ref) => {
|
|
@@ -992,29 +947,29 @@ const CloseComponent = forwardRef((props, ref) => {
|
|
|
992
947
|
return () => setIsCloseButtonPresent(false);
|
|
993
948
|
});
|
|
994
949
|
const ariaLabel = useText(CloseComponent, props, 'aria-label', 'Close drawer');
|
|
995
|
-
return React__default.createElement(
|
|
950
|
+
return React__default.createElement(StyledDrawerClose, _extends$2({}, getCloseProps({
|
|
996
951
|
...props,
|
|
997
952
|
'aria-label': ariaLabel
|
|
998
953
|
}), {
|
|
999
954
|
ref: ref
|
|
1000
955
|
}), React__default.createElement(SvgXStroke, null));
|
|
1001
956
|
});
|
|
1002
|
-
CloseComponent.displayName = '
|
|
957
|
+
CloseComponent.displayName = 'Drawer.Close';
|
|
1003
958
|
const Close = CloseComponent;
|
|
1004
959
|
|
|
1005
|
-
const FooterComponent = forwardRef((props, ref) => React__default.createElement(
|
|
960
|
+
const FooterComponent = forwardRef((props, ref) => React__default.createElement(StyledDrawerFooter, _extends$2({
|
|
1006
961
|
ref: ref
|
|
1007
962
|
}, props)));
|
|
1008
|
-
FooterComponent.displayName = '
|
|
963
|
+
FooterComponent.displayName = 'Drawer.Footer';
|
|
1009
964
|
const Footer = FooterComponent;
|
|
1010
965
|
|
|
1011
|
-
const FooterItemComponent = forwardRef((props, ref) => React__default.createElement(
|
|
966
|
+
const FooterItemComponent = forwardRef((props, ref) => React__default.createElement(StyledDrawerFooterItem, _extends$2({
|
|
1012
967
|
ref: ref
|
|
1013
968
|
}, props)));
|
|
1014
|
-
FooterItemComponent.displayName = '
|
|
969
|
+
FooterItemComponent.displayName = 'Drawer.FooterItem';
|
|
1015
970
|
const FooterItem = FooterItemComponent;
|
|
1016
971
|
|
|
1017
|
-
const
|
|
972
|
+
const DrawerComponent = forwardRef((_ref, ref) => {
|
|
1018
973
|
let {
|
|
1019
974
|
id,
|
|
1020
975
|
isOpen,
|
|
@@ -1114,7 +1069,7 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1114
1069
|
const defaultValue = hasHeader ? modalProps['aria-labelledby'] : 'Modal dialog';
|
|
1115
1070
|
const labelValue = hasHeader ? modalProps['aria-labelledby'] : props['aria-label'];
|
|
1116
1071
|
const ariaProps = {
|
|
1117
|
-
[attribute]: useText(
|
|
1072
|
+
[attribute]: useText(DrawerComponent, {
|
|
1118
1073
|
[attribute]: labelValue
|
|
1119
1074
|
}, attribute, defaultValue)
|
|
1120
1075
|
};
|
|
@@ -1131,12 +1086,12 @@ const DrawerModalComponent = forwardRef((_ref, ref) => {
|
|
|
1131
1086
|
nodeRef: transitionRef
|
|
1132
1087
|
}, React__default.createElement(StyledBackdrop, _extends$2({
|
|
1133
1088
|
isAnimated: true
|
|
1134
|
-
}, getBackdropProps(backdropProps)), React__default.createElement(
|
|
1089
|
+
}, getBackdropProps(backdropProps)), React__default.createElement(StyledDrawer, _extends$2({}, modalProps, ariaProps, props, {
|
|
1135
1090
|
ref: mergeRefs([ref, modalRef, transitionRef])
|
|
1136
1091
|
}))))), rootNode);
|
|
1137
1092
|
});
|
|
1138
|
-
|
|
1139
|
-
|
|
1093
|
+
DrawerComponent.displayName = 'Drawer';
|
|
1094
|
+
DrawerComponent.propTypes = {
|
|
1140
1095
|
backdropProps: PropTypes.object,
|
|
1141
1096
|
focusOnMount: PropTypes.bool,
|
|
1142
1097
|
restoreFocus: PropTypes.bool,
|
|
@@ -1144,17 +1099,17 @@ DrawerModalComponent.propTypes = {
|
|
|
1144
1099
|
appendToNode: PropTypes.any,
|
|
1145
1100
|
isOpen: PropTypes.bool
|
|
1146
1101
|
};
|
|
1147
|
-
|
|
1102
|
+
DrawerComponent.defaultProps = {
|
|
1148
1103
|
focusOnMount: true ,
|
|
1149
1104
|
restoreFocus: true
|
|
1150
1105
|
};
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1106
|
+
const Drawer = DrawerComponent;
|
|
1107
|
+
Drawer.Body = Body;
|
|
1108
|
+
Drawer.Close = Close;
|
|
1109
|
+
Drawer.Footer = Footer;
|
|
1110
|
+
Drawer.FooterItem = FooterItem;
|
|
1111
|
+
Drawer.Header = Header;
|
|
1157
1112
|
|
|
1158
|
-
const PLACEMENT = ['auto',
|
|
1113
|
+
const PLACEMENT = ['auto', ...PLACEMENT$1];
|
|
1159
1114
|
|
|
1160
|
-
export { Body$2 as Body, Close$2 as Close,
|
|
1115
|
+
export { Body$2 as Body, Close$2 as Close, Drawer, Footer$2 as Footer, FooterItem$2 as FooterItem, Header$1 as Header, Modal, PLACEMENT, TooltipModal };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { IDrawerProps } from '../../types';
|
|
9
9
|
import { Header } from './Header';
|
|
10
10
|
import { Body } from './Body';
|
|
11
11
|
import { Close } from './Close';
|
|
@@ -14,7 +14,7 @@ import { FooterItem } from './FooterItem';
|
|
|
14
14
|
/**
|
|
15
15
|
* @extends HTMLAttributes<HTMLDivElement>
|
|
16
16
|
*/
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const Drawer: React.ForwardRefExoticComponent<IDrawerProps & React.RefAttributes<HTMLDivElement>> & {
|
|
18
18
|
Body: typeof Body;
|
|
19
19
|
Close: typeof Close;
|
|
20
20
|
Footer: typeof Footer;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { IDrawerHeaderProps } from '../../types';
|
|
9
9
|
/**
|
|
10
10
|
* @extends HTMLAttributes<HTMLDivElement>
|
|
11
11
|
*/
|
|
12
|
-
export declare const Header: React.ForwardRefExoticComponent<
|
|
12
|
+
export declare const Header: React.ForwardRefExoticComponent<IDrawerHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { Footer } from './elements/Footer';
|
|
|
11
11
|
export { FooterItem } from './elements/FooterItem';
|
|
12
12
|
export { Header } from './elements/Header';
|
|
13
13
|
export { TooltipModal } from './elements/TooltipModal/TooltipModal';
|
|
14
|
-
export {
|
|
15
|
-
export { PLACEMENT, type IModalProps, type
|
|
14
|
+
export { Drawer } from './elements/Drawer/Drawer';
|
|
15
|
+
export { PLACEMENT, type IModalProps, type IDrawerProps, type ITooltipModalProps, type Placement as GARDEN_PLACEMENT } from './types';
|
|
@@ -8,7 +8,7 @@ import { DefaultTheme } from 'styled-components';
|
|
|
8
8
|
/**
|
|
9
9
|
* 1. Smooth iOS scrolling.
|
|
10
10
|
*/
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const StyledDrawer: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
12
12
|
'data-garden-id': string;
|
|
13
13
|
'data-garden-version': string;
|
|
14
14
|
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const StyledDrawerBody: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
8
8
|
'data-garden-id': string;
|
|
9
9
|
'data-garden-version': string;
|
|
10
10
|
} & {
|
|
@@ -9,7 +9,7 @@ export declare const BASE_MULTIPLIERS: {
|
|
|
9
9
|
side: number;
|
|
10
10
|
size: number;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const StyledDrawerClose: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {
|
|
13
13
|
'data-garden-id': string;
|
|
14
14
|
'data-garden-version': string;
|
|
15
15
|
} & {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const StyledDrawerFooter: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
8
8
|
'data-garden-id': string;
|
|
9
9
|
'data-garden-version': string;
|
|
10
10
|
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const StyledDrawerFooterItem: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {
|
|
8
8
|
'data-garden-id': string;
|
|
9
9
|
'data-garden-version': string;
|
|
10
10
|
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 1. the padding added to the Header is based on the close button size and spacing,
|
|
9
9
|
* with additional padding (+ 2) between the Header content and Close button
|
|
10
10
|
*/
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const StyledDrawerHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("./StyledHeader").IStyledHeaderProps & {
|
|
12
12
|
'data-garden-id': string;
|
|
13
13
|
'data-garden-version': string;
|
|
14
14
|
}, "data-garden-id" | "data-garden-version">;
|