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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +34 -288
  2. package/es/Tray/{index.js → v1/index.js} +2 -2
  3. package/es/Tray/v2/index.js +221 -0
  4. package/es/Tray/v2/props.js +26 -0
  5. package/es/Tray/v2/styles.js +131 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -3
  8. package/lib/Tray/v1/index.js +226 -0
  9. package/lib/Tray/{index.js → v2/index.js} +3 -4
  10. package/lib/Tray/v2/props.js +31 -0
  11. package/lib/Tray/v2/styles.js +137 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +43 -21
  15. package/src/Tray/{index.tsx → v1/index.tsx} +2 -2
  16. package/src/Tray/v2/README.md +100 -0
  17. package/src/Tray/v2/index.tsx +249 -0
  18. package/src/Tray/v2/props.ts +206 -0
  19. package/src/Tray/v2/styles.ts +158 -0
  20. package/src/exports/a.ts +26 -0
  21. package/src/exports/b.ts +26 -0
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/Tray/v1/index.d.ts.map +1 -0
  24. package/types/Tray/v1/props.d.ts.map +1 -0
  25. package/types/Tray/v1/styles.d.ts.map +1 -0
  26. package/types/Tray/v1/theme.d.ts.map +1 -0
  27. package/types/Tray/v2/index.d.ts +77 -0
  28. package/types/Tray/v2/index.d.ts.map +1 -0
  29. package/types/Tray/v2/props.d.ts +133 -0
  30. package/types/Tray/v2/props.d.ts.map +1 -0
  31. package/types/Tray/v2/styles.d.ts +20 -0
  32. package/types/Tray/v2/styles.d.ts.map +1 -0
  33. package/types/exports/a.d.ts +3 -0
  34. package/types/exports/a.d.ts.map +1 -0
  35. package/types/exports/b.d.ts +3 -0
  36. package/types/exports/b.d.ts.map +1 -0
  37. package/types/Tray/index.d.ts.map +0 -1
  38. package/types/Tray/props.d.ts.map +0 -1
  39. package/types/Tray/styles.d.ts.map +0 -1
  40. package/types/Tray/theme.d.ts.map +0 -1
  41. package/types/index.d.ts +0 -3
  42. package/types/index.d.ts.map +0 -1
  43. /package/es/Tray/{props.js → v1/props.js} +0 -0
  44. /package/es/Tray/{styles.js → v1/styles.js} +0 -0
  45. /package/es/Tray/{theme.js → v1/theme.js} +0 -0
  46. /package/lib/Tray/{props.js → v1/props.js} +0 -0
  47. /package/lib/Tray/{styles.js → v1/styles.js} +0 -0
  48. /package/lib/Tray/{theme.js → v1/theme.js} +0 -0
  49. /package/src/Tray/{README.md → v1/README.md} +0 -0
  50. /package/src/Tray/{props.ts → v1/props.ts} +0 -0
  51. /package/src/Tray/{styles.ts → v1/styles.ts} +0 -0
  52. /package/src/Tray/{theme.ts → v1/theme.ts} +0 -0
  53. /package/types/Tray/{index.d.ts → v1/index.d.ts} +0 -0
  54. /package/types/Tray/{props.d.ts → v1/props.d.ts} +0 -0
  55. /package/types/Tray/{styles.d.ts → v1/styles.d.ts} +0 -0
  56. /package/types/Tray/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,221 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["label", "children", "size", "placement", "open", "defaultFocusElement", "contentRef", "shouldContainFocus", "shouldReturnFocus", "shouldCloseOnDocumentClick", "onOpen", "onClose", "onDismiss", "mountNode", "insertAt", "liveRegion", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "onTransition", "transitionOnMount", "transitionEnter", "transitionExit", "border", "shadow", "role", "enableMask"];
