@instructure/ui-drawer-layout 8.8.1-snapshot.8 → 8.9.1

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 (51) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es/DrawerLayout/DrawerContent/index.js +5 -17
  3. package/{src/DrawerLayout/DrawerContent/types.ts → es/DrawerLayout/DrawerContent/props.js} +13 -12
  4. package/es/DrawerLayout/DrawerTray/index.js +7 -114
  5. package/es/DrawerLayout/DrawerTray/props.js +126 -0
  6. package/es/DrawerLayout/index.js +5 -27
  7. package/es/DrawerLayout/props.js +49 -0
  8. package/lib/DrawerLayout/DrawerContent/index.js +6 -18
  9. package/{src/DrawerLayout/types.ts → lib/DrawerLayout/DrawerContent/props.js} +24 -10
  10. package/lib/DrawerLayout/DrawerTray/index.js +8 -116
  11. package/lib/DrawerLayout/DrawerTray/props.js +139 -0
  12. package/lib/DrawerLayout/index.js +6 -29
  13. package/lib/DrawerLayout/props.js +64 -0
  14. package/package.json +22 -23
  15. package/src/DrawerLayout/DrawerContent/index.tsx +9 -19
  16. package/src/DrawerLayout/DrawerContent/props.ts +69 -0
  17. package/src/DrawerLayout/DrawerContent/styles.ts +1 -1
  18. package/src/DrawerLayout/DrawerTray/index.tsx +33 -108
  19. package/src/DrawerLayout/DrawerTray/props.ts +205 -0
  20. package/src/DrawerLayout/DrawerTray/styles.ts +1 -1
  21. package/src/DrawerLayout/index.tsx +6 -27
  22. package/src/DrawerLayout/props.ts +75 -0
  23. package/src/index.ts +3 -3
  24. package/types/DrawerLayout/DrawerContent/index.d.ts +15 -14
  25. package/types/DrawerLayout/DrawerContent/index.d.ts.map +1 -1
  26. package/types/DrawerLayout/DrawerContent/props.d.ts +21 -0
  27. package/types/DrawerLayout/DrawerContent/props.d.ts.map +1 -0
  28. package/types/DrawerLayout/DrawerContent/styles.d.ts +1 -1
  29. package/types/DrawerLayout/DrawerTray/index.d.ts +3 -91
  30. package/types/DrawerLayout/DrawerTray/index.d.ts.map +1 -1
  31. package/types/DrawerLayout/DrawerTray/{types.d.ts → props.d.ts} +17 -10
  32. package/types/DrawerLayout/DrawerTray/props.d.ts.map +1 -0
  33. package/types/DrawerLayout/DrawerTray/styles.d.ts +1 -1
  34. package/types/DrawerLayout/index.d.ts +3 -21
  35. package/types/DrawerLayout/index.d.ts.map +1 -1
  36. package/types/DrawerLayout/props.d.ts +17 -0
  37. package/types/DrawerLayout/props.d.ts.map +1 -0
  38. package/types/index.d.ts +3 -3
  39. package/LICENSE.md +0 -27
  40. package/es/DrawerLayout/DrawerContent/types.js +0 -1
  41. package/es/DrawerLayout/DrawerTray/types.js +0 -1
  42. package/es/DrawerLayout/types.js +0 -1
  43. package/lib/DrawerLayout/DrawerContent/types.js +0 -1
  44. package/lib/DrawerLayout/DrawerTray/types.js +0 -1
  45. package/lib/DrawerLayout/types.js +0 -1
  46. package/src/DrawerLayout/DrawerTray/types.ts +0 -72
  47. package/types/DrawerLayout/DrawerContent/types.d.ts +0 -12
  48. package/types/DrawerLayout/DrawerContent/types.d.ts.map +0 -1
  49. package/types/DrawerLayout/DrawerTray/types.d.ts.map +0 -1
  50. package/types/DrawerLayout/types.d.ts +0 -9
  51. package/types/DrawerLayout/types.d.ts.map +0 -1
