@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.
- package/es/DrawerLayout/DrawerContent/DrawerContentLocator.js +2 -1
- package/es/DrawerLayout/DrawerContent/index.js +42 -43
- package/es/DrawerLayout/DrawerContent/props.js +0 -4
- package/es/DrawerLayout/DrawerContent/styles.js +1 -1
- package/es/DrawerLayout/DrawerLayoutLocator.js +2 -1
- package/es/DrawerLayout/DrawerTray/DrawerTrayLocator.js +2 -1
- package/es/DrawerLayout/DrawerTray/index.js +61 -66
- package/es/DrawerLayout/DrawerTray/props.js +0 -70
- package/es/DrawerLayout/__examples__/DrawerLayout.examples.js +2 -2
- package/es/DrawerLayout/index.js +19 -13
- package/es/DrawerLayout/props.js +0 -13
- package/lib/DrawerLayout/DrawerContent/DrawerContentLocator.js +1 -0
- package/lib/DrawerLayout/DrawerContent/index.js +42 -43
- package/lib/DrawerLayout/DrawerContent/props.js +0 -4
- package/lib/DrawerLayout/DrawerContent/styles.js +1 -1
- package/lib/DrawerLayout/DrawerLayoutLocator.js +1 -0
- package/lib/DrawerLayout/DrawerTray/DrawerTrayLocator.js +1 -0
- package/lib/DrawerLayout/DrawerTray/index.js +61 -66
- package/lib/DrawerLayout/DrawerTray/props.js +0 -70
- package/lib/DrawerLayout/__examples__/DrawerLayout.examples.js +2 -2
- package/lib/DrawerLayout/index.js +21 -13
- package/lib/DrawerLayout/props.js +0 -13
- package/package.json +22 -22
- package/src/DrawerLayout/DrawerContent/index.tsx +38 -57
- package/src/DrawerLayout/DrawerContent/props.ts +13 -10
- package/src/DrawerLayout/DrawerContent/styles.ts +3 -4
- package/src/DrawerLayout/DrawerTray/index.tsx +31 -33
- package/src/DrawerLayout/DrawerTray/props.ts +110 -69
- package/src/DrawerLayout/__examples__/DrawerLayout.examples.tsx +7 -5
- package/src/DrawerLayout/__fixtures__/DrawerLayout.fixture.tsx +14 -13
- package/src/DrawerLayout/index.tsx +74 -86
- package/src/DrawerLayout/props.ts +22 -13
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DrawerLayout/DrawerContent/DrawerContentLocator.d.ts +4 -4
- package/types/DrawerLayout/DrawerContent/index.d.ts +28 -19
- package/types/DrawerLayout/DrawerContent/index.d.ts.map +1 -1
- package/types/DrawerLayout/DrawerContent/props.d.ts +13 -6
- package/types/DrawerLayout/DrawerContent/props.d.ts.map +1 -1
- package/types/DrawerLayout/DrawerContent/styles.d.ts +2 -2
- package/types/DrawerLayout/DrawerContent/styles.d.ts.map +1 -1
- package/types/DrawerLayout/DrawerLayoutLocator.d.ts +14 -14
- package/types/DrawerLayout/DrawerTray/DrawerTrayLocator.d.ts +4 -4
- package/types/DrawerLayout/DrawerTray/index.d.ts +45 -21
- package/types/DrawerLayout/DrawerTray/index.d.ts.map +1 -1
- package/types/DrawerLayout/DrawerTray/props.d.ts +74 -16
- package/types/DrawerLayout/DrawerTray/props.d.ts.map +1 -1
- package/types/DrawerLayout/__examples__/DrawerLayout.examples.d.ts +3 -16
- package/types/DrawerLayout/__examples__/DrawerLayout.examples.d.ts.map +1 -1
- package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts +11 -1
- package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts.map +1 -1
- package/types/DrawerLayout/index.d.ts +116 -23
- package/types/DrawerLayout/index.d.ts.map +1 -1
- package/types/DrawerLayout/props.d.ts +19 -3
- 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 =
|
|
52
|
-
this._debounced =
|
|
53
|
-
this._timeouts = [];
|
|
49
|
+
this._resizeListener = void 0;
|
|
50
|
+
this._debounced = void 0;
|
|
54
51
|
|
|
55
|
-
this.
|
|
56
|
-
|
|
52
|
+
this.makeStyleProps = shouldTransition => {
|
|
53
|
+
return {
|
|
54
|
+
shouldTransition
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
57
|
|
|
58
|
+
this.handleContentRef = node => {
|
|
58
59
|
this.ref = node;
|
|
59
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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(
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
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.
|
|
117
|
-
|
|
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$
|
|
125
|
-
style = _this$
|
|
126
|
-
label = _this$
|
|
127
|
-
role = _this$
|
|
128
|
-
return jsx("div", Object.assign({}, omitProps(this.props, DrawerContent.allowedProps
|
|
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,
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
|
|
96
|
-
|
|
96
|
+
this.state = {
|
|
97
|
+
transitioning: false,
|
|
98
|
+
portalOpen: false
|
|
99
|
+
};
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
componentDidMount() {
|
|
100
|
-
;
|
|
101
|
-
|
|
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
|
|
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$
|
|
117
|
-
placement = _this$
|
|
118
|
-
dir = _this$
|
|
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$
|
|
141
|
-
children = _this$
|
|
142
|
-
render = _this$
|
|
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$
|
|
155
|
-
label = _this$
|
|
156
|
-
children = _this$
|
|
157
|
-
render = _this$
|
|
158
|
-
placement = _this$
|
|
159
|
-
open = _this$
|
|
160
|
-
onOpen = _this$
|
|
161
|
-
onClose = _this$
|
|
162
|
-
border = _this$
|
|
163
|
-
shadow = _this$
|
|
164
|
-
onEnter = _this$
|
|
165
|
-
onEntering = _this$
|
|
166
|
-
onEntered = _this$
|
|
167
|
-
onExit = _this$
|
|
168
|
-
onExiting = _this$
|
|
169
|
-
onExited = _this$
|
|
170
|
-
contentRef = _this$
|
|
171
|
-
mountNode = _this$
|
|
172
|
-
defaultFocusElement = _this$
|
|
173
|
-
liveRegion = _this$
|
|
174
|
-
onDismiss = _this$
|
|
175
|
-
onTransition = _this$
|
|
176
|
-
shouldReturnFocus = _this$
|
|
177
|
-
shouldCloseOnEscape = _this$
|
|
178
|
-
shouldCloseOnDocumentClick = _this$
|
|
179
|
-
shouldContainFocus = _this$
|
|
180
|
-
styles = _this$
|
|
181
|
-
props = _objectWithoutProperties(_this$
|
|
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:
|
|
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:
|
|
64
|
+
getExampleProps: () => {
|
|
65
65
|
return {
|
|
66
66
|
as: 'div',
|
|
67
67
|
borderWidth: 'small'
|
package/es/DrawerLayout/index.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
119
|
-
|
|
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
|
|
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
|
|
211
|
-
|
|
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
|
-
|
|
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 };
|
package/es/DrawerLayout/props.js
CHANGED
|
@@ -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;
|