@instructure/ui-tray 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +34 -288
  2. package/es/Tray/{index.js → v1/index.js} +2 -2
  3. package/es/Tray/v2/index.js +221 -0
  4. package/es/Tray/v2/props.js +26 -0
  5. package/es/Tray/v2/styles.js +131 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -3
  8. package/lib/Tray/v1/index.js +226 -0
  9. package/lib/Tray/{index.js → v2/index.js} +3 -4
  10. package/lib/Tray/v2/props.js +31 -0
  11. package/lib/Tray/v2/styles.js +137 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +43 -21
  15. package/src/Tray/{index.tsx → v1/index.tsx} +2 -2
  16. package/src/Tray/v2/README.md +100 -0
  17. package/src/Tray/v2/index.tsx +249 -0
  18. package/src/Tray/v2/props.ts +206 -0
  19. package/src/Tray/v2/styles.ts +158 -0
  20. package/src/exports/a.ts +26 -0
  21. package/src/exports/b.ts +26 -0
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/Tray/v1/index.d.ts.map +1 -0
  24. package/types/Tray/v1/props.d.ts.map +1 -0
  25. package/types/Tray/v1/styles.d.ts.map +1 -0
  26. package/types/Tray/v1/theme.d.ts.map +1 -0
  27. package/types/Tray/v2/index.d.ts +77 -0
  28. package/types/Tray/v2/index.d.ts.map +1 -0
  29. package/types/Tray/v2/props.d.ts +133 -0
  30. package/types/Tray/v2/props.d.ts.map +1 -0
  31. package/types/Tray/v2/styles.d.ts +20 -0
  32. package/types/Tray/v2/styles.d.ts.map +1 -0
  33. package/types/exports/a.d.ts +3 -0
  34. package/types/exports/a.d.ts.map +1 -0
  35. package/types/exports/b.d.ts +3 -0
  36. package/types/exports/b.d.ts.map +1 -0
  37. package/types/Tray/index.d.ts.map +0 -1
  38. package/types/Tray/props.d.ts.map +0 -1
  39. package/types/Tray/styles.d.ts.map +0 -1
  40. package/types/Tray/theme.d.ts.map +0 -1
  41. package/types/index.d.ts +0 -3
  42. package/types/index.d.ts.map +0 -1
  43. /package/es/Tray/{props.js → v1/props.js} +0 -0
  44. /package/es/Tray/{styles.js → v1/styles.js} +0 -0
  45. /package/es/Tray/{theme.js → v1/theme.js} +0 -0
  46. /package/lib/Tray/{props.js → v1/props.js} +0 -0
  47. /package/lib/Tray/{styles.js → v1/styles.js} +0 -0
  48. /package/lib/Tray/{theme.js → v1/theme.js} +0 -0
  49. /package/src/Tray/{README.md → v1/README.md} +0 -0
  50. /package/src/Tray/{props.ts → v1/props.ts} +0 -0
  51. /package/src/Tray/{styles.ts → v1/styles.ts} +0 -0
  52. /package/src/Tray/{theme.ts → v1/theme.ts} +0 -0
  53. /package/types/Tray/{index.d.ts → v1/index.d.ts} +0 -0
  54. /package/types/Tray/{props.d.ts → v1/props.d.ts} +0 -0
  55. /package/types/Tray/{styles.d.ts → v1/styles.d.ts} +0 -0
  56. /package/types/Tray/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _uiThemes = require("@instructure/ui-themes");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param {Object} componentTheme The theme variable object.