@@ -21,12 +21,8 @@ exports.DrawerLayoutContext = exports.DrawerLayout = exports.default = void 0;
21
21
 
22
22
  var _react = require("react");
23
23
 
24
- var _propTypes = _interopRequireDefault(require("prop-types"));
25
-
26
24
  var _bidirectional = require("@instructure/ui-i18n/lib/bidirectional.js");
27
25
 
28
- var _Children = require("@instructure/ui-prop-types/lib/Children.js");
29
-
30
26
  var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
31
27
 
32
28
  var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
@@ -53,6 +49,8 @@ var _emotion = require("@instructure/emotion");
53
49
 
54
50
  var _styles = _interopRequireDefault(require("./styles"));
55
51
 
52
+ var _props2 = require("./props");
53
+
56
54
  var _dec, _dec2, _dec3, _class, _class2, _temp;
57
55
 
58
56
  /**
@@ -244,40 +242,19 @@ let DrawerLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2
244
242
  }
245
243
 
246
244
  render() {
245
+ var _this$props$styles;
246
+
247
247
  const props = {
248
248
  [DrawerLayout.locatorAttribute]: this._id
249
249
  };
250
250
  return (0, _emotion.jsx)(DrawerLayoutContext.Provider, {
251
251
  value: this.state.shouldOverlayTray
252
252
  }, (0, _emotion.jsx)("div", Object.assign({}, props, {
253
- css: this.props.styles.drawerLayout
253
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerLayout
254
254
  }), this.renderChildren()));
255
255
  }
256
256
 
257
- }, _class2.displayName = "DrawerLayout", _class2.componentId = 'DrawerLayout', _class2.locatorAttribute = 'data-drawer-layout', _class2.propTypes = {
258
- /**
259
- * Exactly one of each of the following child types: `DrawerLayout.Content`, `DrawerLayout.Tray`
260
- */
261
- children: _Children.Children.oneOfEach([_DrawerContent.DrawerContent, _DrawerTray.DrawerTray]),
262
-
263
- /**
264
- * Min width for the `<DrawerLayout.Content />`
265
- */
266
- minWidth: _propTypes.default.string,
267
-
268
- /**
269
- * Function called when the `<DrawerLayout.Content />` is resized and hits the `minWidth` breakpoint
270
- * Called with a boolean value, `true` if the tray is now overlaying the content or `false` if
271
- * it is side by side
272
- */
273
- onOverlayTrayChange: _propTypes.default.func,
274
- // eslint-disable-next-line react/require-default-props
275
- makeStyles: _propTypes.default.func,
276
- // eslint-disable-next-line react/require-default-props
277
- styles: _propTypes.default.object,
278
- // eslint-disable-next-line react/require-default-props
279
- dir: _propTypes.default.oneOf(Object.values(_bidirectional.bidirectional.DIRECTION))
280
- }, _class2.defaultProps = {
257
+ }, _class2.displayName = "DrawerLayout", _class2.componentId = 'DrawerLayout', _class2.locatorAttribute = 'data-drawer-layout', _class2.propTypes = _props2.propTypes, _class2.allowedProps = _props2.allowedProps, _class2.defaultProps = {
281
258
  children: null,
282
259
  minWidth: '30rem',
283
260
  onOverlayTrayChange: shouldOverlayTray => {}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.allowedProps = exports.propTypes = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _Children = require("@instructure/ui-prop-types/lib/Children.js");
13
+
14
+ var _bidirectional = require("@instructure/ui-i18n/lib/bidirectional.js");
15
+
16
+ var _DrawerContent = require("./DrawerContent");
17
+
18
+ var _DrawerTray = require("./DrawerTray");
19
+
20
+ /*
21
+ * The MIT License (MIT)
22
+ *
23
+ * Copyright (c) 2015 - present Instructure, Inc.
24
+ *
25
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ * of this software and associated documentation files (the "Software"), to deal
27
+ * in the Software without restriction, including without limitation the rights
28
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ * copies of the Software, and to permit persons to whom the Software is
30
+ * furnished to do so, subject to the following conditions:
31
+ *
32
+ * The above copyright notice and this permission notice shall be included in all
33
+ * copies or substantial portions of the Software.
34
+ *
35
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ * SOFTWARE.
42
+ */
43
+ const propTypes = {
44
+ /**
45
+ * Exactly one of each of the following child types: `DrawerLayout.Content`, `DrawerLayout.Tray`
46
+ */
47
+ children: _Children.Children.oneOfEach([_DrawerContent.DrawerContent, _DrawerTray.DrawerTray]),
48
+
49
+ /**
50
+ * Min width for the `<DrawerLayout.Content />`
51
+ */
52
+ minWidth: _propTypes.default.string,
53
+
54
+ /**
55
+ * Function called when the `<DrawerLayout.Content />` is resized and hits the `minWidth` breakpoint
56
+ * Called with a boolean value, `true` if the tray is now overlaying the content or `false` if
57
+ * it is side by side
58
+ */
59
+ onOverlayTrayChange: _propTypes.default.func,
60
+ dir: _propTypes.default.oneOf(Object.values(_bidirectional.bidirectional.DIRECTION))
61
+ };
62
+ exports.propTypes = propTypes;
63
+ const allowedProps = ['children', 'minWidth', 'onOverlayTrayChange', 'dir'];
64
+ exports.allowedProps = allowedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-drawer-layout",
3
- "version": "8.8.1-snapshot.8+7b83164f4",
3
+ "version": "8.9.1",
4
4
  "description": "A main-content-plus-tray layout component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,29 +25,29 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/console": "8.8.1-snapshot.8+7b83164f4",
29
- "@instructure/debounce": "8.8.1-snapshot.8+7b83164f4",
30
- "@instructure/emotion": "8.8.1-snapshot.8+7b83164f4",
31
- "@instructure/shared-types": "8.8.1-snapshot.8+7b83164f4",
32
- "@instructure/ui-dialog": "8.8.1-snapshot.8+7b83164f4",
33
- "@instructure/ui-dom-utils": "8.8.1-snapshot.8+7b83164f4",
34
- "@instructure/ui-i18n": "8.8.1-snapshot.8+7b83164f4",
35
- "@instructure/ui-motion": "8.8.1-snapshot.8+7b83164f4",
36
- "@instructure/ui-portal": "8.8.1-snapshot.8+7b83164f4",
37
- "@instructure/ui-position": "8.8.1-snapshot.8+7b83164f4",
38
- "@instructure/ui-prop-types": "8.8.1-snapshot.8+7b83164f4",
39
- "@instructure/ui-react-utils": "8.8.1-snapshot.8+7b83164f4",
40
- "@instructure/ui-test-utils": "8.8.1-snapshot.8+7b83164f4",
41
- "@instructure/ui-testable": "8.8.1-snapshot.8+7b83164f4",
42
- "@instructure/ui-utils": "8.8.1-snapshot.8+7b83164f4",
43
- "@instructure/ui-view": "8.8.1-snapshot.8+7b83164f4",
44
- "@instructure/uid": "8.8.1-snapshot.8+7b83164f4",
28
+ "@instructure/console": "8.9.1",
29
+ "@instructure/debounce": "8.9.1",
30
+ "@instructure/emotion": "8.9.1",
31
+ "@instructure/shared-types": "8.9.1",
32
+ "@instructure/ui-dialog": "8.9.1",
33
+ "@instructure/ui-dom-utils": "8.9.1",
34
+ "@instructure/ui-i18n": "8.9.1",
35
+ "@instructure/ui-motion": "8.9.1",
36
+ "@instructure/ui-portal": "8.9.1",
37
+ "@instructure/ui-position": "8.9.1",
38
+ "@instructure/ui-prop-types": "8.9.1",
39
+ "@instructure/ui-react-utils": "8.9.1",
40
+ "@instructure/ui-test-utils": "8.9.1",
41
+ "@instructure/ui-testable": "8.9.1",
42
+ "@instructure/ui-utils": "8.9.1",
43
+ "@instructure/ui-view": "8.9.1",
44
+ "@instructure/uid": "8.9.1",
45
45
  "prop-types": "^15"
46
46
  },