3
+ var _dec, _dec2, _class, _Tray;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2015 - present Instructure, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ import { Component, createRef } from 'react';
29
+ import { Dialog } from '@instructure/ui-dialog';
30
+ import { omitProps } from '@instructure/ui-react-utils';
31
+ import { createChainedFunction } from '@instructure/ui-utils';
32
+ import { textDirectionContextConsumer } from '@instructure/ui-i18n';
33
+ import { Portal } from '@instructure/ui-portal';
34
+ import { mirrorHorizontalPlacement } from '@instructure/ui-position';
35
+ import { Transition } from '@instructure/ui-motion';
36
+ import { withStyle } from '@instructure/emotion';
37
+ import generateStyle from "./styles.js";
38
+ import { allowedProps } from "./props.js";
39
+ import { Mask } from '@instructure/ui-overlays/latest';
40
+
41
+ /**
42
+ ---
43
+ category: components
44
+ ---
45
+ **/
46
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
47
+ let Tray = (_dec = withStyle(generateStyle), _dec2 = textDirectionContextConsumer(), _dec(_class = _dec2(_class = (_Tray = class Tray extends Component {
48
+ constructor(props) {
49
+ var _props$open;
50
+ super(props);
51
+ this.ref = null;
52
+ this.dialogRef = /*#__PURE__*/createRef();
53
+ this.state = void 0;
54
+ this.handleTransitionComplete = _type => {
55
+ this.setState({
56
+ transitioning: false
57
+ });
58
+ };
59
+ this.handlePortalOpen = DOMNode => {
60
+ if (DOMNode) {
61
+ this.DOMNode = DOMNode;
62
+ }
63
+ };
64
+ this.state = {
65
+ transitioning: false,
66
+ open: (_props$open = props.open) !== null && _props$open !== void 0 ? _props$open : false
67
+ };
68
+ }
69
+ componentDidMount() {
70
+ var _this$props$makeStyle, _this$props;
71
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
72
+ }
73
+ componentDidUpdate(prevProps, _prevState) {
74
+ var _this$props$makeStyle2, _this$props2;
75
+ if (this.props.open !== prevProps.open) {
76
+ if (!this.props.open) {
77
+ var _this$dialogRef$curre;
78
+ // calling Dialog.close() to remove focusregion immediately when transition starts
79
+ // so if a new Tray is opened (during transition) the new focusregion won't get treated as a child of this one
80
+ (_this$dialogRef$curre = this.dialogRef.current) === null || _this$dialogRef$curre === void 0 ? void 0 : _this$dialogRef$curre.close();
81
+ }
82
+ this.setState({
83
+ transitioning: true,
84
+ open: this.props.open
85
+ });
86
+ }
87
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
88
+ }
89
+ get placement() {
90
+ const _this$props3 = this.props,
91
+ placement = _this$props3.placement,
92
+ dir = _this$props3.dir;
93
+ const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl;
94
+ return isRtl ? mirrorHorizontalPlacement(placement, ' ') : placement;
95
+ }
96
+ get direction() {
97
+ switch (this.placement) {
98
+ case 'top':
99
+ return 'up';
100
+ case 'bottom':
101
+ return 'down';
102
+ case 'end':
103
+ return 'right';
104
+ default:
105
+ // start
106
+ return 'left';
107
+ }
108
+ }
109
+ get transition() {
110
+ return `slide-${this.direction}`;
111
+ }
112
+ get DOMNode() {
113
+ // The DOMNode property is needed for Portal type components
114
+ return this.ref;
115
+ }
116
+ set DOMNode(el) {
117
+ this.ref = el ? el : null;
118
+ }
119
+ render() {
120
+ var _this$props$styles, _this$props$styles2;
121
+ const _this$props4 = this.props,
122
+ label = _this$props4.label,
123
+ children = _this$props4.children,
124
+ size = _this$props4.size,
125
+ placement = _this$props4.placement,
126
+ open = _this$props4.open,
127
+ defaultFocusElement = _this$props4.defaultFocusElement,
128
+ contentRef = _this$props4.contentRef,
129
+ shouldContainFocus = _this$props4.shouldContainFocus,
130
+ shouldReturnFocus = _this$props4.shouldReturnFocus,
131
+ shouldCloseOnDocumentClick = _this$props4.shouldCloseOnDocumentClick,
132
+ onOpen = _this$props4.onOpen,
133
+ onClose = _this$props4.onClose,
134
+ onDismiss = _this$props4.onDismiss,
135
+ mountNode = _this$props4.mountNode,
136
+ insertAt = _this$props4.insertAt,
137
+ liveRegion = _this$props4.liveRegion,
138
+ onEnter = _this$props4.onEnter,
139
+ onEntering = _this$props4.onEntering,
140
+ onEntered = _this$props4.onEntered,
141
+ onExit = _this$props4.onExit,
142
+ onExiting = _this$props4.onExiting,
143
+ onExited = _this$props4.onExited,
144
+ onTransition = _this$props4.onTransition,
145
+ transitionOnMount = _this$props4.transitionOnMount,
146
+ transitionEnter = _this$props4.transitionEnter,
147
+ transitionExit = _this$props4.transitionExit,
148
+ border = _this$props4.border,
149
+ shadow = _this$props4.shadow,
150
+ role = _this$props4.role,
151
+ enableMask = _this$props4.enableMask,
152
+ props = _objectWithoutProperties(_this$props4, _excluded);
153
+ const portalIsOpen = this.state.open || this.state.transitioning;
154
+ const content = _jsx(Transition, {
155
+ in: open,
156
+ type: this.transition,
157
+ onTransition: onTransition,
158
+ onEnter: onEnter,
159
+ onEntering: onEntering,
160
+ onEntered: createChainedFunction(this.handleTransitionComplete, onEntered, onOpen),
161
+ onExit: onExit,
162
+ onExiting: onExiting,
163
+ onExited: createChainedFunction(this.handleTransitionComplete, onExited, onClose),
164
+ transitionOnMount: transitionOnMount,
165
+ transitionEnter: transitionEnter,
166
+ transitionExit: transitionExit,
167
+ children: _jsx("span", {
168
+ ...omitProps(props, Tray.allowedProps),
169
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.tray,
170
+ ref: contentRef,
171
+ children: _jsx(Dialog, {
172
+ ref: this.dialogRef,
173
+ as: "div",
174
+ label: label,
175
+ defaultFocusElement: defaultFocusElement,
176
+ open: true,
177
+ shouldContainFocus: shouldContainFocus,
178
+ shouldReturnFocus: shouldReturnFocus,
179
+ shouldCloseOnDocumentClick: shouldCloseOnDocumentClick,
180
+ shouldCloseOnEscape: true,
181
+ liveRegion: liveRegion,
182
+ onDismiss: onDismiss,
183
+ role: role,
184
+ children: _jsx("div", {
185
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.content,
186
+ children: children
187
+ })
188
+ })
189
+ })
190
+ });
191
+ return _jsx(Portal, {
192
+ open: portalIsOpen,
193
+ onOpen: this.handlePortalOpen,
194
+ insertAt: insertAt,
195
+ mountNode: mountNode,
196
+ "data-cid": "Tray",
197
+ children: enableMask ? _jsx(Mask, {
198
+ placement: 'center',
199
+ fullscreen: true,
200
+ children: content
201
+ }) : content
202
+ });
203
+ }
204
+ }, _Tray.displayName = "Tray", _Tray.componentId = 'Tray', _Tray.allowedProps = allowedProps, _Tray.defaultProps = {
205
+ defaultFocusElement: null,
206
+ open: false,
207
+ insertAt: 'bottom',
208
+ shouldCloseOnDocumentClick: false,
209
+ shouldContainFocus: true,
210
+ shouldReturnFocus: true,
211
+ size: 'small',
212
+ placement: 'start',
213
+ transitionOnMount: true,
214
+ transitionEnter: true,
215
+ transitionExit: true,
216
+ shadow: true,
217
+ border: false,
218
+ enableMask: false
219
+ }, _Tray)) || _class) || _class);
220
+ export default Tray;
221
+ export { Tray };
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['label', 'children', 'size', 'placement', 'open', 'defaultFocusElement', 'contentRef', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'onOpen', 'onClose', 'onDismiss', 'mountNode', 'insertAt', 'liveRegion', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'transitionOnMount', 'transitionEnter', 'transitionExit', 'border', 'shadow', 'enableMask'];
26
+ export { allowedProps };
@@ -0,0 +1,131 @@
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 { boxShadowObjectsToCSSString } from '@instructure/ui-themes';
26
+ /**
27
+ * ---
28
+ * private: true
29
+ * ---
30
+ * Generates the style object from the theme and provided additional information
31
+ * @param {Object} componentTheme The theme variable object.
32
+ * @param {Object} params the props and passed through data of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, params) => {
36
+ const border = params.border,
37
+ shadow = params.shadow,
38
+ size = params.size,
39
+ placement = params.placement;
40
+ const borderStyle = {
41
+ borderWidth: 0,
42
+ borderColor: componentTheme.borderColor,
43
+ borderStyle: 'solid'
44
+ };
45
+ const shadowStyle = shadow ? {
46
+ boxShadow: boxShadowObjectsToCSSString(componentTheme.boxShadow)
47
+ } : {};
48
+ const contentStyle = placement === 'start' || placement === 'end' || placement === 'center' ? {
49
+ label: 'tray__content',
50
+ minHeight: '100vh'
51
+ } : {};
52
+ const placementStyles = {
53
+ top: {
54
+ insetInlineStart: 0,
55
+ insetInlineEnd: 0,
56
+ top: 0
57
+ },
58
+ bottom: {
59
+ insetInlineStart: 0,
60
+ insetInlineEnd: 0,
61
+ bottom: 0
62
+ },
63
+ start: {
64
+ top: 0,
65
+ bottom: 0,
66
+ insetInlineStart: 0,
67
+ insetInlineEnd: 'auto'
68
+ },
69
+ end: {
70
+ top: 0,
71
+ bottom: 0,
72
+ insetInlineEnd: 0,
73
+ insetInlineStart: 'auto'
74
+ },
75
+ center: {
76
+ left: 0,
77
+ right: 0,
78
+ top: 0,
79
+ bottom: 0
80
+ }
81
+ };
82
+ const borderPlacementStyle = border ? {
83
+ start: {
84
+ borderInlineEndWidth: componentTheme.borderWidth
85
+ },
86
+ end: {
87
+ borderInlineStartWidth: componentTheme.borderWidth
88
+ },
89
+ top: {
90
+ borderBottomWidth: componentTheme.borderWidth
91
+ },
92
+ bottom: {
93
+ borderTopWidth: componentTheme.borderWidth
94
+ },
95
+ center: {}
96
+ } : {};
97
+ const sizeVariants = {
98
+ 'x-small': componentTheme.widthXs,
99
+ small: componentTheme.widthSm,
100
+ regular: componentTheme.widthMd,
101
+ medium: componentTheme.widthLg,
102
+ large: componentTheme.widthXl
103
+ };
104
+ const sizeStyle = placement === 'start' || placement === 'end' ? {
105
+ width: sizeVariants[size]
106
+ } : {};
107
+ return {
108
+ tray: {
109
+ label: 'tray',
110
+ padding: componentTheme.padding,
111
+ backgroundColor: componentTheme.backgroundColor,
112
+ position: 'fixed',
113
+ overflowY: 'auto',
114
+ overflowX: 'hidden',
115
+ boxSizing: 'border-box',
116
+ zIndex: componentTheme.zIndex,
117
+ maxWidth: '100vw',
118
+ maxHeight: '100vh',
119
+ ...shadowStyle,
120
+ ...placementStyles[placement],
121
+ ...(border && borderStyle),
122
+ ...(border && borderPlacementStyle[placement]),
123
+ ...sizeStyle
124
+ },
125
+ content: {
126
+ label: 'tray__content',
127
+ ...contentStyle
128
+ }
129
+ };
130
+ };
131
+ export default generateStyle;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { Tray } from "./Tray/index.js";
24
+ export { Tray } from "../Tray/v1/index.js";
@@ -21,6 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
-
25
- export { Tray } from './Tray'
26
- export type { TrayProps } from './Tray/props'
24
+ export { Tray } from "../Tray/v2/index.js";
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Tray = void 0;
8
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
+ var _react = require("react");
10
+ var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
11
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
+ var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
13
+ var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
14
+ var _Portal = require("@instructure/ui-portal/lib/Portal");
15
+ var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHorizontalPlacement.js");
16
+ var _Transition = require("@instructure/ui-motion/lib/Transition");
17
+ var _emotion = require("@instructure/emotion");
18
+ var _styles = _interopRequireDefault(require("./styles"));
19
+ var _theme = _interopRequireDefault(require("./theme"));
20
+ var _props = require("./props");
21
+ var _v11_ = require("@instructure/ui-overlays/v11_6");
22
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
+ const _excluded = ["label", "children", "size", "placement", "open", "defaultFocusElement", "contentRef", "shouldContainFocus", "shouldReturnFocus", "shouldCloseOnDocumentClick", "onOpen", "onClose", "onDismiss", "mountNode", "insertAt", "liveRegion", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "onTransition", "transitionOnMount", "transitionEnter", "transitionExit", "border", "shadow", "role", "enableMask"];
24
+ var _dec, _dec2, _class, _Tray;
25
+ /*
26
+ * The MIT License (MIT)
27
+ *
28
+ * Copyright (c) 2015 - present Instructure, Inc.
29
+ *
30
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
31
+ * of this software and associated documentation files (the "Software"), to deal
32
+ * in the Software without restriction, including without limitation the rights
33
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34
+ * copies of the Software, and to permit persons to whom the Software is
35
+ * furnished to do so, subject to the following conditions:
36
+ *
37
+ * The above copyright notice and this permission notice shall be included in all
38
+ * copies or substantial portions of the Software.
39
+ *
40
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46
+ * SOFTWARE.
47
+ */
48
+ /**
49
+ ---
50
+ category: components
51
+ ---
52
+ **/
53
+ let Tray = exports.Tray = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = (_Tray = class Tray extends _react.Component {
54
+ constructor(props) {
55
+ var _props$open;
56
+ super(props);
57
+ this.ref = null;
58
+ this.dialogRef = /*#__PURE__*/(0, _react.createRef)();
59
+ this.state = void 0;
60
+ this.handleTransitionComplete = _type => {
61
+ this.setState({
62
+ transitioning: false
63
+ });
64
+ };
65
+ this.handlePortalOpen = DOMNode => {
66
+ if (DOMNode) {
67
+ this.DOMNode = DOMNode;
68
+ }
69
+ };
70
+ this.state = {
71
+ transitioning: false,
72
+ open: (_props$open = props.open) !== null && _props$open !== void 0 ? _props$open : false
73
+ };
74
+ }
75
+ componentDidMount() {
76
+ var _this$props$makeStyle, _this$props;
77
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
78
+ }
79
+ componentDidUpdate(prevProps, _prevState) {
80
+ var _this$props$makeStyle2, _this$props2;
81
+ if (this.props.open !== prevProps.open) {
82
+ if (!this.props.open) {
83
+ var _this$dialogRef$curre;
84
+ // calling Dialog.close() to remove focusregion immediately when transition starts
85
+ // so if a new Tray is opened (during transition) the new focusregion won't get treated as a child of this one
86
+ (_this$dialogRef$curre = this.dialogRef.current) === null || _this$dialogRef$curre === void 0 ? void 0 : _this$dialogRef$curre.close();
87
+ }
88
+ this.setState({
89
+ transitioning: true,
90
+ open: this.props.open
91
+ });
92
+ }
93
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
94
+ }
95
+ get placement() {
96
+ const _this$props3 = this.props,
97
+ placement = _this$props3.placement,
98
+ dir = _this$props3.dir;
99
+ const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
100
+ return isRtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement;
101
+ }
102
+ get direction() {
103
+ switch (this.placement) {
104
+ case 'top':
105
+ return 'up';
106
+ case 'bottom':
107
+ return 'down';
108
+ case 'end':
109
+ return 'right';
110
+ default:
111
+ // start
112
+ return 'left';
113
+ }
114
+ }
115
+ get transition() {
116
+ return `slide-${this.direction}`;
117
+ }
118
+ get DOMNode() {
119
+ // The DOMNode property is needed for Portal type components
120
+ return this.ref;
121
+ }
122
+ set DOMNode(el) {
123
+ this.ref = el ? el : null;
124
+ }
125
+ render() {
126
+ var _this$props$styles, _this$props$styles2;
127
+ const _this$props4 = this.props,
128
+ label = _this$props4.label,
129
+ children = _this$props4.children,
130
+ size = _this$props4.size,
131
+ placement = _this$props4.placement,
132
+ open = _this$props4.open,
133
+ defaultFocusElement = _this$props4.defaultFocusElement,
134
+ contentRef = _this$props4.contentRef,
135
+ shouldContainFocus = _this$props4.shouldContainFocus,
136
+ shouldReturnFocus = _this$props4.shouldReturnFocus,
137
+ shouldCloseOnDocumentClick = _this$props4.shouldCloseOnDocumentClick,
138
+ onOpen = _this$props4.onOpen,
139
+ onClose = _this$props4.onClose,
140
+ onDismiss = _this$props4.onDismiss,
141
+ mountNode = _this$props4.mountNode,
142
+ insertAt = _this$props4.insertAt,
143
+ liveRegion = _this$props4.liveRegion,
144
+ onEnter = _this$props4.onEnter,
145
+ onEntering = _this$props4.onEntering,
146
+ onEntered = _this$props4.onEntered,
147
+ onExit = _this$props4.onExit,
148
+ onExiting = _this$props4.onExiting,
149
+ onExited = _this$props4.onExited,
150
+ onTransition = _this$props4.onTransition,
151
+ transitionOnMount = _this$props4.transitionOnMount,
152
+ transitionEnter = _this$props4.transitionEnter,
153
+ transitionExit = _this$props4.transitionExit,
154
+ border = _this$props4.border,
155
+ shadow = _this$props4.shadow,
156
+ role = _this$props4.role,
157
+ enableMask = _this$props4.enableMask,
158
+ props = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
159
+ const portalIsOpen = this.state.open || this.state.transitioning;
160
+ const content = (0, _jsxRuntime.jsx)(_Transition.Transition, {
161
+ in: open,
162
+ type: this.transition,
163
+ onTransition: onTransition,
164
+ onEnter: onEnter,
165
+ onEntering: onEntering,
166
+ onEntered: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionComplete, onEntered, onOpen),
167
+ onExit: onExit,
168
+ onExiting: onExiting,
169
+ onExited: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionComplete, onExited, onClose),
170
+ transitionOnMount: transitionOnMount,
171
+ transitionEnter: transitionEnter,
172
+ transitionExit: transitionExit,
173
+ children: (0, _jsxRuntime.jsx)("span", {
174
+ ...(0, _omitProps.omitProps)(props, Tray.allowedProps),
175
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.tray,
176
+ ref: contentRef,
177
+ children: (0, _jsxRuntime.jsx)(_Dialog.Dialog, {
178
+ ref: this.dialogRef,
179
+ as: "div",
180
+ label: label,
181
+ defaultFocusElement: defaultFocusElement,
182
+ open: true,
183
+ shouldContainFocus: shouldContainFocus,
184
+ shouldReturnFocus: shouldReturnFocus,
185
+ shouldCloseOnDocumentClick: shouldCloseOnDocumentClick,
186
+ shouldCloseOnEscape: true,
187
+ liveRegion: liveRegion,
188
+ onDismiss: onDismiss,
189
+ role: role,
190
+ children: (0, _jsxRuntime.jsx)("div", {
191
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.content,
192
+ children: children
193
+ })
194
+ })
195
+ })
196
+ });
197
+ return (0, _jsxRuntime.jsx)(_Portal.Portal, {
198
+ open: portalIsOpen,
199
+ onOpen: this.handlePortalOpen,
200
+ insertAt: insertAt,
201
+ mountNode: mountNode,
202
+ "data-cid": "Tray",
203
+ children: enableMask ? (0, _jsxRuntime.jsx)(_v11_.Mask, {
204
+ placement: 'center',
205
+ fullscreen: true,
206
+ children: content
207
+ }) : content
208
+ });
209
+ }
210
+ }, _Tray.displayName = "Tray", _Tray.componentId = 'Tray', _Tray.allowedProps = _props.allowedProps, _Tray.defaultProps = {
211
+ defaultFocusElement: null,
212
+ open: false,
213
+ insertAt: 'bottom',
214
+ shouldCloseOnDocumentClick: false,
215
+ shouldContainFocus: true,
216
+ shouldReturnFocus: true,
217
+ size: 'small',
218
+ placement: 'start',
219
+ transitionOnMount: true,
220
+ transitionEnter: true,
221
+ transitionExit: true,
222
+ shadow: true,
223
+ border: false,
224
+ enableMask: false
225
+ }, _Tray)) || _class) || _class);
226
+ var _default = exports.default = Tray;
@@ -16,9 +16,8 @@ var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHor
16
16
  var _Transition = require("@instructure/ui-motion/lib/Transition");
