@instructure/ui-drawer-layout 8.14.1-snapshot.5 → 8.14.1-snapshot.66

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 (54) hide show
  1. package/es/DrawerLayout/DrawerContent/DrawerContentLocator.js +2 -1
  2. package/es/DrawerLayout/DrawerContent/index.js +42 -43
  3. package/es/DrawerLayout/DrawerContent/props.js +0 -4
  4. package/es/DrawerLayout/DrawerContent/styles.js +1 -1
  5. package/es/DrawerLayout/DrawerLayoutLocator.js +2 -1
  6. package/es/DrawerLayout/DrawerTray/DrawerTrayLocator.js +2 -1
  7. package/es/DrawerLayout/DrawerTray/index.js +61 -66
  8. package/es/DrawerLayout/DrawerTray/props.js +0 -70
  9. package/es/DrawerLayout/__examples__/DrawerLayout.examples.js +2 -2
  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/__examples__/DrawerLayout.examples.js +2 -2
  21. package/lib/DrawerLayout/index.js +21 -13
  22. package/lib/DrawerLayout/props.js +0 -13
  23. package/package.json +22 -22
  24. package/src/DrawerLayout/DrawerContent/index.tsx +38 -57
  25. package/src/DrawerLayout/DrawerContent/props.ts +13 -10
  26. package/src/DrawerLayout/DrawerContent/styles.ts +3 -4
  27. package/src/DrawerLayout/DrawerTray/index.tsx +31 -33
  28. package/src/DrawerLayout/DrawerTray/props.ts +110 -69
  29. package/src/DrawerLayout/__examples__/DrawerLayout.examples.tsx +7 -5
  30. package/src/DrawerLayout/__fixtures__/DrawerLayout.fixture.tsx +14 -13
  31. package/src/DrawerLayout/index.tsx +74 -86
  32. package/src/DrawerLayout/props.ts +22 -13
  33. package/tsconfig.build.tsbuildinfo +1 -1
  34. package/types/DrawerLayout/DrawerContent/DrawerContentLocator.d.ts +4 -4
  35. package/types/DrawerLayout/DrawerContent/index.d.ts +28 -19
  36. package/types/DrawerLayout/DrawerContent/index.d.ts.map +1 -1
  37. package/types/DrawerLayout/DrawerContent/props.d.ts +13 -6
  38. package/types/DrawerLayout/DrawerContent/props.d.ts.map +1 -1
  39. package/types/DrawerLayout/DrawerContent/styles.d.ts +2 -2
  40. package/types/DrawerLayout/DrawerContent/styles.d.ts.map +1 -1
  41. package/types/DrawerLayout/DrawerLayoutLocator.d.ts +14 -14
  42. package/types/DrawerLayout/DrawerTray/DrawerTrayLocator.d.ts +4 -4
  43. package/types/DrawerLayout/DrawerTray/index.d.ts +45 -21
  44. package/types/DrawerLayout/DrawerTray/index.d.ts.map +1 -1
  45. package/types/DrawerLayout/DrawerTray/props.d.ts +74 -16
  46. package/types/DrawerLayout/DrawerTray/props.d.ts.map +1 -1
  47. package/types/DrawerLayout/__examples__/DrawerLayout.examples.d.ts +3 -16
  48. package/types/DrawerLayout/__examples__/DrawerLayout.examples.d.ts.map +1 -1
  49. package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts +11 -1
  50. package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts.map +1 -1
  51. package/types/DrawerLayout/index.d.ts +116 -23
  52. package/types/DrawerLayout/index.d.ts.map +1 -1
  53. package/types/DrawerLayout/props.d.ts +19 -3
  54. package/types/DrawerLayout/props.d.ts.map +1 -1
@@ -22,5 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import { locator } from '@instructure/ui-test-locator';
25
- import { DrawerContent } from './index';
25
+ import { DrawerContent } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
26
+
26
27
  export const DrawerContentLocator = locator(DrawerContent.selector);
@@ -40,23 +40,27 @@ import { propTypes, allowedProps } from './props';
40
40
  parent: DrawerLayout
41
41
  id: DrawerLayout.Content