47
47
  "devDependencies": {
48
- "@instructure/ui-babel-preset": "8.8.1-snapshot.8+7b83164f4",
49
- "@instructure/ui-test-locator": "8.8.1-snapshot.8+7b83164f4",
50
- "@instructure/ui-themes": "8.8.1-snapshot.8+7b83164f4"
48
+ "@instructure/ui-babel-preset": "8.9.1",
49
+ "@instructure/ui-test-locator": "8.9.1",
50
+ "@instructure/ui-themes": "8.9.1"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": ">=16.8 <=17"
@@ -55,6 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "sideEffects": false,
59
- "gitHead": "7b83164f4c5872f3a217e010563f59bf584ae4fc"
58
+ "sideEffects": false
60
59
  }
@@ -24,7 +24,6 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import { debounce } from '@instructure/debounce'
30
29
  import { getBoundingClientRect } from '@instructure/ui-dom-utils'
@@ -34,7 +33,12 @@ import { withStyle, jsx } from '@instructure/emotion'
34
33
 
35
34
  import generateStyle from './styles'
36
35
  import generateComponentTheme from './theme'
37
- import { DrawerLayoutContentProps, DrawerLayoutContentState } from './types'
36
+
37
+ import { propTypes, allowedProps } from './props'
38
+ import type {
39
+ DrawerLayoutContentProps,
40
+ DrawerLayoutContentState
41
+ } from './props'
38
42
 
