@instructure/ui-drawer-layout 8.14.1-snapshot.7 → 8.15.1-snapshot.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/es/DrawerLayout/DrawerContent/DrawerContentLocator.js +2 -1
  3. package/es/DrawerLayout/DrawerContent/index.js +42 -43
  4. package/es/DrawerLayout/DrawerContent/props.js +0 -4
  5. package/es/DrawerLayout/DrawerContent/styles.js +1 -1
  6. package/es/DrawerLayout/DrawerLayoutLocator.js +2 -1
  7. package/es/DrawerLayout/DrawerTray/DrawerTrayLocator.js +2 -1
  8. package/es/DrawerLayout/DrawerTray/index.js +61 -66
  9. package/es/DrawerLayout/DrawerTray/props.js +0 -70
  10. package/es/DrawerLayout/index.js +19 -13
  11. package/es/DrawerLayout/props.js +0 -13
  12. package/lib/DrawerLayout/DrawerContent/DrawerContentLocator.js +1 -0
  13. package/lib/DrawerLayout/DrawerContent/index.js +42 -43
  14. package/lib/DrawerLayout/DrawerContent/props.js +0 -4
  15. package/lib/DrawerLayout/DrawerContent/styles.js +1 -1
  16. package/lib/DrawerLayout/DrawerLayoutLocator.js +1 -0
  17. package/lib/DrawerLayout/DrawerTray/DrawerTrayLocator.js +1 -0
  18. package/lib/DrawerLayout/DrawerTray/index.js +61 -66
  19. package/lib/DrawerLayout/DrawerTray/props.js +0 -70
  20. package/lib/DrawerLayout/index.js +21 -13
  21. package/lib/DrawerLayout/props.js +0 -13
  22. package/package.json +22 -22
  23. package/src/DrawerLayout/DrawerContent/index.tsx +38 -57
  24. package/src/DrawerLayout/DrawerContent/props.ts +13 -10
  25. package/src/DrawerLayout/DrawerContent/styles.ts +3 -4
  26. package/src/DrawerLayout/DrawerTray/index.tsx +31 -33
  27. package/src/DrawerLayout/DrawerTray/props.ts +110 -69
  28. package/src/DrawerLayout/__fixtures__/DrawerLayout.fixture.tsx +14 -13
  29. package/src/DrawerLayout/index.tsx +74 -86
  30. package/src/DrawerLayout/props.ts +22 -13
  31. package/tsconfig.build.tsbuildinfo +1 -1
  32. package/types/DrawerLayout/DrawerContent/DrawerContentLocator.d.ts +4 -4
  33. package/types/DrawerLayout/DrawerContent/index.d.ts +28 -19
  34. package/types/DrawerLayout/DrawerContent/index.d.ts.map +1 -1
  35. package/types/DrawerLayout/DrawerContent/props.d.ts +13 -6
  36. package/types/DrawerLayout/DrawerContent/props.d.ts.map +1 -1
  37. package/types/DrawerLayout/DrawerContent/styles.d.ts +2 -2
  38. package/types/DrawerLayout/DrawerContent/styles.d.ts.map +1 -1
  39. package/types/DrawerLayout/DrawerLayoutLocator.d.ts +14 -14
  40. package/types/DrawerLayout/DrawerTray/DrawerTrayLocator.d.ts +4 -4
  41. package/types/DrawerLayout/DrawerTray/index.d.ts +46 -22
  42. package/types/DrawerLayout/DrawerTray/index.d.ts.map +1 -1
  43. package/types/DrawerLayout/DrawerTray/props.d.ts +74 -16
  44. package/types/DrawerLayout/DrawerTray/props.d.ts.map +1 -1
  45. package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts +11 -1
  46. package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts.map +1 -1
  47. package/types/DrawerLayout/index.d.ts +116 -23
  48. package/types/DrawerLayout/index.d.ts.map +1 -1
  49. package/types/DrawerLayout/props.d.ts +19 -3
  50. package/types/DrawerLayout/props.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-drawer-layout",