38
+ * @param {Object} params the props and passed through data of the component, the style is applied to
39
+ * @return {Object} The final style object, which will be used in the component
40
+ */
41
+ const generateStyle = (componentTheme, params) => {
42
+ const border = params.border,
43
+ shadow = params.shadow,
44
+ size = params.size,
45
+ placement = params.placement;
46
+ const borderStyle = {
47
+ borderWidth: 0,
48
+ borderColor: componentTheme.borderColor,
49
+ borderStyle: 'solid'
50
+ };
51
+ const shadowStyle = shadow ? {
52
+ boxShadow: (0, _uiThemes.boxShadowObjectsToCSSString)(componentTheme.boxShadow)
53
+ } : {};
54
+ const contentStyle = placement === 'start' || placement === 'end' || placement === 'center' ? {
55
+ label: 'tray__content',
56
+ minHeight: '100vh'
57
+ } : {};
58
+ const placementStyles = {
59
+ top: {
60
+ insetInlineStart: 0,
61
+ insetInlineEnd: 0,
62
+ top: 0
63
+ },
64
+ bottom: {
65
+ insetInlineStart: 0,
66
+ insetInlineEnd: 0,
67
+ bottom: 0
68
+ },
69
+ start: {
70
+ top: 0,
71
+ bottom: 0,
72
+ insetInlineStart: 0,
73
+ insetInlineEnd: 'auto'
74
+ },
75
+ end: {
76
+ top: 0,
77
+ bottom: 0,
78
+ insetInlineEnd: 0,
79
+ insetInlineStart: 'auto'
80
+ },
81
+ center: {
82
+ left: 0,
83
+ right: 0,
84
+ top: 0,
85
+ bottom: 0
86
+ }
87
+ };
88
+ const borderPlacementStyle = border ? {
89
+ start: {
90
+ borderInlineEndWidth: componentTheme.borderWidth
91
+ },
92
+ end: {
93
+ borderInlineStartWidth: componentTheme.borderWidth
94
+ },
95
+ top: {
96
+ borderBottomWidth: componentTheme.borderWidth
97
+ },
98
+ bottom: {
99
+ borderTopWidth: componentTheme.borderWidth
100
+ },
101
+ center: {}
102
+ } : {};
103
+ const sizeVariants = {
104
+ 'x-small': componentTheme.widthXs,
105
+ small: componentTheme.widthSm,
106
+ regular: componentTheme.widthMd,
107
+ medium: componentTheme.widthLg,
108
+ large: componentTheme.widthXl
109
+ };
110
+ const sizeStyle = placement === 'start' || placement === 'end' ? {
111
+ width: sizeVariants[size]
112
+ } : {};
113
+ return {
114
+ tray: {
115
+ label: 'tray',
116
+ padding: componentTheme.padding,
117
+ backgroundColor: componentTheme.backgroundColor,
118
+ position: 'fixed',
119
+ overflowY: 'auto',
120
+ overflowX: 'hidden',
121
+ boxSizing: 'border-box',
122
+ zIndex: componentTheme.zIndex,
123
+ maxWidth: '100vw',
124
+ maxHeight: '100vh',
125
+ ...shadowStyle,
126
+ ...placementStyles[placement],
127
+ ...(border && borderStyle),
128
+ ...(border && borderPlacementStyle[placement]),
129
+ ...sizeStyle
130
+ },
131
+ content: {
132
+ label: 'tray__content',
133
+ ...contentStyle
134
+ }
135
+ };
136
+ };
137
+ var _default = exports.default = generateStyle;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Tray", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Tray.Tray;
9
+ return _v.Tray;
10
10
  }
11
11
  });