39
43
  /**
40
44
  ---
@@ -51,22 +55,8 @@ class DrawerContent extends Component<
51
55
  static readonly componentId = 'DrawerLayout.Content'
52
56
 
53
57
  static locatorAttribute = 'data-drawer-content'
54
- static propTypes = {
55
- label: PropTypes.string.isRequired,
56
- children: PropTypes.node,
57
- contentRef: PropTypes.func,
58
- /**
59
- * Callback fired whenever the `<DrawerLayout.Content />` changes size
60
- */
61
- onSizeChange: PropTypes.func,
62
- role: PropTypes.string,
63
-
64
- // eslint-disable-next-line react/require-default-props
65
- makeStyles: PropTypes.func,
66
- // eslint-disable-next-line react/require-default-props
67
- styles: PropTypes.object
68
- }
69
-
58
+ static propTypes = propTypes
59
+ static allowedProps = allowedProps
70
60
  static defaultProps = {
71
61
  children: null,
72
62
  // @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
@@ -165,7 +155,7 @@ class DrawerContent extends Component<
165
155
  style={style}
166
156
  ref={this.handleContentRef}
167
157
  aria-label={label}
168
- css={this.props.styles.drawerContent}
158
+ css={this.props.styles?.drawerContent}
169
159
  >
170
160
  {this.props.children}
171
161
  </div>
@@ -0,0 +1,69 @@
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 React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import type { PropValidators } from '@instructure/shared-types'
29
+ import type { WithStyleProps } from '@instructure/emotion'
30
+
31
+ type DrawerLayoutContentOwnProps = {
32
+ label: string
33
+ children?: React.ReactNode
34
+ contentRef?: (...args: any[]) => any
35
+ onSizeChange?: (...args: any[]) => any
36
+ role?: string
37
+ }
38
+
39
+ type DrawerLayoutContentState = {
40
+ shouldTransition: boolean
41
+ }
42
+
43
+ type PropKeys = keyof DrawerLayoutContentOwnProps
44
+
45
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
46
+
47
+ type DrawerLayoutContentProps = DrawerLayoutContentOwnProps & WithStyleProps
48
+
49
+ const propTypes: PropValidators<PropKeys> = {
50
+ label: PropTypes.string.isRequired,
51
+ children: PropTypes.node,
52
+ contentRef: PropTypes.func,
53
+ /**
54
+ * Callback fired whenever the `<DrawerLayout.Content />` changes size
55
+ */
56
+ onSizeChange: PropTypes.func,
57
+ role: PropTypes.string
58
+ }
59
+
60
+ const allowedProps: AllowedPropKeys = [
61
+ 'label',
62
+ 'children',
63
+ 'contentRef',
64
+ 'onSizeChange',
65
+ 'role'
66
+ ]
67
+
68
+ export type { DrawerLayoutContentProps, DrawerLayoutContentState }
69
+ export { propTypes, allowedProps }
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { DrawerLayoutContentTheme } from '@instructure/shared-types'
26
- import { DrawerLayoutContentProps, DrawerLayoutContentState } from './types'
26
+ import { DrawerLayoutContentProps, DrawerLayoutContentState } from './props'
27
27
 
28
28
  /**
29
29
  * ---
@@ -23,27 +23,29 @@
23
23
  */
24
24
  /** @jsx jsx */
25
25
  import { Component } from 'react'
26
- import PropTypes from 'prop-types'
26
+
27
27
  import { withStyle, jsx } from '@instructure/emotion'
28
28
  import { bidirectional } from '@instructure/ui-i18n'
29
29
  import { Transition } from '@instructure/ui-motion'
30
30
  import { omitProps } from '@instructure/ui-react-utils'
31
- import { element } from '@instructure/ui-prop-types'
32
31
  import { createChainedFunction } from '@instructure/ui-utils'
33
32
  import { testable } from '@instructure/ui-testable'
34
33
  import { Dialog } from '@instructure/ui-dialog'
35
34
  import { Portal } from '@instructure/ui-portal'
36
35
  import type { PortalNode } from '@instructure/ui-portal'
37
36
  import { mirrorHorizontalPlacement } from '@instructure/ui-position'
37
+
38
38
  import generateStyle from './styles'
39
39
  import generateComponentTheme from './theme'
40
40
  import { DrawerLayoutContext } from '../index'
41
- import {
41
+
42
+ import { propTypes, allowedProps } from './props'
43
+ import type {
42
44
  DrawerLayoutTrayProps,
43
45
  DrawerLayoutTrayState,
44
46
  DrawerLayoutTrayStyleProps,
45
47
  DrawerTrayPlacement
46
- } from './types'
48
+ } from './props'
47
49
 
48
50
  /**
49
51
  ---
@@ -61,102 +63,11 @@ class DrawerTray extends Component<
61
63
  static readonly componentId = 'DrawerLayout.Tray' as const
62
64
 
63
65
  static locatorAttribute = 'data-drawer-tray'
64
- static propTypes = {
65
- label: PropTypes.string.isRequired,
66
- children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
67
- render: PropTypes.func,
68
- /**
69
- * Placement of the `<DrawerLayout.Tray />`
70
- */
71
- placement: PropTypes.oneOf(['start', 'end']),
72
- /**
73
- * If the tray is open or closed.
74
- */
75
- open: PropTypes.bool,
76
- /**
77
- * Called when the `<DrawerLayout.Tray />` is opened
78
- */
79
- onOpen: PropTypes.func,
80
- /**
81
- * Called when the `<DrawerLayout.Tray />` is closed
82
- */
83
- onClose: PropTypes.func,
84
- /**
85
- * Should the `<DrawerLayout.Tray />` have a border
86
- */
87
- border: PropTypes.bool,
88
- /**
89
- * Should the `<DrawerLayout.Tray />` have a shadow
90
- */
91
- shadow: PropTypes.bool,
92
- /**
93
- * Callback fired when the `<DrawerLayout.Tray />` transitions in/out
94
- */
95
- onTransition: PropTypes.func,
96
- /**
97
- * Callback fired before the `<DrawerLayout.Tray />` transitions in
98
- */
99
- onEnter: PropTypes.func,
100
- /**
101
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition in
102
- */
103
- onEntering: PropTypes.func,
104
- /**
105
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning in
106
- */
107
- onEntered: PropTypes.func,
108
- /**
109
- * Callback fired right before the `<DrawerLayout.Tray />` transitions out
110
- */
111
- onExit: PropTypes.func,
112
- /**
113
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition out
114
- */
115
- onExiting: PropTypes.func,
116
- /**
117
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning out
118
- */
119
- onExited: PropTypes.func,
120
- /**
121
- * Ref function for the `<DrawerLayout.Tray />` content
122
- */
123
- contentRef: PropTypes.func,
124
- /**
125
- * An element or a function returning an element to use as the mount node
126
- * for the `<DrawerLayout.Tray />` when tray is overlaying content
127
- */
128
- mountNode: PropTypes.oneOfType([element, PropTypes.func]),
129
- /**
130
- * An element or a function returning an element to focus by default
131
- */
132
- defaultFocusElement: PropTypes.oneOfType([
133
- PropTypes.element,
134
- PropTypes.func
135
- ]),
136
- /**
137
- * An element, function returning an element, or array of elements that will not be hidden from
138
- * the screen reader when the `<DrawerLayout.Tray />` is open
139
- */
140
- liveRegion: PropTypes.oneOfType([
141
- PropTypes.arrayOf(PropTypes.element),
142
- PropTypes.element,
143
- PropTypes.func
144
- ]),
145
- onDismiss: PropTypes.func,
146
- shouldContainFocus: PropTypes.bool,
147
- shouldReturnFocus: PropTypes.bool,
148
- shouldCloseOnDocumentClick: PropTypes.bool,
149
- shouldCloseOnEscape: PropTypes.bool,
150
- // eslint-disable-next-line react/require-default-props
151
- makeStyles: PropTypes.func,
152
- // eslint-disable-next-line react/require-default-props
153
- styles: PropTypes.object,
154
- // eslint-disable-next-line react/require-default-props
155
- dir: PropTypes.oneOf(Object.values(bidirectional.DIRECTION))
156
- }
66
+
67
+ static propTypes = propTypes
68
+ static allowedProps = allowedProps
157
69
  static defaultProps = {
158
70
  children: null,
159
- render: undefined,
160
71
  shouldContainFocus: true,
161
72
  shouldCloseOnEscape: true,
162
73
  shouldCloseOnDocumentClick: true,
@@ -174,21 +85,20 @@ class DrawerTray extends Component<
174
85
  onExiting: () => {},
175
86
  onExited: () => {},
176
87
  // @ts-expect-error ts-migrate(6133) FIXME: 'node' is declared but its value is never read.
177
- contentRef: (node: any) => {},
178
- onClose: undefined,
179
- onDismiss: undefined,
180
- defaultFocusElement: undefined,
181
- liveRegion: undefined,
182
- onTransition: undefined
88
+ contentRef: (node: any) => {}
183
89
  }