3
- "version": "8.14.1-snapshot.7+845d7ec6c",
3
+ "version": "8.15.1-snapshot.2+00f55c738",
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.14.1-snapshot.7+845d7ec6c",
29
- "@instructure/debounce": "8.14.1-snapshot.7+845d7ec6c",
30
- "@instructure/emotion": "8.14.1-snapshot.7+845d7ec6c",
31
- "@instructure/shared-types": "8.14.1-snapshot.7+845d7ec6c",
32
- "@instructure/ui-dialog": "8.14.1-snapshot.7+845d7ec6c",
33
- "@instructure/ui-dom-utils": "8.14.1-snapshot.7+845d7ec6c",
34
- "@instructure/ui-i18n": "8.14.1-snapshot.7+845d7ec6c",
35
- "@instructure/ui-motion": "8.14.1-snapshot.7+845d7ec6c",
36
- "@instructure/ui-portal": "8.14.1-snapshot.7+845d7ec6c",
37
- "@instructure/ui-position": "8.14.1-snapshot.7+845d7ec6c",
38
- "@instructure/ui-prop-types": "8.14.1-snapshot.7+845d7ec6c",
39
- "@instructure/ui-react-utils": "8.14.1-snapshot.7+845d7ec6c",
40
- "@instructure/ui-test-utils": "8.14.1-snapshot.7+845d7ec6c",
41
- "@instructure/ui-testable": "8.14.1-snapshot.7+845d7ec6c",
42
- "@instructure/ui-utils": "8.14.1-snapshot.7+845d7ec6c",
43
- "@instructure/ui-view": "8.14.1-snapshot.7+845d7ec6c",
44
- "@instructure/uid": "8.14.1-snapshot.7+845d7ec6c",
28
+ "@instructure/console": "8.15.1-snapshot.2+00f55c738",
29
+ "@instructure/debounce": "8.15.1-snapshot.2+00f55c738",
30
+ "@instructure/emotion": "8.15.1-snapshot.2+00f55c738",
31
+ "@instructure/shared-types": "8.15.1-snapshot.2+00f55c738",
32
+ "@instructure/ui-dialog": "8.15.1-snapshot.2+00f55c738",
33
+ "@instructure/ui-dom-utils": "8.15.1-snapshot.2+00f55c738",
34
+ "@instructure/ui-i18n": "8.15.1-snapshot.2+00f55c738",
35
+ "@instructure/ui-motion": "8.15.1-snapshot.2+00f55c738",
36
+ "@instructure/ui-portal": "8.15.1-snapshot.2+00f55c738",
37
+ "@instructure/ui-position": "8.15.1-snapshot.2+00f55c738",
38
+ "@instructure/ui-prop-types": "8.15.1-snapshot.2+00f55c738",
39
+ "@instructure/ui-react-utils": "8.15.1-snapshot.2+00f55c738",
40
+ "@instructure/ui-test-utils": "8.15.1-snapshot.2+00f55c738",
41
+ "@instructure/ui-testable": "8.15.1-snapshot.2+00f55c738",
42
+ "@instructure/ui-utils": "8.15.1-snapshot.2+00f55c738",
43
+ "@instructure/ui-view": "8.15.1-snapshot.2+00f55c738",
44
+ "@instructure/uid": "8.15.1-snapshot.2+00f55c738",
45
45
  "prop-types": "^15"
46
46
  },
47
47
  "devDependencies": {
48
- "@instructure/ui-babel-preset": "8.14.1-snapshot.7+845d7ec6c",
49
- "@instructure/ui-test-locator": "8.14.1-snapshot.7+845d7ec6c",
50
- "@instructure/ui-themes": "8.14.1-snapshot.7+845d7ec6c"
48
+ "@instructure/ui-babel-preset": "8.15.1-snapshot.2+00f55c738",
49
+ "@instructure/ui-test-locator": "8.15.1-snapshot.2+00f55c738",
50
+ "@instructure/ui-themes": "8.15.1-snapshot.2+00f55c738"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": ">=16.8 <=17"
@@ -56,5 +56,5 @@
56
56
  "access": "public"
57
57
  },