12
- var _Tray = require("./Tray");
12
+ var _v = require("../Tray/v1");
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Tray", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.Tray;
10
+ }
11
+ });
12
+ var _v = require("../Tray/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tray",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "Tray component for secondary/menu content",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,25 +15,25 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.6.0",
19
- "@instructure/ui-dialog": "11.6.0",
20
- "@instructure/emotion": "11.6.0",
21
- "@instructure/ui-i18n": "11.6.0",
22
- "@instructure/shared-types": "11.6.0",
23
- "@instructure/ui-motion": "11.6.0",
24
- "@instructure/ui-overlays": "11.6.0",
25
- "@instructure/ui-portal": "11.6.0",
26
- "@instructure/ui-utils": "11.6.0",
27
- "@instructure/ui-react-utils": "11.6.0",
28
- "@instructure/ui-position": "11.6.0"
18
+ "@instructure/emotion": "11.6.1-snapshot-129",
19
+ "@instructure/console": "11.6.1-snapshot-129",
20
+ "@instructure/shared-types": "11.6.1-snapshot-129",
21
+ "@instructure/ui-dialog": "11.6.1-snapshot-129",
22
+ "@instructure/ui-i18n": "11.6.1-snapshot-129",
23
+ "@instructure/ui-motion": "11.6.1-snapshot-129",
24
+ "@instructure/ui-overlays": "11.6.1-snapshot-129",
25
+ "@instructure/ui-portal": "11.6.1-snapshot-129",
26
+ "@instructure/ui-position": "11.6.1-snapshot-129",
27
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
28
+ "@instructure/ui-utils": "11.6.1-snapshot-129"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@testing-library/jest-dom": "^6.6.3",
32
32
  "@testing-library/react": "15.0.7",
33
33
  "@testing-library/user-event": "^14.6.1",
34
34
  "vitest": "^3.2.2",
35
- "@instructure/ui-themes": "11.6.0",
36
- "@instructure/ui-babel-preset": "11.6.0"
35
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129",
36
+ "@instructure/ui-themes": "11.6.1-snapshot-129"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=18 <=19"
@@ -43,17 +43,39 @@
43
43
  },
44
44
  "sideEffects": false,
45
45
  "exports": {
46
- ".": {
47
- "types": "./types/index.d.ts",
48
- "import": "./es/index.js",
49
- "require": "./lib/index.js",
50
- "default": "./es/index.js"
51
- },
52
46
  "./lib/*": "./lib/*",
53
47
  "./es/*": "./es/*",
54
48
  "./types/*": "./types/*",
55
49
  "./package.json": "./package.json",
56
- "./src/*": "./src/*"
50
+ "./src/*": "./src/*",
51
+ ".": {
52
+ "src": "./src/exports/a.ts",
53
+ "types": "./types/exports/a.d.ts",
54
+ "import": "./es/exports/a.js",
55
+ "require": "./lib/exports/a.js",
56
+ "default": "./es/exports/a.js"
57
+ },
58
+ "./v11_6": {
59
+ "src": "./src/exports/a.ts",
60
+ "types": "./types/exports/a.d.ts",
61
+ "import": "./es/exports/a.js",
62
+ "require": "./lib/exports/a.js",
63
+ "default": "./es/exports/a.js"
64
+ },
65
+ "./v11_7": {
66
+ "src": "./src/exports/b.ts",
67
+ "types": "./types/exports/b.d.ts",
68
+ "import": "./es/exports/b.js",
69
+ "require": "./lib/exports/b.js",
70
+ "default": "./es/exports/b.js"
71
+ },
72
+ "./latest": {
73
+ "src": "./src/exports/b.ts",
74
+ "types": "./types/exports/b.d.ts",
75
+ "import": "./es/exports/b.js",
76
+ "require": "./lib/exports/b.js",
77
+ "default": "./es/exports/b.js"
78
+ }
57
79
  },