90
+
184
91
  state: DrawerLayoutTrayState = {
185
92
  transitioning: false,
186
93
  portalOpen: false
187
94
  }
95
+
188
96
  _DOMNode?: PortalNode = null
97
+
189
98
  componentDidMount() {
190
99
  ;(this.props as any).makeStyles(this.makeStyleProps())
191
100
  }
101
+
192
102
  // @ts-expect-error ts-migrate(6133) FIXME: 'prevState' is declared but its value is never rea... Remove this comment to see the full error message
193
103
  componentDidUpdate(prevProps: any, prevState: any, snapshot: any) {
194
104
  if ((this.props as any).open !== prevProps.open) {
@@ -198,11 +108,13 @@ class DrawerTray extends Component<
198
108
  }
199
109
  ;(this.props as any).makeStyles(this.makeStyleProps())
200
110
  }
111
+
201
112
  makeStyleProps = (): DrawerLayoutTrayStyleProps => {
202
113
  return {
203
114
  placement: this.placement
204
115
  }
205
116
  }
117
+
206
118
  get placement() {
207
119
  const { placement, dir } = this.props
208
120
  const isRtl = dir === bidirectional.DIRECTION.rtl
@@ -210,12 +122,15 @@ class DrawerTray extends Component<
210
122
  ? mirrorHorizontalPlacement(placement!, ' ')
211
123
  : placement!) as DrawerTrayPlacement