17
17
  var _emotion = require("@instructure/emotion");
18
18
  var _styles = _interopRequireDefault(require("./styles"));
19
- var _theme = _interopRequireDefault(require("./theme"));
20
19
  var _props = require("./props");
21
- var _Mask = require("@instructure/ui-overlays/lib/Mask");
20
+ var _latest = require("@instructure/ui-overlays/latest");
22
21
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
22
  const _excluded = ["label", "children", "size", "placement", "open", "defaultFocusElement", "contentRef", "shouldContainFocus", "shouldReturnFocus", "shouldCloseOnDocumentClick", "onOpen", "onClose", "onDismiss", "mountNode", "insertAt", "liveRegion", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "onTransition", "transitionOnMount", "transitionEnter", "transitionExit", "border", "shadow", "role", "enableMask"];
24
23
  var _dec, _dec2, _class, _Tray;
@@ -50,7 +49,7 @@ var _dec, _dec2, _class, _Tray;
50
49
  category: components
51
50
  ---
52
51
  **/
53
- let Tray = exports.Tray = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = (_Tray = class Tray extends _react.Component {
52
+ let Tray = exports.Tray = (_dec = (0, _emotion.withStyle)(_styles.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = (_Tray = class Tray extends _react.Component {
54
53
  constructor(props) {
55
54
  var _props$open;
56
55
  super(props);
@@ -200,7 +199,7 @@ let Tray = exports.Tray = (_dec = (0, _emotion.withStyle)(_styles.default, _them
200
199
  insertAt: insertAt,
201
200
  mountNode: mountNode,
202
201
  "data-cid": "Tray",
203
- children: enableMask ? (0, _jsxRuntime.jsx)(_Mask.Mask, {
202
+ children: enableMask ? (0, _jsxRuntime.jsx)(_latest.Mask, {
204
203
  placement: 'center',
205
204
  fullscreen: true,
206
205
  children: content
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['label', 'children', 'size', 'placement', 'open', 'defaultFocusElement', 'contentRef', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'onOpen', 'onClose', 'onDismiss', 'mountNode', 'insertAt', 'liveRegion', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'transitionOnMount', 'transitionEnter', 'transitionExit', 'border', 'shadow', 'enableMask'];