58
58
  "sideEffects": false,
59
- "gitHead": "845d7ec6c159d8946b22caa9d8fb3d0175167a6f"
59
+ "gitHead": "00f55c7382e82209ea553c107951c4356ba202bf"
60
60
  }
@@ -26,6 +26,7 @@
26
26
  import { Component } from 'react'
27
27
 
28
28
  import { debounce } from '@instructure/debounce'
29
+ import type { Debounced } from '@instructure/debounce'
29
30
  import { getBoundingClientRect } from '@instructure/ui-dom-utils'
30
31
  import { omitProps } from '@instructure/ui-react-utils'
31
32
  import { testable } from '@instructure/ui-testable'
@@ -37,7 +38,7 @@ import generateComponentTheme from './theme'
37
38
  import { propTypes, allowedProps } from './props'
38
39
  import type {
39
40
  DrawerLayoutContentProps,
40
- DrawerLayoutContentState
41
+ DrawerLayoutContentStyleProps
41
42
  } from './props'
42
43
 
43
44
  /**
@@ -45,32 +46,22 @@ import type {
45
46
  parent: DrawerLayout
46
47
  id: DrawerLayout.Content
47
48
  ---
49
+ @tsProps
48
50
  **/
49
51
  @withStyle(generateStyle, generateComponentTheme)
50
52
  @testable()