212
124
  }
125
+
213
126
  get direction() {
214
127
  return this.placement === 'end' ? 'right' : 'left'
215
128
  }
129
+
216
130
  get transition() {
217
131
  return `slide-${this.direction}`
218
132
  }
133
+
219
134
  handleContentRef = (node: any) => {
220
135
  // @ts-expect-error ts-migrate(2551) FIXME: Property '_content' does not exist on type 'Drawer... Remove this comment to see the full error message
221
136
  this._content = node
@@ -223,36 +138,44 @@ class DrawerTray extends Component<
223
138
  ;(this.props as any).contentRef(node)
224
139
  }
225
140
  }
141
+
226
142
  handleTransitionEntered = () => {
227
143
  this.setState({ transitioning: false })
228
144
  }
145
+
229
146
  handleTransitionExited = () => {
230
147
  this.setState({
231
148
  transitioning: false
232
149
  })
233
150
  }
151
+
234
152
  handlePortalOpen = (DOMNode?: PortalNode) => {
235
153
  this.DOMNode = DOMNode
236
154
  this.setState({
237
155
  portalOpen: true
238
156
  })
239
157
  }
158
+
240
159
  get DOMNode() {
241
160
  return this._DOMNode
242
161
  }
162
+
243
163
  set DOMNode(el: PortalNode) {
244
164
  this._DOMNode = el
245
165
  }