42
42
  ---
43
+ @tsProps
43
44
  **/
44
45
  let DrawerContent = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class DrawerContent extends Component {
45
46
  constructor() {
46
47
  super(...arguments);
47
- this.state = {
48
- shouldTransition: false
49
- };
50
48
  this.ref = null;
51
- this._resizeListener = null;
52
- this._debounced = null;
53
- this._timeouts = [];
49
+ this._resizeListener = void 0;
50
+ this._debounced = void 0;
54
51
 
55
- this.handleContentRef = node => {
56
- var _this$props$contentRe, _this$props;
52
+ this.makeStyleProps = shouldTransition => {
53
+ return {
54
+ shouldTransition
55
+ };
56
+ };
57
57
 
58
+ this.handleContentRef = node => {
58
59
  this.ref = node;
59
- (_this$props$contentRe = (_this$props = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props, node);
60
+
61
+ if (typeof this.props.contentRef === 'function') {
62
+ this.props.contentRef(node);
63
+ }
60
64
  };
61
65
  }
62
66
 
@@ -65,20 +69,25 @@ let DrawerContent = (_dec = withStyle(generateStyle, generateComponentTheme), _d
65
69
  }
66
70
 
67
71
  componentDidMount() {
72
+ var _this$props$makeStyle, _this$props;
73
+
68
74
  const rect = getBoundingClientRect(this.ref);
69
75
  const origSize = {
70
76
  width: rect.width
71
77
  }; // set initial size
72
78
 
73
- this.props.onSizeChange({
74
- width: rect.width,
75
- height: rect.height
76
- }); // listen for changes to size
79
+ if (typeof this.props.onSizeChange === 'function') {
80
+ this.props.onSizeChange({
81
+ width: rect.width,
82
+ height: rect.height
83
+ }); // listen for changes to size
84
+
85
+ this._debounced = debounce(this.props.onSizeChange, 100, {
86
+ leading: false,
87
+ trailing: true
88
+ });
89
+ }
77
90
 
78
- this._debounced = debounce(this.props.onSizeChange, 100, {
79
- leading: false,
80
- trailing: true
81
- });
82
91
  this._resizeListener = new ResizeObserver(entries => {
83
92
  for (const entry of entries) {
84
93
  const size = {
@@ -86,46 +95,39 @@ let DrawerContent = (_dec = withStyle(generateStyle, generateComponentTheme), _d
86
95
  };
87
96
 
88
97
  if (size.width !== origSize.width) {
89
- this._debounced(size);
98
+ var _this$_debounced;
99
+
100
+ (_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this, size);
90
101
  }
91
102
  }
92
103
  });
93
104
 
94
105
  this._resizeListener.observe(this.ref);
95
106
 
96
- this.props.makeStyles({
97
- shouldTransition: false
98
- });
107
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps(false));
99
108
  }
100
109
 
101
- componentDidUpdate(prevProps, prevState, snapshot) {
102
- this.props.makeStyles({
103
- shouldTransition: true
104
- });
110
+ componentDidUpdate() {
111
+ var _this$props$makeStyle2, _this$props2;
112
+
113
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps(true));
105
114
  }
106
115
 
107
116
  componentWillUnmount() {
108
- if (this._resizeListener) {
109
- this._resizeListener.disconnect();
110
- }
111
-
112
- if (this._debounced) {
113
- this._debounced.cancel();
114
- }
117
+ var _this$_resizeListener, _this$_debounced2;
115
118
 
116
- this._timeouts.forEach(timeout => {
117
- clearTimeout(timeout);
118
- });
119
+ (_this$_resizeListener = this._resizeListener) === null || _this$_resizeListener === void 0 ? void 0 : _this$_resizeListener.disconnect();
120
+ (_this$_debounced2 = this._debounced) === null || _this$_debounced2 === void 0 ? void 0 : _this$_debounced2.cancel();
119
121
  }
120
122
 
121
123
  render() {
122
124
  var _this$props$styles;
123
125
 
124
- const _this$props2 = this.props,
125
- style = _this$props2.style,
126
- label = _this$props2.label,
127
- role = _this$props2.role;
128
- return jsx("div", Object.assign({}, omitProps(this.props, DrawerContent.allowedProps, ['shouldTransition']), {
126
+ const _this$props3 = this.props,
127
+ style = _this$props3.style,
128
+ label = _this$props3.label,
129
+ role = _this$props3.role;
130
+ return jsx("div", Object.assign({}, omitProps(this.props, DrawerContent.allowedProps), {
129
131
  role: role,
130
132
  style: style,
131
133
  ref: this.handleContentRef,
@@ -135,9 +137,6 @@ let DrawerContent = (_dec = withStyle(generateStyle, generateComponentTheme), _d
135
137
  }
136
138
 
137
139
  }, _class2.displayName = "DrawerContent", _class2.componentId = 'DrawerLayout.Content', _class2.locatorAttribute = 'data-drawer-content', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
138
- children: null,
139
- contentRef: el => {},
140
- onSizeChange: node => {},
141
140
  role: 'region'
142
141
  }, _temp)) || _class) || _class);
143
142
  export default DrawerContent;
@@ -26,10 +26,6 @@ const propTypes = {
26
26
  label: PropTypes.string.isRequired,
27
27
  children: PropTypes.node,
28
28
  contentRef: PropTypes.func,
29
-
30
- /**
31
- * Callback fired whenever the `<DrawerLayout.Content />` changes size
32
- */
33
29
  onSizeChange: PropTypes.func,
34
30
  role: PropTypes.string
35
31
  };
@@ -32,7 +32,7 @@
32
32
  * @param {Object} state the state of the component, the style is applied to
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
- const generateStyle = (componentTheme, props, state) => {
35
+ const generateStyle = (componentTheme, _props, state) => {
36
36
  const shouldTransition = state.shouldTransition;
37
37
  const transitionState = shouldTransition ? {
38
38
  transition: `margin ${componentTheme.duration}`
@@ -25,7 +25,8 @@ import { locator } from '@instructure/ui-test-locator';
25
25
  import { DrawerLayout } from './index';
26
26
  import { DrawerContentLocator } from './DrawerContent/DrawerContentLocator';
27
27
  import { DrawerTrayLocator } from './DrawerTray/DrawerTrayLocator';
28
- export { DrawerContentLocator, DrawerTrayLocator };
28
+ export { DrawerContentLocator, DrawerTrayLocator }; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
29
+
29
30
  export const DrawerLayoutLocator = locator(DrawerLayout.selector, {
30
31
  findContent: function () {
31
32
  return DrawerContentLocator.find(...arguments);
@@ -22,5 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import { locator } from '@instructure/ui-test-locator';
25
- import { DrawerTray } from './index';
25
+ import { DrawerTray } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
26
+
26
27
  export const DrawerTrayLocator = locator(DrawerTray.selector);
@@ -48,16 +48,17 @@ import { propTypes, allowedProps } from './props';
48
48
  parent: DrawerLayout
49
49
  id: DrawerLayout.Tray
50
50
  ---
51
+ @tsProps
51
52
  **/
52
53
  let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class DrawerTray extends Component {
53
- constructor() {
54
- super(...arguments);
55
- this.state = {
56
- transitioning: false,
57
- portalOpen: false
58
- };
59
- this._DOMNode = null;
54
+ get _content() {
55
+ return this.ref;
56
+ }
57
+
58
+ constructor(props) {
59
+ super(props);
60
60
  this.ref = null;
61
+ this._DOMNode = null;
61
62
 
62
63
  this.makeStyleProps = () => {
63
64
  return {
@@ -66,19 +67,20 @@ let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
66
67
  };
67
68
 
68
69
  this.handleContentRef = node => {
69
- var _this$props$contentRe, _this$props;
70
-
71
70
  this.ref = node;
72
- (_this$props$contentRe = (_this$props = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props, node);
71
+
72
+ if (typeof this.props.contentRef === 'function') {
73
+ this.props.contentRef(node);
74
+ }
73
75
  };
74
76
 
75
- this.handleTransitionEntered = () => {
77
+ this.handleTransitionEntered = _transitionType => {
76
78
  this.setState({
77
79
  transitioning: false
78
80
  });
79
81
  };
80
82
 
81
- this.handleTransitionExited = () => {
83
+ this.handleTransitionExited = _transitionType => {
82
84
  this.setState({
83
85
  transitioning: false
84
86
  });
@@ -90,32 +92,35 @@ let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
90
92
  portalOpen: true
91
93
  });
92
94
  };
93
- }
94
95
 
95
- get _content() {
96
- return this.ref;
96
+ this.state = {
97
+ transitioning: false,
98
+ portalOpen: false
99
+ };
97
100
  }
98
101
 
99
102
  componentDidMount() {
100
- ;
101
- this.props.makeStyles(this.makeStyleProps());
103
+ var _this$props$makeStyle, _this$props;
104
+
105
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
102
106
  }
103
107
 
104
- componentDidUpdate(prevProps, prevState, snapshot) {
108
+ componentDidUpdate(prevProps) {
109
+ var _this$props$makeStyle2, _this$props2;
110
+
105
111
  if (this.props.open !== prevProps.open) {
106
112
  this.setState({
107
113
  transitioning: true
108
114
  });
109
115
  }
110
116
 
111
- ;
112
- this.props.makeStyles(this.makeStyleProps());
117
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
113
118
  }
114
119
 
115
120
  get placement() {
116
- const _this$props2 = this.props,
117
- placement = _this$props2.placement,
118
- dir = _this$props2.dir;
121
+ const _this$props3 = this.props,
122
+ placement = _this$props3.placement,
123
+ dir = _this$props3.dir;
119
124
  const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl;
120
125
  return isRtl ? mirrorHorizontalPlacement(placement, ' ') : placement;
121
126
  }
@@ -137,9 +142,9 @@ let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
137
142
  }
138
143
 
139
144
  renderContent() {
140
- const _this$props3 = this.props,
141
- children = _this$props3.children,
142
- render = _this$props3.render;
145
+ const _this$props4 = this.props,
146
+ children = _this$props4.children,
147
+ render = _this$props4.render;
143
148
 
144
149
  if (typeof render === 'function') {
145
150
  return render();
@@ -151,40 +156,40 @@ let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
151
156
  }
152
157
 
153
158
  render() {
154
- const _this$props4 = this.props,
155
- label = _this$props4.label,
156
- children = _this$props4.children,
157
- render = _this$props4.render,
158
- placement = _this$props4.placement,
159
- open = _this$props4.open,
160
- onOpen = _this$props4.onOpen,
161
- onClose = _this$props4.onClose,
162
- border = _this$props4.border,
163
- shadow = _this$props4.shadow,
164
- onEnter = _this$props4.onEnter,
165
- onEntering = _this$props4.onEntering,
166
- onEntered = _this$props4.onEntered,
167
- onExit = _this$props4.onExit,
168
- onExiting = _this$props4.onExiting,
169
- onExited = _this$props4.onExited,
170
- contentRef = _this$props4.contentRef,
171
- mountNode = _this$props4.mountNode,
172
- defaultFocusElement = _this$props4.defaultFocusElement,
173
- liveRegion = _this$props4.liveRegion,
174
- onDismiss = _this$props4.onDismiss,
175
- onTransition = _this$props4.onTransition,
176
- shouldReturnFocus = _this$props4.shouldReturnFocus,
177
- shouldCloseOnEscape = _this$props4.shouldCloseOnEscape,
178
- shouldCloseOnDocumentClick = _this$props4.shouldCloseOnDocumentClick,
179
- shouldContainFocus = _this$props4.shouldContainFocus,
180
- styles = _this$props4.styles,
181
- props = _objectWithoutProperties(_this$props4, _excluded);
159
+ const _this$props5 = this.props,
160
+ label = _this$props5.label,
161
+ children = _this$props5.children,
162
+ render = _this$props5.render,
163
+ placement = _this$props5.placement,
164
+ open = _this$props5.open,
165
+ onOpen = _this$props5.onOpen,
166
+ onClose = _this$props5.onClose,
167
+ border = _this$props5.border,
168
+ shadow = _this$props5.shadow,
169
+ onEnter = _this$props5.onEnter,
170
+ onEntering = _this$props5.onEntering,
171
+ onEntered = _this$props5.onEntered,
172
+ onExit = _this$props5.onExit,
173
+ onExiting = _this$props5.onExiting,
174
+ onExited = _this$props5.onExited,
175
+ contentRef = _this$props5.contentRef,
176
+ mountNode = _this$props5.mountNode,
177
+ defaultFocusElement = _this$props5.defaultFocusElement,
178
+ liveRegion = _this$props5.liveRegion,
179
+ onDismiss = _this$props5.onDismiss,
180
+ onTransition = _this$props5.onTransition,
181
+ shouldReturnFocus = _this$props5.shouldReturnFocus,
182
+ shouldCloseOnEscape = _this$props5.shouldCloseOnEscape,
183
+ shouldCloseOnDocumentClick = _this$props5.shouldCloseOnDocumentClick,
184
+ shouldContainFocus = _this$props5.shouldContainFocus,
185
+ styles = _this$props5.styles,
186
+ props = _objectWithoutProperties(_this$props5, _excluded);
182
187
 
183
188
  return jsx(DrawerLayoutContext.Consumer, null, shouldOverlayTray => {
184
189
  var _this$props$styles;
185
190
 
186
191
  const portalOpen = this.state.portalOpen;
187
- const needsPortal = shouldOverlayTray && mountNode; // we have to handle the shadow version here,
192
+ const needsPortal = shouldOverlayTray && !!mountNode; // we have to handle the shadow version here,
188
193
  // because passing and handling it in styles.js makes it
189
194
  // rerender the component during the transition, breaking it
190
195
 
@@ -237,24 +242,14 @@ let DrawerTray = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
237
242
  }
238
243
 
239
244
  }, _class2.displayName = "DrawerTray", _class2.componentId = 'DrawerLayout.Tray', _class2.locatorAttribute = 'data-drawer-tray', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
240
- children: null,
241
245
  shouldContainFocus: true,
242
246
  shouldCloseOnEscape: true,
243
247
  shouldCloseOnDocumentClick: true,
244
248
  shouldReturnFocus: true,
245
249
  open: false,
246
- onOpen: () => {},
247
250
  shadow: true,
248
251
  border: true,
249
- placement: 'start',
250
- mountNode: null,
251
- onEnter: () => {},
252
- onEntering: () => {},
253
- onEntered: () => {},
254
- onExit: () => {},
255
- onExiting: () => {},
256
- onExited: () => {},
257
- contentRef: node => {}
252
+ placement: 'start'
258
253
  }, _temp)) || _class) || _class) || _class);
259
254
  export default DrawerTray;
260
255
  export { DrawerTray };
@@ -28,92 +28,22 @@ const propTypes = {
28
28
  label: PropTypes.string.isRequired,
29
29
  children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
30
30
  render: PropTypes.func,
31
-
32
- /**
33
- * Placement of the `<DrawerLayout.Tray />`
34
- */
35
31
  placement: PropTypes.oneOf(['start', 'end']),
36
-
37
- /**
38
- * If the tray is open or closed.
39
- */
40
32
  open: PropTypes.bool,
41
-
42
- /**
43
- * Called when the `<DrawerLayout.Tray />` is opened
44
- */
45
33
  onOpen: PropTypes.func,
46
-
47
- /**
48
- * Called when the `<DrawerLayout.Tray />` is closed
49
- */
50
34
  onClose: PropTypes.func,
51
-
52
- /**
53
- * Should the `<DrawerLayout.Tray />` have a border
54
- */
55
35
  border: PropTypes.bool,
56
-
57
- /**
58
- * Should the `<DrawerLayout.Tray />` have a shadow
59
- */
60
36
  shadow: PropTypes.bool,
61
-
62
- /**
63
- * Callback fired when the `<DrawerLayout.Tray />` transitions in/out
64
- */
65
37
  onTransition: PropTypes.func,
66
-
67
- /**
68
- * Callback fired before the `<DrawerLayout.Tray />` transitions in
69
- */
70
38
  onEnter: PropTypes.func,
71
-
72
- /**
73
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition in
74
- */
75
39
  onEntering: PropTypes.func,
76
-
77
- /**
78
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning in
79
- */
80
40
  onEntered: PropTypes.func,
81
-
82
- /**
83
- * Callback fired right before the `<DrawerLayout.Tray />` transitions out
84
- */
85
41
  onExit: PropTypes.func,
86
-
87
- /**
88
- * Callback fired as the `<DrawerLayout.Tray />` begins to transition out
89
- */
90
42
  onExiting: PropTypes.func,
91
-
92
- /**
93
- * Callback fired after the `<DrawerLayout.Tray />` finishes transitioning out
94
- */
95
43
  onExited: PropTypes.func,
96
-
97
- /**
98
- * Ref function for the `<DrawerLayout.Tray />` content
99
- */
100
44
  contentRef: PropTypes.func,
101
-
102
- /**
103
- * An element or a function returning an element to use as the mount node
104
- * for the `<DrawerLayout.Tray />` when tray is overlaying content
105
- */
106
45
  mountNode: PropTypes.oneOfType([element, PropTypes.func]),
107
-
108
- /**
109
- * An element or a function returning an element to focus by default
110
- */
111
46
  defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
112
-
113
- /**
114
- * An element, function returning an element, or array of elements that will not be hidden from
115
- * the screen reader when the `<DrawerLayout.Tray />` is open
116
- */
117
47
  liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
118
48
  onDismiss: PropTypes.func,
119
49
  shouldContainFocus: PropTypes.bool,
@@ -30,7 +30,7 @@ export default {
30
30
  propValues: {
31
31
  dir: ['ltr']
32
32
  },
33
- getComponentProps: props => {
33
+ getComponentProps: () => {
34
34
  return {
35
35
  children: [_DrawerLayout$Tray || (_DrawerLayout$Tray = /*#__PURE__*/React.createElement(DrawerLayout.Tray, {
36
36
  key: "0",
@@ -61,7 +61,7 @@ export default {
61
61
  }, "Drawer content"))))]
62
62
  };
63
63
  },
64
- getExampleProps: props => {
64
+ getExampleProps: () => {
65
65
  return {
66
66
  as: 'div',
67
67
  borderWidth: 'small'
@@ -25,7 +25,7 @@ var _dec, _dec2, _dec3, _class, _class2, _temp;
25
25
  */
26
26
 
27
27
  /** @jsx jsx */
28
- import { Children, Component, createContext } from 'react';
28
+ import React, { Children, Component, createContext } from 'react';
29
29
  import { textDirectionContextConsumer } from '@instructure/ui-i18n';
30
30
  import { matchComponentTypes, safeCloneElement } from '@instructure/ui-react-utils';
31
31
  import { getBoundingClientRect } from '@instructure/ui-dom-utils';
@@ -44,11 +44,14 @@ import { propTypes, allowedProps } from './props';
44
44
  ---
45
45
  category: components
46
46
  ---
47
+ @tsProps
47
48
  **/
48
49
  let DrawerLayout = (_dec = withStyle(generateStyle, null), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class DrawerLayout extends Component {
49
50
  constructor(_props) {
50
51
  super(_props);
52
+ this._id = void 0;
51
53
  this._content = null;
54
+ this._tray = null;
52
55
  this.ref = null;
53
56
 
54
57
  this.handleRef = el => {
@@ -112,11 +115,15 @@ let DrawerLayout = (_dec = withStyle(generateStyle, null), _dec2 = textDirection
112
115
  }
113
116
 
114
117
  componentDidMount() {
115
- this.props.makeStyles();
118
+ var _this$props$makeStyle, _this$props;
119
+
120
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
116
121
  }
117
122
 
118
- componentDidUpdate(prevProps, prevState, snapshot) {
119
- this.props.makeStyles();
123
+ componentDidUpdate() {
124
+ var _this$props$makeStyle2, _this$props2;
125
+
126
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
120
127
  }
121
128
 
122
129
  get trayProps() {
@@ -190,11 +197,11 @@ let DrawerLayout = (_dec = withStyle(generateStyle, null), _dec2 = textDirection
190
197
  renderChildren() {
191
198
  let trayCount = 0;
192
199
  let contentCount = 0;
193
- const shouldOverlayTray = this.shouldOverlayTray(this.props.minWidth, this.state.trayWidth, this.state.contentWidth, this.state.shouldOverlayTray);
194
- const children = Children.map(this.props.children, (child, index) => {
200
+ const children = Children.map(this.props.children, (child, _index) => {
195
201
  if (matchComponentTypes(child, [DrawerTray])) {
196
202
  trayCount++;
197
203
  return safeCloneElement(child, {
204
+ label: child.props.label,
198
205
  key: child.props.label,
199
206
  [DrawerTray.locatorAttribute]: this._id,
200
207
  contentRef: this.handleTrayContentRef,
@@ -205,20 +212,21 @@ let DrawerLayout = (_dec = withStyle(generateStyle, null), _dec2 = textDirection
205
212
  contentCount++;
206
213
 
207
214
  const handleContentRef = el => {
215
+ const contentRef = child.props.contentRef;
208
216
  this._content = el;
209
217
 
210
- if (typeof child.props.contentRef === 'function') {
211
- child.props.contentRef(el);
218
+ if (typeof contentRef === 'function') {
219
+ contentRef(el);
212
220
  }
213
221
  };
214
222
 
215
223
  return this.state.trayWidth !== null ? safeCloneElement(child, {
224
+ label: child.props.label,
216
225
  key: child.props.label,
217
226
  [DrawerContent.locatorAttribute]: this._id,
218
227
  style: this.contentStyle,
219
228
  onSizeChange: createChainedFunction(this.handleContentSizeChange, child.props.onSizeChange),
220
- contentRef: handleContentRef,
221
- shouldTransition: !shouldOverlayTray
229
+ contentRef: handleContentRef
222
230
  }) : null;
223
231
  } else {
224
232
  return child;
@@ -244,9 +252,7 @@ let DrawerLayout = (_dec = withStyle(generateStyle, null), _dec2 = textDirection
244
252
  }
245
253
 
246
254
  }, _class2.displayName = "DrawerLayout", _class2.componentId = 'DrawerLayout', _class2.locatorAttribute = 'data-drawer-layout', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
247
- children: null,
248
- minWidth: '30rem',
249
- onOverlayTrayChange: shouldOverlayTray => {}
255
+ minWidth: '30rem'
250
256
  }, _class2.Content = DrawerContent, _class2.Tray = DrawerTray, _temp)) || _class) || _class) || _class);
251
257
  export default DrawerLayout;
252
258
  export { DrawerLayout, DrawerContent, DrawerTray };
@@ -27,21 +27,8 @@ import { textDirectionContextConsumer } from '@instructure/ui-i18n';
27
27
  import { DrawerContent } from './DrawerContent';
28
28
  import { DrawerTray } from './DrawerTray';
29
29
  const propTypes = {
30
- /**
31
- * Exactly one of each of the following child types: `DrawerLayout.Content`, `DrawerLayout.Tray`
32
- */
33
30
  children: ChildrenPropTypes.oneOfEach([DrawerContent, DrawerTray]),
34
-
35
- /**
36
- * Min width for the `<DrawerLayout.Content />`
37
- */
38
31
  minWidth: PropTypes.string,
39
-
40
- /**
41
- * Function called when the `<DrawerLayout.Content />` is resized and hits the `minWidth` breakpoint
42
- * Called with a boolean value, `true` if the tray is now overlaying the content or `false` if
43
- * it is side by side
44
- */
45
32
  onOverlayTrayChange: PropTypes.func,
46
33
  dir: PropTypes.oneOf(Object.values(textDirectionContextConsumer.DIRECTION))
47
34
  };
@@ -32,5 +32,6 @@ var _index = require("./index");
32
32
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
33
  * SOFTWARE.
34
34
  */
35
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
35
36
  const DrawerContentLocator = (0, _locator.locator)(_index.DrawerContent.selector);
36
37
  exports.DrawerContentLocator = DrawerContentLocator;