51
- class DrawerContent extends Component<
52
- DrawerLayoutContentProps,
53
- DrawerLayoutContentState
54
- > {
53
+ class DrawerContent extends Component<DrawerLayoutContentProps> {
55
54
  static readonly componentId = 'DrawerLayout.Content'
56
55
 
57
56
  static locatorAttribute = 'data-drawer-content'
58
57
  static propTypes = propTypes
59
58
  static allowedProps = allowedProps
60
59
  static defaultProps = {
61
- children: null,
62
- // @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
63
- contentRef: (el: any) => {},
64
- // @ts-expect-error ts-migrate(6133) FIXME: 'node' is declared but its value is never read.
65
- onSizeChange: (node: any) => {},
66
60
  role: 'region'
67
61
  }
68
62
 
69
- state: DrawerLayoutContentState = {
70
- shouldTransition: false
71
- }
63
+ ref: HTMLDivElement | null = null
72
64
 
73
- ref: Element | null = null
74
65
  get _content() {
75
66
  console.warn(
76
67
  '_content property is deprecated and will be removed in v9, please use ref instead'
@@ -78,10 +69,10 @@ class DrawerContent extends Component<
78
69
 
79
70
  return this.ref
80
71
  }
81
- _resizeListener = null
82
72
 
83
- _debounced = null
84
- _timeouts = []
73
+ private _resizeListener?: ResizeObserver
74
+
75
+ private _debounced?: Debounced
85
76
 
86
77
  componentDidMount() {
87
78
  const rect = getBoundingClientRect(this.ref)
@@ -89,72 +80,62 @@ class DrawerContent extends Component<
89
80
  width: rect.width
90
81
  }
91
82
  // set initial size
92
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefined'.
93
- this.props.onSizeChange({ width: rect.width, height: rect.height })
94
- // listen for changes to size
95
- // @ts-expect-error ts-migrate(2322) FIXME: Type 'Function' is not assignable to type 'null'.
96
- this._debounced = debounce(this.props.onSizeChange, 100, {
97
- leading: false,
98
- trailing: true
99
- })
100
- // @ts-expect-error ts-migrate(2322) FIXME: Type 'ResizeObserver' is not assignable to type 'n... Remove this comment to see the full error message
83
+ if (typeof this.props.onSizeChange === 'function') {
84
+ this.props.onSizeChange({ width: rect.width, height: rect.height })
85
+
86
+ // listen for changes to size
87
+ this._debounced = debounce(this.props.onSizeChange, 100, {
88
+ leading: false,
89
+ trailing: true
90
+ })
91
+ }
92
+
101
93
  this._resizeListener = new ResizeObserver((entries) => {
102
94
  for (const entry of entries) {
103
95
  const size = {
104
96
  width: entry.contentRect.width
105
97
  }
106
98
  if (size.width !== origSize.width) {
107
- // @ts-expect-error ts-migrate(2721) FIXME: Cannot invoke an object which is possibly 'null'.
108
- this._debounced(size)
99
+ this._debounced?.(size)
109
100
  }
110
101
  }
111
102
  })
112
103
 
113
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
114
- this._resizeListener.observe(this.ref)
115
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
116
- this.props.makeStyles({ shouldTransition: false })
104
+ this._resizeListener.observe(this.ref!)
105
+
106
+ this.props.makeStyles?.(this.makeStyleProps(false))
117
107
  }
118
108
 
119
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
120
- componentDidUpdate(prevProps: any, prevState: any, snapshot: any) {
121
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
122
- this.props.makeStyles({ shouldTransition: true })
109
+ componentDidUpdate() {
110
+ this.props.makeStyles?.(this.makeStyleProps(true))
123
111
  }
124
112
 
125
113
  componentWillUnmount() {
126
- if (this._resizeListener) {
127
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
128
- this._resizeListener.disconnect()
129
- }
114
+ this._resizeListener?.disconnect()
130
115
 
131
- if (this._debounced) {
132
- // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
133
- this._debounced.cancel()
134
- }
116
+ this._debounced?.cancel()
117
+ }
135
118
 
136
- this._timeouts.forEach((timeout) => {
137
- clearTimeout(timeout)
138
- })
119
+ makeStyleProps = (
120
+ shouldTransition: DrawerLayoutContentStyleProps['shouldTransition']
121
+ ): DrawerLayoutContentStyleProps => {
122
+ return { shouldTransition }
139
123
  }
140
124
 
141
- handleContentRef = (node: Element | null) => {
125
+ handleContentRef = (node: HTMLDivElement | null) => {
142
126
  this.ref = node
143
- this.props.contentRef?.(node)
127
+
128
+ if (typeof this.props.contentRef === 'function') {
129
+ this.props.contentRef(node)
130
+ }
144
131
  }
145
132
 
146
133
  render() {
147
- const {
148
- style, // eslint-disable-line react/prop-types
149
- label,
150
- role
151
- } = this.props
134
+ const { style, label, role } = this.props
152
135
 
153
136
  return (
154
137
  <div
155
- {...omitProps(this.props, DrawerContent.allowedProps, [
156
- 'shouldTransition'
157
- ])}
138
+ {...omitProps(this.props, DrawerContent.allowedProps)}
158
139
  role={role}
159
140
  style={style}
160
141
  ref={this.handleContentRef}
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import React from 'react'
25
+ import React, { AriaRole } from 'react'
26
26
  import PropTypes from 'prop-types'
27
27
 
28
28
  import type {
@@ -32,15 +32,20 @@ import type {
32
32
  } from '@instructure/shared-types'
33
33
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
34
34
 
35
+ type DrawerContentSize = { width: number; height: number }
36
+
35
37
  type DrawerLayoutContentOwnProps = {
36
38
  label: string
37
39
  children?: React.ReactNode
38
- contentRef?: (...args: any[]) => any
39
- onSizeChange?: (...args: any[]) => any
40
- role?: string
40
+ contentRef?: (element: HTMLDivElement | null) => void
41
+ /**
42
+ * Callback fired whenever the `<DrawerLayout.Content />` changes size
43
+ */
44
+ onSizeChange?: (contentSize: DrawerContentSize) => void
45
+ role?: AriaRole
41
46
  }
42
47
 
43
- type DrawerLayoutContentState = {
48
+ type DrawerLayoutContentStyleProps = {
44
49
  shouldTransition: boolean
45
50
  }
46
51
 
@@ -58,9 +63,6 @@ const propTypes: PropValidators<PropKeys> = {
58
63
  label: PropTypes.string.isRequired,
59
64
  children: PropTypes.node,
60
65
  contentRef: PropTypes.func,
61
- /**
62
- * Callback fired whenever the `<DrawerLayout.Content />` changes size
63
- */
64
66
  onSizeChange: PropTypes.func,
65
67
  role: PropTypes.string
66
68
  }
@@ -75,7 +77,8 @@ const allowedProps: AllowedPropKeys = [
75
77
 
76
78
  export type {
77
79
  DrawerLayoutContentProps,
78
- DrawerLayoutContentState,
79
- DrawerLayoutContentStyle
80
+ DrawerLayoutContentStyleProps,
81
+ DrawerLayoutContentStyle,
82
+ DrawerContentSize
80
83
  }
81
84
  export { propTypes, allowedProps }
@@ -25,7 +25,7 @@
25
25
  import type { DrawerLayoutContentTheme } from '@instructure/shared-types'
26
26
  import type {
27
27
  DrawerLayoutContentProps,
28
- DrawerLayoutContentState,
28
+ DrawerLayoutContentStyleProps,
29
29
  DrawerLayoutContentStyle
30
30
  } from './props'
31
31
 
@@ -41,9 +41,8 @@ import type {
41
41
  */
42
42
  const generateStyle = (
43
43
  componentTheme: DrawerLayoutContentTheme,
44
- // @ts-expect-error no props used here
45
- props: DrawerLayoutContentProps,
46
- state: DrawerLayoutContentState
44
+ _props: DrawerLayoutContentProps,
45
+ state: DrawerLayoutContentStyleProps
47
46
  ): DrawerLayoutContentStyle => {
48
47
  const { shouldTransition } = state
49
48
 
@@ -27,6 +27,7 @@ import { Component } from 'react'
27
27
  import { withStyle, jsx } from '@instructure/emotion'
28
28
  import { textDirectionContextConsumer } from '@instructure/ui-i18n'
29
29
  import { Transition } from '@instructure/ui-motion'
30
+ import type { TransitionType } from '@instructure/ui-motion'
30
31
  import { omitProps } from '@instructure/ui-react-utils'
31
32
  import { createChainedFunction } from '@instructure/ui-utils'
32
33
  import { testable } from '@instructure/ui-testable'
@@ -52,6 +53,7 @@ import type {
52
53
  parent: DrawerLayout
53
54
  id: DrawerLayout.Tray
54
55
  ---
56
+ @tsProps
55
57
  **/
56
58
  @withStyle(generateStyle, generateComponentTheme)
57
59
  @textDirectionContextConsumer()
@@ -67,34 +69,20 @@ class DrawerTray extends Component<
67
69
  static propTypes = propTypes
68
70
  static allowedProps = allowedProps
69
71
  static defaultProps = {
70
- children: null,
71
72
  shouldContainFocus: true,
72
73
  shouldCloseOnEscape: true,
73
74
  shouldCloseOnDocumentClick: true,
74
75
  shouldReturnFocus: true,
75
76
  open: false,
76
- onOpen: () => {},
77
77
  shadow: true,
78
78
  border: true,
79
- placement: 'start',
80
- mountNode: null,
81
- onEnter: () => {},
82
- onEntering: () => {},
83
- onEntered: () => {},
84
- onExit: () => {},
85
- onExiting: () => {},
86
- onExited: () => {},
87
- // @ts-expect-error ts-migrate(6133) FIXME: 'node' is declared but its value is never read.
88
- contentRef: (node: any) => {}
79
+ placement: 'start'
89
80
  }
90
81
 
91
- state: DrawerLayoutTrayState = {
92
- transitioning: false,
93
- portalOpen: false
94
- }
82
+ ref: HTMLDivElement | null = null
83
+
84
+ private _DOMNode: PortalNode = null
95
85
 
96
- _DOMNode: PortalNode = null
97
- ref: Element | null = null
98
86
  get _content() {
99
87
  console.warn(
100
88
  '_content property is deprecated and will be removed in v9, please use ref instead'
@@ -103,18 +91,26 @@ class DrawerTray extends Component<
103
91
  return this.ref
104
92
  }
105
93
 
94
+ constructor(props: DrawerLayoutTrayProps) {
95
+ super(props)
96
+
97
+ this.state = {
98
+ transitioning: false,
99
+ portalOpen: false
100
+ }
101
+ }
102
+
106
103
  componentDidMount() {
107
- ;(this.props as any).makeStyles(this.makeStyleProps())
104
+ this.props.makeStyles?.(this.makeStyleProps())
108
105
  }
109
106
 
110
- // @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
111
- componentDidUpdate(prevProps: any, prevState: any, snapshot: any) {
112
- if ((this.props as any).open !== prevProps.open) {
107
+ componentDidUpdate(prevProps: DrawerLayoutTrayProps) {
108
+ if (this.props.open !== prevProps.open) {
113
109
  this.setState({
114
110
  transitioning: true
115
111
  })
116
112
  }
117
- ;(this.props as any).makeStyles(this.makeStyleProps())
113
+ this.props.makeStyles?.(this.makeStyleProps())
118
114
  }
119
115
 
120
116
  makeStyleProps = (): DrawerLayoutTrayStyleProps => {
@@ -126,29 +122,32 @@ class DrawerTray extends Component<
126
122
  get placement() {
127
123
  const { placement, dir } = this.props
128
124
  const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl
129
- return (isRtl
130
- ? mirrorHorizontalPlacement(placement!, ' ')
131
- : placement!) as DrawerTrayPlacement
125
+ return (
126
+ isRtl ? mirrorHorizontalPlacement(placement!, ' ') : placement!
127
+ ) as DrawerTrayPlacement
132
128
  }
133
129
 
134
130
  get direction() {
135
131
  return this.placement === 'end' ? 'right' : 'left'
136
132
  }
137
133
 
138
- get transition() {
134
+ get transition(): TransitionType {
139
135
  return `slide-${this.direction}`
140
136
  }
141
137
 
142
- handleContentRef = (node: Element | null) => {
138
+ handleContentRef = (node: HTMLDivElement | null) => {
143
139
  this.ref = node
144
- this.props.contentRef?.(node)
140
+
141
+ if (typeof this.props.contentRef === 'function') {
142
+ this.props.contentRef(node)
143
+ }
145
144
  }
146
145
 
147
- handleTransitionEntered = () => {
146
+ handleTransitionEntered = (_transitionType?: TransitionType) => {
148
147
  this.setState({ transitioning: false })
149
148
  }
150
149
 
151
- handleTransitionExited = () => {
150
+ handleTransitionExited = (_transitionType?: TransitionType) => {
152
151
  this.setState({
153
152
  transitioning: false
154
153
  })
@@ -215,7 +214,7 @@ class DrawerTray extends Component<
215
214
  <DrawerLayoutContext.Consumer>
216
215
  {(shouldOverlayTray: boolean) => {
217
216
  const { portalOpen } = this.state
218
- const needsPortal = shouldOverlayTray && mountNode
217
+ const needsPortal = shouldOverlayTray && !!mountNode
219
218
  // we have to handle the shadow version here,
220
219
  // because passing and handling it in styles.js makes it
221
220
  // rerender the component during the transition, breaking it
@@ -230,7 +229,6 @@ class DrawerTray extends Component<
230
229
  const content = (
231
230
  <Transition
232
231
  in={transitionIn}
233
- // @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
234
232
  type={this.transition}
235
233
  onTransition={onTransition}
236
234
  onEnter={onEnter}
@@ -35,38 +35,132 @@ import type {
35
35
  PropValidators,
36
36
  DrawerLayoutTrayTheme,
37
37
  OtherHTMLAttributes,
38
- LiveRegion
38
+ LiveRegion,
39
+ UIElement
39
40
  } from '@instructure/shared-types'
41
+ import {
42
+ BaseTransitionStatesType,
43
+ TransitionType
44
+ } from '@instructure/ui-motion/src/Transition/BaseTransition/props'
40
45
 
41
46
  type DrawerTrayPlacement = 'start' | 'end'
42
47
 
43
48
  type DrawerLayoutTrayOwnProps = {
44
49
  label: string
45
- children?: React.ReactNode | ((...args: any[]) => React.ReactNode)
46
- render?: (...args: any[]) => any
50
+
51
+ children?: React.ReactNode | (() => React.ReactNode)
52
+
53
+ render?: () => React.ReactNode
54
+
55
+ /**
56
+ * Placement of the `<DrawerLayout.Tray />`
57
+ */
47
58
  placement?: DrawerTrayPlacement
59
+
60
+ /**
61
+ * If the tray is open or closed.
62
+ */
48
63
  open?: boolean
49
- onOpen?: (...args: any[]) => any
50
- onClose?: (...args: any[]) => any
64
+
65
+ /**
66
+ * Called when the `<DrawerLayout.Tray />` is opened
67
+ */
68
+ onOpen?: (transitionType?: TransitionType) => void
69
+
70
+ /**
71
+ * Called when the `<DrawerLayout.Tray />` is closed
72
+ */
73
+ onClose?: (transitionType?: TransitionType) => void
74
+
75
+ /**
76
+ * Should the `<DrawerLayout.Tray />` have a border
77
+ */
51
78
  border?: boolean
79
+
80
+ /**
81
+ * Should the `<DrawerLayout.Tray />` have a shadow
82
+ */
52
83
  shadow?: boolean
53
- onTransition?: (...args: any[]) => any
54
- onEnter?: (...args: any[]) => any
55
- onEntering?: (...args: any[]) => any
56
- onEntered?: (...args: any[]) => any
57
- onExit?: (...args: any[]) => any
58
- onExiting?: (...args: any[]) => any
59
- onExited?: (...args: any[]) => any
60
- contentRef?: (...args: any[]) => any
84
+
85
+ /**
86
+ * Ref function for the `<DrawerLayout.Tray />` content
87
+ */
88
+ contentRef?: (element: HTMLDivElement | null) => void
89
+
90
+ /**
91
+ * An element or a function returning an element to use as the mount node
92
+ * for the `<DrawerLayout.Tray />` when tray is overlaying content
93
+ */
61
94
  mountNode?: PositionMountNode
62
- defaultFocusElement?: React.ReactElement | ((...args: any[]) => any)
95
+ } & PropsPassedToDialog &
96
+ PropsPassedToTransition &
97
+ BidirectionalProps
98
+
99
+ type PropsPassedToDialog = {
100
+ /**
101
+ * An element or a function returning an element to focus by default
102
+ */
103
+ defaultFocusElement?: UIElement
104
+
105
+ /**
106
+ * An element, function returning an element, or array of elements that will not be hidden from
107
+ * the screen reader when the `<DrawerLayout.Tray />` is open
108
+ */
63
109
  liveRegion?: LiveRegion
64
- onDismiss?: (...args: any[]) => any
110
+
111
+ onDismiss?: (
112
+ event: React.UIEvent | React.FocusEvent,
113
+ documentClick?: boolean
114
+ ) => void
115
+
65
116
  shouldContainFocus?: boolean
117
+
66
118
  shouldReturnFocus?: boolean
119
+
67
120
  shouldCloseOnDocumentClick?: boolean
121
+
68
122
  shouldCloseOnEscape?: boolean
69
- } & BidirectionalProps
123
+ }
124
+
125
+ type PropsPassedToTransition = {
126
+ /**
127
+ * Callback fired when the `<DrawerLayout.Tray />` transitions in/out
128
+ */
129
+ onTransition?: (
130
+ toState: BaseTransitionStatesType,
131
+ fromState: BaseTransitionStatesType
132
+ ) => void
133
+
134
+ /**
135
+ * Callback fired before the `<DrawerLayout.Tray />` transitions in
136
+ */
137
+ onEnter?: () => void
138
+
139
+ /**
140
+ * Callback fired as the `<DrawerLayout.Tray />` begins to transition in
141
+ */
142
+ onEntering?: () => void
143
+
144
+ /**
145
+ * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning in
146
+ */
147
+ onEntered?: (type?: TransitionType) => void
148
+
149
+ /**
150
+ * Callback fired right before the `<DrawerLayout.Tray />` transitions out
151
+ */
152
+ onExit?: () => void
153
+
154
+ /**
155
+ * Callback fired as the `<DrawerLayout.Tray />` begins to transition out
156
+ */
157
+ onExiting?: () => void
158
+
159
+ /**
160
+ * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning out
161
+ */
162
+ onExited?: (type?: TransitionType) => void
163
+ }
70
164
 
71
165
  type DrawerLayoutTrayState = {
72
166
  transitioning: boolean
@@ -93,75 +187,22 @@ const propTypes: PropValidators<PropKeys> = {
93
187
  label: PropTypes.string.isRequired,
94
188
  children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
95
189
  render: PropTypes.func,
96
- /**
97
- * Placement of the `<DrawerLayout.Tray />`
98
- */
99
190
  placement: PropTypes.oneOf(['start', 'end']),
100
- /**
101
- * If the tray is open or closed.
102
- */
103
191
  open: PropTypes.bool,
104
- /**
105
- * Called when the `<DrawerLayout.Tray />` is opened
106
- */
107
192
  onOpen: PropTypes.func,
108
- /**
109
- * Called when the `<DrawerLayout.Tray />` is closed
110
- */
111
193
  onClose: PropTypes.func,
112
- /**
113
- * Should the `<DrawerLayout.Tray />` have a border
114
- */
115
194
  border: PropTypes.bool,
116
- /**
117
- * Should the `<DrawerLayout.Tray />` have a shadow
118
- */
119
195
  shadow: PropTypes.bool,
120
- /**
121
- * Callback fired when the `<DrawerLayout.Tray />` transitions in/out
122
- */
123
196
  onTransition: PropTypes.func,
124
- /**
125
- * Callback fired before the `<DrawerLayout.Tray />` transitions in
126
- */
127
197
  onEnter: PropTypes.func,
128
- /**
129
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition in
130
- */
131
198
  onEntering: PropTypes.func,
132
- /**
133
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning in
134
- */
135
199
  onEntered: PropTypes.func,
136
- /**
137
- * Callback fired right before the `<DrawerLayout.Tray />` transitions out
138
- */
139
200
  onExit: PropTypes.func,
140
- /**
141
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition out
142
- */
143
201
  onExiting: PropTypes.func,
144
- /**
145
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning out
146
- */
147
202
  onExited: PropTypes.func,
148
- /**
149
- * Ref function for the `<DrawerLayout.Tray />` content
150
- */
151
203
  contentRef: PropTypes.func,
152
- /**
153
- * An element or a function returning an element to use as the mount node
154
- * for the `<DrawerLayout.Tray />` when tray is overlaying content
155
- */
156
204
  mountNode: PropTypes.oneOfType([element, PropTypes.func]),
157
- /**
158
- * An element or a function returning an element to focus by default
159
- */
160
205
  defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
161
- /**
162
- * An element, function returning an element, or array of elements that will not be hidden from
163
- * the screen reader when the `<DrawerLayout.Tray />` is open
164
- */
165
206
  liveRegion: PropTypes.oneOfType([
166
207
  PropTypes.arrayOf(PropTypes.element),
167
208
  PropTypes.element,