166
+
246
167
  renderContent() {
247
168
  const { children, render } = this.props
248
169
  if (typeof render === 'function') {
249
170
  return render()
250
171
  } else if (typeof children === 'function') {
172
+ // @ts-expect-error TODO: fix
251
173
  return children()
252
174
  } else {
253
175
  return children
254
176
  }
255
177
  }
178
+
256
179
  render() {
257
180
  const {
258
181
  label,
@@ -283,9 +206,10 @@ class DrawerTray extends Component<
283
206
  styles,
284
207
  ...props
285
208
  } = this.props
209
+
286
210
  return (
287
211
  <DrawerLayoutContext.Consumer>
288
- {(shouldOverlayTray: any) => {
212
+ {(shouldOverlayTray: boolean) => {
289
213
  const { portalOpen } = this.state
290
214
  const needsPortal = shouldOverlayTray && mountNode
291
215
  // we have to handle the shadow version here,
@@ -293,8 +217,8 @@ class DrawerTray extends Component<
293
217
  // rerender the component during the transition, breaking it
294
218
  const trayStyles =
295
219
  shadow && shouldOverlayTray
296
- ? (styles as any).drawerTrayWithShadow
297
- : (styles as any).drawerTray
220
+ ? styles?.drawerTrayWithShadow
221
+ : styles?.drawerTray
298
222
  let transitionIn = open
299
223
  if (needsPortal && !portalOpen) {
300
224
  transitionIn = false
@@ -345,7 +269,7 @@ class DrawerTray extends Component<
345
269
  liveRegion={liveRegion}
346
270
  onDismiss={onDismiss}
347
271
  as="div"
348
- css={(this.props as any).styles.drawerTrayContent}
272
+ css={this.props.styles?.drawerTrayContent}
349
273
  >
350
274
  {this.renderContent()}
351
275
  </Dialog>
@@ -367,5 +291,6 @@ class DrawerTray extends Component<
367
291
  )
368
292
  }
369
293
  }
294
+
370
295
  export default DrawerTray
371
296
  export { DrawerTray }