58
80
  "scripts": {
59
81
  "lint": "ui-scripts lint",
@@ -33,12 +33,12 @@ import type { PortalNode } from '@instructure/ui-portal'
33
33
  import { mirrorHorizontalPlacement } from '@instructure/ui-position'
34
34
  import { Transition } from '@instructure/ui-motion'
35
35
  import type { TransitionType } from '@instructure/ui-motion'
36
- import { withStyle } from '@instructure/emotion'
36
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
37
37
  import generateStyle from './styles'
38
38
  import generateComponentTheme from './theme'
39
39
  import { allowedProps } from './props'
40
40
  import type { TrayProps, TrayState } from './props'
41
- import { Mask } from '@instructure/ui-overlays'
41
+ import { Mask } from '@instructure/ui-overlays/v11_6'
42
42
 
43
43
  /**
44
44
  ---
@@ -0,0 +1,100 @@
1
+ ---
2
+ describes: Tray
3
+ ---
4
+
5
+ The Tray is an actionable container that is triggered by click and does not need to be connected to the element that triggered it. The Tray is on the same hierarchy as the Popover but contains more content. The Tray slides out from the top/bottom/start/end of the viewport.
6
+
7
+ > Note that the `size` property only applies when the Tray is positioned at `start` or `end` and defines the width of the Tray.
8
+
9
+ ```js
10
+ ---
11
+ type: example
12
+ ---
13
+ const FPO = lorem.paragraph()
14
+
15
+ const Example = () => {
16
+ const [open, setOpen] = useState(false)
17
+
18
+ const hideTray = () => {
19
+ setOpen(false)
20
+ }
21
+
22
+ const renderCloseButton = () => (
23
+ <Flex>
24
+ <Flex.Item>
25
+ <CloseButton
26
+ placement="end"
27
+ offset="small"
28
+ screenReaderLabel="Close"
29
+ onClick={hideTray}
30
+ />
31
+ </Flex.Item>
32
+ <Flex.Item shouldGrow shouldShrink>
33
+ <Heading>Hello</Heading>
34
+ </Flex.Item>
35
+ </Flex>
36
+ )
37
+
38
+ return (
39
+ <div style={{ padding: '0 0 16rem 0', margin: '0 auto' }}>
40
+ <Button onClick={() => setOpen(true)}>Show the Tray</Button>
41
+ <Tray
42
+ label="Tray Example"
43
+ open={open}
44
+ onDismiss={() => setOpen(false)}
45
+ size="small"
46
+ placement="start"
47
+ >
48
+ <View as="div" padding="medium">
49
+ {renderCloseButton()}
50
+ <Text as="p" lineHeight="double">
51
+ {FPO}
52
+ </Text>
53
+ </View>
54
+ </Tray>
55
+ </div>
56
+ )
57
+ }
58
+
59
+ render(<Example />)
60
+ ```
61
+
62
+ ### Guidelines
63
+
64
+ ```js
65
+ ---
66
+ type: embed
67
+ ---
68
+ <Guidelines>
69
+ <Figure recommendation="yes" title="Do">
70
+ <Figure.Item>Configure Tray to enter from the end on desktop, bottom on mobile/tablet</Figure.Item>
71
+ <Figure.Item>Use when it is useful to still see information contained on the page or not lose context of the page that triggered the Tray</Figure.Item>
72
+ <Figure.Item>Use 2 tabs max if using TabList in small size</Figure.Item>
73
+ <Figure.Item>Use 5 tabs max if using TabList in medium/large size</Figure.Item>
74
+ <Figure.Item>Prefer Tray to close when user clicks outside of the Tray</Figure.Item>
75
+ <Figure.Item>Keep the close 'x' directly following the Tray title, no matter what side the Tray slides from</Figure.Item>
76
+ </Figure>
77
+ <Figure recommendation="no" title="Don't">
78
+ <Figure.Item>Use TabList in the x-small size</Figure.Item>
79
+ <Figure.Item>Use for Sub Nav or <Link href="/#DrawerLayout">Drawer Layout</Link></Figure.Item>
80
+ <Figure.Item>Use with an <Link href="/#Overlay">Overlay</Link></Figure.Item>
81
+ <Figure.Item>Use a Tray on top of a <Link href="/#Modal">Modal</Link></Figure.Item>
82
+ <Figure.Item>Use for <Link href="#Alert">Alerts</Link> or Confirmation Dialogs</Figure.Item>
83
+ <Figure.Item>Allow Tray to push the content of the page</Figure.Item>
84
+ </Figure>
85
+ </Guidelines>
86
+ ```
87
+
88
+ ```js
89
+ ---
90
+ type: embed
91
+ ---
92
+ <Guidelines>
93
+ <Figure recommendation="a11y" title="Accessibility">
94
+ <Figure.Item>Keyboard focus must be set in the tray when it appears; usually on the first interactive element</Figure.Item>
95
+ <Figure.Item>Trays must contain keyboard focus until they’re closed. This is to ensure that keyboard or screen reader users won't mistakenly interact with background content that is meant to be hidden or inaccessible</Figure.Item>
96
+ <Figure.Item>When a user closes a tray, focus must return to a logical place within the page. This is usually the element that triggered opening the tray</Figure.Item>
97
+ <Figure.Item>We recommend that trays begin with a heading (typically H2). However, when configuring the component, the button to close the Tray should precede the heading. This ensures screen readers announce the Tray's content in a logical order.</Figure.Item>
98
+ </Figure>
99
+ </Guidelines>
100
+ ```
@@ -0,0 +1,249 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component, createRef } from 'react'
26
+
27
+ import { Dialog } from '@instructure/ui-dialog'
28
+ import { omitProps } from '@instructure/ui-react-utils'
29
+ import { createChainedFunction } from '@instructure/ui-utils'
30
+ import { textDirectionContextConsumer } from '@instructure/ui-i18n'
31
+ import { Portal } from '@instructure/ui-portal'
32
+ import type { PortalNode } from '@instructure/ui-portal'
33
+ import { mirrorHorizontalPlacement } from '@instructure/ui-position'
34
+ import { Transition } from '@instructure/ui-motion'
35
+ import type { TransitionType } from '@instructure/ui-motion'
36
+ import { withStyle } from '@instructure/emotion'
37
+ import generateStyle from './styles'
38
+ import { allowedProps } from './props'
39
+ import type { TrayProps, TrayState } from './props'
40
+ import { Mask } from '@instructure/ui-overlays/latest'
41
+
42
+ /**
43
+ ---
44
+ category: components
45
+ ---
46
+ **/
47
+ @withStyle(generateStyle)
48
+ @textDirectionContextConsumer()
49
+ class Tray extends Component<TrayProps> {
50
+ static readonly componentId = 'Tray'
51
+
52
+ static allowedProps = allowedProps
53
+
54
+ static defaultProps = {
55
+ defaultFocusElement: null,
56
+ open: false,
57
+ insertAt: 'bottom',
58
+ shouldCloseOnDocumentClick: false,
59
+ shouldContainFocus: true,
60
+ shouldReturnFocus: true,
61
+ size: 'small',
62
+ placement: 'start',
63
+ transitionOnMount: true,
64
+ transitionEnter: true,
65
+ transitionExit: true,
66
+ shadow: true,
67
+ border: false,
68
+ enableMask: false
69
+ }
70
+ ref: Element | null = null
71
+ dialogRef = createRef<Dialog>()
72
+
73
+ state: TrayState
74
+
75
+ constructor(props: TrayProps) {
76
+ super(props)
77
+ this.state = {
78
+ transitioning: false,
79
+ open: props.open ?? false
80
+ }
81
+ }
82
+
83
+ componentDidMount() {
84
+ this.props.makeStyles?.()
85
+ }
86
+
87
+ componentDidUpdate(prevProps: TrayProps, _prevState: TrayState) {
88
+ if (this.props.open !== prevProps.open) {
89
+ if (!this.props.open) {
90
+ // calling Dialog.close() to remove focusregion immediately when transition starts
91
+ // so if a new Tray is opened (during transition) the new focusregion won't get treated as a child of this one
92
+ this.dialogRef.current?.close()
93
+ }
94
+
95
+ this.setState({ transitioning: true, open: this.props.open })
96
+ }
97
+ this.props.makeStyles?.()
98
+ }
99
+
100
+ get placement() {
101
+ const { placement, dir } = this.props
102
+ const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl
103
+ return isRtl ? mirrorHorizontalPlacement(placement!, ' ') : placement
104
+ }
105
+
106
+ get direction() {
107
+ switch (this.placement) {
108
+ case 'top':
109
+ return 'up'
110
+ case 'bottom':
111
+ return 'down'
112
+ case 'end':
113
+ return 'right'
114
+ default:
115
+ // start
116
+ return 'left'
117
+ }
118
+ }
119
+
120
+ get transition(): TransitionType {
121
+ return `slide-${this.direction}`
122
+ }
123
+
124
+ handleTransitionComplete = (_type?: TransitionType) => {
125
+ this.setState({ transitioning: false })
126
+ }
127
+
128
+ get DOMNode() {
129
+ // The DOMNode property is needed for Portal type components
130
+ return this.ref
131
+ }
132
+
133
+ set DOMNode(el) {
134
+ this.ref = el ? el : null
135
+ }
136
+
137
+ handlePortalOpen = (DOMNode: PortalNode) => {
138
+ if (DOMNode) {
139
+ this.DOMNode = DOMNode
140
+ }
141
+ }
142
+
143
+ render() {
144
+ const {
145
+ label,
146
+ children,
147
+ size,
148
+ placement,
149
+ open,
150
+ defaultFocusElement,
151
+ contentRef,
152
+ shouldContainFocus,
153
+ shouldReturnFocus,
154
+ shouldCloseOnDocumentClick,
155
+ onOpen,
156
+ onClose,
157
+ onDismiss,
158
+ mountNode,
159
+ insertAt,
160
+ liveRegion,
161
+ onEnter,
162
+ onEntering,
163
+ onEntered,
164
+ onExit,
165
+ onExiting,
166
+ onExited,
167
+ onTransition,
168
+ transitionOnMount,
169
+ transitionEnter,
170
+ transitionExit,
171
+ border,
172
+ shadow,
173
+ role,
174
+ enableMask,
175
+ ...props
176
+ } = this.props
177
+
178
+ const portalIsOpen = this.state.open || this.state.transitioning
179
+
180
+ const content = (
181
+ <Transition
182
+ in={open}
183
+ type={this.transition}
184
+ onTransition={onTransition}
185
+ onEnter={onEnter}
186
+ onEntering={onEntering}
187
+ onEntered={createChainedFunction(
188
+ this.handleTransitionComplete,
189
+ onEntered,
190
+ onOpen
191
+ )}
192
+ onExit={onExit}
193
+ onExiting={onExiting}
194
+ onExited={createChainedFunction(
195
+ this.handleTransitionComplete,
196
+ onExited,
197
+ onClose
198
+ )}
199
+ transitionOnMount={transitionOnMount}
200
+ transitionEnter={transitionEnter}
201
+ transitionExit={transitionExit}
202
+ >
203
+ <span
204
+ {...omitProps(props, Tray.allowedProps)}
205
+ css={this.props.styles?.tray}
206
+ ref={contentRef}
207
+ >
208
+ <Dialog
209
+ ref={this.dialogRef}
210
+ as="div"
211
+ label={label}
212
+ defaultFocusElement={defaultFocusElement}
213
+ open
214
+ shouldContainFocus={shouldContainFocus}
215
+ shouldReturnFocus={shouldReturnFocus}
216
+ shouldCloseOnDocumentClick={shouldCloseOnDocumentClick}
217
+ shouldCloseOnEscape
218
+ liveRegion={liveRegion}
219
+ onDismiss={onDismiss}
220
+ role={role}
221
+ >
222
+ <div css={this.props.styles?.content}>{children}</div>
223
+ </Dialog>
224
+ </span>
225
+ </Transition>
226
+ )
227
+
228
+ return (
229
+ <Portal
230
+ open={portalIsOpen}
231
+ onOpen={this.handlePortalOpen}
232
+ insertAt={insertAt}
233
+ mountNode={mountNode}
234
+ data-cid="Tray"
235
+ >
236
+ {enableMask ? (
237
+ <Mask placement={'center'} fullscreen={true}>
238
+ {content}
239
+ </Mask>
240
+ ) : (
241
+ content
242
+ )}
243
+ </Portal>
244
+ )
245
+ }
246
+ }
247
+
248
+ export default Tray
249
+ export { Tray }