@instructure/ui-drawer-layout 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-drawer-layout
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-drawer-layout
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['label', 'children', 'contentRef', 'onSizeChange', 'role'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-drawer-layout",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A main-content-plus-tray layout component",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,28 +15,28 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.6.0",
19
- "@instructure/debounce": "11.6.0",
20
- "@instructure/emotion": "11.6.0",
21
- "@instructure/shared-types": "11.6.0",
22
- "@instructure/ui-dialog": "11.6.0",
23
- "@instructure/ui-i18n": "11.6.0",
24
- "@instructure/ui-dom-utils": "11.6.0",
25
- "@instructure/ui-motion": "11.6.0",
26
- "@instructure/ui-react-utils": "11.6.0",
27
- "@instructure/ui-portal": "11.6.0",
28
- "@instructure/ui-view": "11.6.0",
29
- "@instructure/ui-position": "11.6.0",
30
- "@instructure/ui-utils": "11.6.0",
31
- "@instructure/uid": "11.6.0"
18
+ "@instructure/debounce": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-dialog": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-i18n": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-motion": "11.6.1-pr-snapshot-1779894247159",
26
+ "@instructure/ui-position": "11.6.1-pr-snapshot-1779894247159",
27
+ "@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
28
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
29
+ "@instructure/ui-view": "11.6.1-pr-snapshot-1779894247159",
30
+ "@instructure/uid": "11.6.1-pr-snapshot-1779894247159",
31
+ "@instructure/ui-portal": "11.6.1-pr-snapshot-1779894247159"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@testing-library/jest-dom": "^6.6.3",
35
35
  "@testing-library/react": "15.0.7",
36
36
  "vitest": "^3.2.2",
37
- "@instructure/ui-babel-preset": "11.6.0",
38
- "@instructure/ui-buttons": "11.6.0",
39
- "@instructure/ui-themes": "11.6.0"
37
+ "@instructure/ui-buttons": "11.6.1-pr-snapshot-1779894247159",
38
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
39
+ "@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=18 <=19"
@@ -49,10 +49,8 @@
49
49
  ".": {
50
50
  "types": "./types/index.d.ts",
51
51
  "import": "./es/index.js",
52
- "require": "./lib/index.js",
53
52
  "default": "./es/index.js"
54
53
  },
55
- "./lib/*": "./lib/*",
56
54
  "./es/*": "./es/*",
57
55
  "./types/*": "./types/*",
58
56
  "./package.json": "./package.json",
@@ -62,7 +60,7 @@
62
60
  "lint": "ui-scripts lint",
63
61
  "lint:fix": "ui-scripts lint --fix",
64
62
  "clean": "ui-scripts clean",
65
- "build": "ui-scripts build --modules es,cjs",
63
+ "build": "ui-scripts build",
66
64
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
67
65
  "build:types": "tsc -p tsconfig.build.json",
68
66
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,130 +0,0 @@
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.DrawerContent = void 0;
8
- var _react = require("react");
9
- var _debounce = require("@instructure/debounce");
10
- var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
11
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
- var _emotion = require("@instructure/emotion");
13
- var _styles = _interopRequireDefault(require("./styles"));
14
- var _theme = _interopRequireDefault(require("./theme"));
15
- var _props = require("./props");
16
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
- var _dec, _class, _DrawerContent;
18
- /*
19
- * The MIT License (MIT)
20
- *
21
- * Copyright (c) 2015 - present Instructure, Inc.
22
- *
23
- * Permission is hereby granted, free of charge, to any person obtaining a copy
24
- * of this software and associated documentation files (the "Software"), to deal
25
- * in the Software without restriction, including without limitation the rights
26
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
- * copies of the Software, and to permit persons to whom the Software is
28
- * furnished to do so, subject to the following conditions:
29
- *
30
- * The above copyright notice and this permission notice shall be included in all
31
- * copies or substantial portions of the Software.
32
- *
33
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
- * SOFTWARE.
40
- */
41
- /**
42
- ---
43
- parent: DrawerLayout
44
- id: DrawerLayout.Content
45
- ---
46
- **/
47
- let DrawerContent = exports.DrawerContent = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_DrawerContent = class DrawerContent extends _react.Component {
48
- constructor(...args) {
49
- super(...args);
50
- this.ref = null;
51
- this._resizeListener = void 0;
52
- this._debounced = void 0;
53
- this.makeStyleProps = shouldTransition => {
54
- return {
55
- shouldTransition
56
- };
57
- };
58
- this.handleContentRef = node => {
59
- this.ref = node;
60
- if (typeof this.props.contentRef === 'function') {
61
- this.props.contentRef(node);
62
- }
63
- };
64
- }
65
- get _content() {
66
- return this.ref;
67
- }
68
- componentDidMount() {
69
- var _this$props$makeStyle, _this$props;
70
- const rect = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref);
71
- const origSize = {
72
- width: rect.width
73
- };
74
- // set initial size
75
- if (typeof this.props.onSizeChange === 'function') {
76
- this.props.onSizeChange({
77
- width: rect.width,
78
- height: rect.height
79
- });
80
-
81
- // listen for changes to size
82
- this._debounced = (0, _debounce.debounce)(this.props.onSizeChange, 100, {
83
- leading: false,
84
- trailing: true
85
- });
86
- }
87
- this._resizeListener = new ResizeObserver(entries => {
88
- for (const entry of entries) {
89
- const size = {
90
- width: entry.contentRect.width
91
- };
92
- if (size.width !== origSize.width) {
93
- var _this$_debounced;
94
- (_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this, size);
95
- }
96
- }
97
- });
98
- this._resizeListener.observe(this.ref);
99
- (_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));
100
- }
101
- componentDidUpdate() {
102
- var _this$props$makeStyle2, _this$props2;
103
- (_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));
104
- }
105
- componentWillUnmount() {
106
- var _this$_resizeListener, _this$_debounced2;
107
- (_this$_resizeListener = this._resizeListener) === null || _this$_resizeListener === void 0 ? void 0 : _this$_resizeListener.disconnect();
108
- (_this$_debounced2 = this._debounced) === null || _this$_debounced2 === void 0 ? void 0 : _this$_debounced2.cancel();
109
- }
110
- render() {
111
- var _this$props$styles;
112
- const _this$props3 = this.props,
113
- style = _this$props3.style,
114
- label = _this$props3.label,
115
- role = _this$props3.role;
116
- return (0, _jsxRuntime.jsx)("div", {
117
- ...(0, _omitProps.omitProps)(this.props, DrawerContent.allowedProps),
118
- role: role,
119
- style: style,
120
- ref: this.handleContentRef,
121
- "aria-label": label,
122
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerContent,
123
- "data-cid": "DrawerContent",
124
- children: this.props.children
125
- });
126
- }
127
- }, _DrawerContent.displayName = "DrawerContent", _DrawerContent.componentId = 'DrawerLayout.Content', _DrawerContent.locatorAttribute = 'data-drawer-content', _DrawerContent.allowedProps = _props.allowedProps, _DrawerContent.defaultProps = {
128
- role: 'region'
129
- }, _DrawerContent)) || _class);
130
- var _default = exports.default = DrawerContent;
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, _props, state) => {
42
- const shouldTransition = state.shouldTransition;
43
- const transitionState = shouldTransition ? {
44
- transition: `margin ${componentTheme.duration}`
45
- } : {};
46
- return {
47
- drawerContent: {
48
- label: 'drawerLayout__content',
49
- overflowY: componentTheme.overflowY,
50
- height: '100%',
51
- boxSizing: 'content-box',
52
- ...transitionState
53
- }
54
- };
55
- };
56
- var _default = exports.default = generateStyle;
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- const transitions = theme.transitions;
38
- return {
39
- duration: transitions === null || transitions === void 0 ? void 0 : transitions.duration,
40
- overflowY: 'auto'
41
- };
42
- };
43
- var _default = exports.default = generateComponentTheme;
@@ -1,233 +0,0 @@
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.DrawerTray = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = require("react");
10
- var _emotion = require("@instructure/emotion");
11
- var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
12
- var _Transition = require("@instructure/ui-motion/lib/Transition");
13
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
14
- var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
15
- var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
16
- var _Portal = require("@instructure/ui-portal/lib/Portal");
17
- var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHorizontalPlacement.js");
18
- var _styles = _interopRequireDefault(require("./styles"));
19
- var _theme = _interopRequireDefault(require("./theme"));
20
- var _index = require("../index");
21
- var _props = require("./props");
22
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
- const _excluded = ["label", "children", "render", "placement", "open", "onOpen", "onClose", "border", "shadow", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "contentRef", "mountNode", "defaultFocusElement", "liveRegion", "onDismiss", "onTransition", "shouldReturnFocus", "shouldCloseOnEscape", "shouldCloseOnDocumentClick", "shouldContainFocus", "styles"];
24
- var _dec, _dec2, _class, _DrawerTray;
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
- parent: DrawerLayout
51
- id: DrawerLayout.Tray
52
- ---
53
- **/
54
- let DrawerTray = exports.DrawerTray = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = (_DrawerTray = class DrawerTray extends _react.Component {
55
- get _content() {
56
- return this.ref;
57
- }
58
- constructor(props) {
59
- super(props);
60
- this.ref = null;
61
- this._DOMNode = null;
62
- this.makeStyleProps = () => {
63
- return {
64
- placement: this.placement
65
- };
66
- };
67
- this.handleContentRef = node => {
68
- this.ref = node;
69
- if (typeof this.props.contentRef === 'function') {
70
- this.props.contentRef(node);
71
- }
72
- };
73
- this.handleTransitionEntered = _transitionType => {
74
- this.setState({
75
- transitioning: false
76
- });
77
- };
78
- this.handleTransitionExited = _transitionType => {
79
- this.setState({
80
- transitioning: false
81
- });
82
- };
83
- this.handlePortalOpen = DOMNode => {
84
- this.DOMNode = DOMNode;
85
- this.setState({
86
- portalOpen: true
87
- });
88
- };
89
- this.state = {
90
- transitioning: false,
91
- portalOpen: false
92
- };
93
- }
94
- componentDidMount() {
95
- var _this$props$makeStyle, _this$props;
96
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
97
- }
98
- componentDidUpdate(prevProps) {
99
- var _this$props$makeStyle2, _this$props2;
100
- if (this.props.open !== prevProps.open) {
101
- this.setState({
102
- transitioning: true
103
- });
104
- }
105
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
106
- }
107
- get placement() {
108
- const _this$props3 = this.props,
109
- placement = _this$props3.placement,
110
- dir = _this$props3.dir;
111
- const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
112
- return isRtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement;
113
- }
114
- get transition() {
115
- return this.placement === 'end' ? 'fade' : 'slide-left';
116
- }
117
- get DOMNode() {
118
- return this._DOMNode;
119
- }
120
- set DOMNode(el) {
121
- this._DOMNode = el;
122
- }
123
- renderContent() {
124
- const _this$props4 = this.props,
125
- children = _this$props4.children,
126
- render = _this$props4.render;
127
- if (typeof render === 'function') {
128
- return render();
129
- } else if (typeof children === 'function') {
130
- return children();
131
- } else {
132
- return children;
133
- }
134
- }
135
- render() {
136
- const _this$props5 = this.props,
137
- label = _this$props5.label,
138
- children = _this$props5.children,
139
- render = _this$props5.render,
140
- placement = _this$props5.placement,
141
- open = _this$props5.open,
142
- onOpen = _this$props5.onOpen,
143
- onClose = _this$props5.onClose,
144
- border = _this$props5.border,
145
- shadow = _this$props5.shadow,
146
- onEnter = _this$props5.onEnter,
147
- onEntering = _this$props5.onEntering,
148
- onEntered = _this$props5.onEntered,
149
- onExit = _this$props5.onExit,
150
- onExiting = _this$props5.onExiting,
151
- onExited = _this$props5.onExited,
152
- contentRef = _this$props5.contentRef,
153
- mountNode = _this$props5.mountNode,
154
- defaultFocusElement = _this$props5.defaultFocusElement,
155
- liveRegion = _this$props5.liveRegion,
156
- onDismiss = _this$props5.onDismiss,
157
- onTransition = _this$props5.onTransition,
158
- shouldReturnFocus = _this$props5.shouldReturnFocus,
159
- shouldCloseOnEscape = _this$props5.shouldCloseOnEscape,
160
- shouldCloseOnDocumentClick = _this$props5.shouldCloseOnDocumentClick,
161
- shouldContainFocus = _this$props5.shouldContainFocus,
162
- styles = _this$props5.styles,
163
- props = (0, _objectWithoutProperties2.default)(_this$props5, _excluded);
164
- return (0, _jsxRuntime.jsx)(_index.DrawerLayoutContext.Consumer, {
165
- children: shouldOverlayTray => {
166
- var _this$props$styles;
167
- const portalOpen = this.state.portalOpen;
168
- const needsPortal = shouldOverlayTray && !!mountNode;
169
- // we have to handle the shadow version here,
170
- // because passing and handling it in styles.js makes it
171
- // rerender the component during the transition, breaking it
172
- const trayStyles = shadow && shouldOverlayTray ? styles === null || styles === void 0 ? void 0 : styles.drawerTrayWithShadow : styles === null || styles === void 0 ? void 0 : styles.drawerTray;
173
- let transitionIn = open;
174
- if (needsPortal && !portalOpen) {
175
- transitionIn = false;
176
- }
177
- const content = (0, _jsxRuntime.jsx)(_Transition.Transition, {
178
- in: transitionIn,
179
- type: this.transition,
180
- onTransition: onTransition,
181
- onEnter: onEnter,
182
- onEntering: onEntering,
183
- onEntered: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionEntered, onEntered, onOpen),
184
- onExit: onExit,
185
- onExiting: onExiting,
186
- onExited: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionExited, onExited, onClose),
187
- unmountOnExit: true,
188
- children: (0, _jsxRuntime.jsx)("div", {
189
- ...(0, _omitProps.omitProps)(props, DrawerTray.allowedProps),
190
- ref: this.handleContentRef,
191
- css: trayStyles,
192
- "data-cid": "DrawerTray",
193
- children: (0, _jsxRuntime.jsx)(_Dialog.Dialog, {
194
- open: true,
195
- role: shouldOverlayTray ? 'dialog' : 'region',
196
- label: label,
197
- shouldReturnFocus: shouldReturnFocus,
198
- shouldContainFocus: !this.state.transitioning && shouldContainFocus && shouldOverlayTray,
199
- shouldCloseOnDocumentClick: shouldCloseOnDocumentClick && shouldOverlayTray,
200
- shouldCloseOnEscape: shouldCloseOnEscape && shouldOverlayTray,
201
- defaultFocusElement: defaultFocusElement,
202
- liveRegion: liveRegion,
203
- onDismiss: onDismiss,
204
- as: "div",
205
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerTrayContent,
206
- children: this.renderContent()
207
- })
208
- })
209
- });
210
- if (needsPortal) {
211
- return (0, _jsxRuntime.jsx)(_Portal.Portal, {
212
- mountNode: mountNode,
213
- open: true,
214
- onOpen: this.handlePortalOpen,
215
- children: content
216
- });
217
- } else {
218
- return content;
219
- }
220
- }
221
- });
222
- }
223
- }, _DrawerTray.displayName = "DrawerTray", _DrawerTray.componentId = 'DrawerLayout.Tray', _DrawerTray.locatorAttribute = 'data-drawer-tray', _DrawerTray.allowedProps = _props.allowedProps, _DrawerTray.defaultProps = {
224
- shouldContainFocus: true,
225
- shouldCloseOnEscape: true,
226
- shouldCloseOnDocumentClick: true,
227
- shouldReturnFocus: true,
228
- open: false,
229
- shadow: true,
230
- border: true,
231
- placement: 'start'
232
- }, _DrawerTray)) || _class) || _class);
233
- var _default = exports.default = DrawerTray;
@@ -1,31 +0,0 @@
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', 'render', 'placement', 'open', 'onOpen', 'onClose', 'border', 'shadow', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'contentRef', 'mountNode', 'defaultFocusElement', 'liveRegion', 'onDismiss', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'shouldCloseOnEscape', 'dir'];
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props, state) => {
42
- const border = props.border;
43
- const placement = state.placement;
44
- const borderPlacementStyle = {
45
- start: {
46
- borderRightWidth: componentTheme.borderWidth
47
- },
48
- end: {
49
- borderLeftWidth: componentTheme.borderWidth
50
- }
51
- };
52
- const borderStyles = border ? {
53
- borderWidth: 0,
54
- borderColor: componentTheme.borderColor,
55
- borderStyle: componentTheme.borderStyle,
56
- boxSizing: 'border-box',
57
- ...borderPlacementStyle[placement]
58
- } : {
59
- boxSizing: 'content-box'
60
- };
61
- const placementStyleMap = {
62
- start: {
63
- left: 0
64
- },
65
- end: {
66
- right: 0
67
- }
68
- };
69
- const trayStyle = {
70
- position: 'absolute',
71
- backgroundColor: componentTheme.background,
72
- zIndex: componentTheme.zIndex,
73
- overflowY: componentTheme.overflowY,
74
- overflowX: componentTheme.overflowX,
75
- ...borderStyles,
76
- top: 0,
77
- bottom: 0,
78
- ...placementStyleMap[placement]
79
- };
80
- return {
81
- drawerTray: {
82
- label: 'drawerTray',
83
- ...trayStyle
84
- },
85
- drawerTrayWithShadow: {
86
- label: 'drawerTray--with-shadow',
87
- ...trayStyle,
88
- boxShadow: componentTheme.boxShadow,
89
- border: 0
90
- },
91
- drawerTrayContent: {
92
- label: 'drawerTray__content',
93
- overflowY: componentTheme.contentOverflowY,
94
- height: '100%',
95
- boxSizing: 'content-box'
96
- }
97
- };
98
- };
99
- var _default = exports.default = generateStyle;
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- var _colors$contrasts, _colors$contrasts2;
38
- const colors = theme.colors,
39
- borders = theme.borders,
40
- stacking = theme.stacking,
41
- shadows = theme.shadows;
42
- const componentVariables = {
43
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.white1010,
44
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey3045,
45
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
46
- borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
47
- zIndex: stacking === null || stacking === void 0 ? void 0 : stacking.topmost,
48
- boxShadow: shadows === null || shadows === void 0 ? void 0 : shadows.depth3,
49
- overflowX: 'hidden',
50
- overflowY: 'auto',
51
- contentOverflowY: 'auto'
52
- };
53
- return {
54
- ...componentVariables
55
- };
56
- };
57
- var _default = exports.default = generateComponentTheme;
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _index = require("../index");
9
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- var _DrawerLayout$Content;
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
- class DrawerLayoutFixture extends _react.Component {
35
- render() {
36
- const _this$props = this.props,
37
- layoutWidth = _this$props.layoutWidth,
38
- trayWidth = _this$props.trayWidth,
39
- open = _this$props.open,
40
- placement = _this$props.placement,
41
- onOverlayTrayChange = _this$props.onOverlayTrayChange;
42
- return (0, _jsxRuntime.jsx)("div", {
43
- style: {
44
- width: layoutWidth
45
- },
46
- children: (0, _jsxRuntime.jsxs)(_index.DrawerLayout, {
47
- minWidth: "500px",
48
- onOverlayTrayChange: onOverlayTrayChange,
49
- children: [(0, _jsxRuntime.jsx)(_index.DrawerLayout.Tray, {
50
- open: open,
51
- placement: placement,
52
- label: "Test DrawerTray",
53
- children: (0, _jsxRuntime.jsx)("div", {
54
- style: {
55
- width: trayWidth
56
- },
57
- children: "Hello from tray"
58
- })
59
- }), _DrawerLayout$Content || (_DrawerLayout$Content = (0, _jsxRuntime.jsx)(_index.DrawerLayout.Content, {
60
- label: "Test DrawerContent",
61
- children: (0, _jsxRuntime.jsxs)("div", {
62
- children: ["Hello from content", (0, _jsxRuntime.jsx)("button", {
63
- children: "Expand"
64
- })]
65
- })
66
- }))]
67
- })
68
- });
69
- }
70
- }
71
- exports.default = DrawerLayoutFixture;
72
- DrawerLayoutFixture.displayName = "DrawerLayoutFixture";
73
- DrawerLayoutFixture.defaultProps = {
74
- layoutWidth: '600px',
75
- trayWidth: '200px',
76
- open: false,
77
- placement: 'start',
78
- onOverlayTrayChange: () => {}
79
- };
@@ -1,245 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "DrawerContent", {
8
- enumerable: true,
9
- get: function () {
10
- return _DrawerContent.DrawerContent;
11
- }
12
- });
13
- exports.DrawerLayoutContext = exports.DrawerLayout = void 0;
14
- Object.defineProperty(exports, "DrawerTray", {
15
- enumerable: true,
16
- get: function () {
17
- return _DrawerTray.DrawerTray;
18
- }
19
- });
20
- exports.default = void 0;
21
- var _react = require("react");
22
- var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
23
- var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
24
- var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
25
- var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
26
- var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
27
- var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
28
- var _px = require("@instructure/ui-utils/lib/px.js");
29
- var _console = require("@instructure/console");
30
- var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHorizontalPlacement.js");
31
- var _DrawerContent = require("./DrawerContent");
32
- var _DrawerTray = require("./DrawerTray");
33
- var _emotion = require("@instructure/emotion");
34
- var _styles = _interopRequireDefault(require("./styles"));
35
- var _props2 = require("./props");
36
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
37
- var _dec, _dec2, _dec3, _class, _DrawerLayout;
38
- /*
39
- * The MIT License (MIT)
40
- *
41
- * Copyright (c) 2015 - present Instructure, Inc.
42
- *
43
- * Permission is hereby granted, free of charge, to any person obtaining a copy
44
- * of this software and associated documentation files (the "Software"), to deal
45
- * in the Software without restriction, including without limitation the rights
46
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
47
- * copies of the Software, and to permit persons to whom the Software is
48
- * furnished to do so, subject to the following conditions:
49
- *
50
- * The above copyright notice and this permission notice shall be included in all
51
- * copies or substantial portions of the Software.
52
- *
53
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
56
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59
- * SOFTWARE.
60
- */
61
- /**
62
- ---
63
- category: components
64
- ---
65
- **/
66
- let DrawerLayout = exports.DrawerLayout = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, null), _dec3 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = _dec3(_class = (_DrawerLayout = class DrawerLayout extends _react.Component {
67
- constructor(_props) {
68
- super(_props);
69
- this._id = void 0;
70
- this._content = null;
71
- this._tray = null;
72
- this.ref = null;
73
- this.handleRef = el => {
74
- this.ref = el;
75
- };
76
- this.handleTrayContentRef = el => {
77
- this._tray = el;
78
- };
79
- this.handleContentSizeChange = ({
80
- width
81
- }) => {
82
- this.setState((state, props) => {
83
- const nextState = this.getNextState(props.minWidth, state.trayWidth, width, state.shouldOverlayTray);
84
- if (state.shouldOverlayTray !== nextState.shouldOverlayTray) {
85
- this.notifyOverlayTrayChange(nextState.shouldOverlayTray);
86
- }
87
- return nextState;
88
- });
89
- };
90
- this.handleTraySizeChange = ({
91
- width
92
- }) => {
93
- this.setState((state, props) => {
94
- const nextState = this.getNextState(props.minWidth, width, state.contentWidth, true);
95
- if (state.shouldOverlayTray !== nextState.shouldOverlayTray) {
96
- this.notifyOverlayTrayChange(nextState.shouldOverlayTray);
97
- }
98
- return nextState;
99
- });
100
- };
101
- this.handleTrayTransitionEnter = () => {
102
- let width = 0;
103
- if (this._tray) {
104
- width = (0, _getBoundingClientRect.getBoundingClientRect)(this._tray).width;
105
- }
106
- this.handleTraySizeChange({
107
- width
108
- });
109
- };
110
- this.handleTrayTransitionExit = () => {
111
- this.handleTraySizeChange({
112
- width: 0
113
- });
114
- };
115
- this.state = {
116
- shouldOverlayTray: false,
117
- trayWidth: 0,
118
- contentWidth: 0
119
- };
120
- this._id = _props.deterministicId();
121
- }
122
- componentDidMount() {
123
- var _this$props$makeStyle, _this$props;
124
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
125
- }
126
- componentDidUpdate() {
127
- var _this$props$makeStyle2, _this$props2;
128
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
129
- }
130
- get trayProps() {
131
- const tray = _react.Children.toArray(this.props.children).filter(child => (0, _matchComponentTypes.matchComponentTypes)(child, [_DrawerTray.DrawerTray]))[0];
132
- return tray.props;
133
- }
134
- get trayPlacement() {
135
- const _this$trayProps = this.trayProps,
136
- placement = _this$trayProps.placement,
137
- _this$trayProps$dir = _this$trayProps.dir,
138
- dir = _this$trayProps$dir === void 0 ? this.props.dir : _this$trayProps$dir;
139
- const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
140
- return isRtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement;
141
- }
142
- get contentMargin() {
143
- const trayWidth = this.state.trayWidth || 0;
144
- return this.state.shouldOverlayTray ? 0 : trayWidth;
145
- }
146
- get contentStyle() {
147
- const shouldOverlayTray = this.shouldOverlayTray(this.props.minWidth, this.state.trayWidth, this.state.contentWidth, this.state.shouldOverlayTray);
148
- let marginLeft = 0;
149
- let marginRight = 0;
150
- if (!shouldOverlayTray) {
151
- if (this.trayPlacement === 'start') {
152
- marginLeft = this.contentMargin;
153
- }
154
- if (this.trayPlacement === 'end') {
155
- marginRight = this.contentMargin;
156
- }
157
- }
158
- return {
159
- marginLeft: `${marginLeft}px`,
160
- marginRight: `${marginRight}px`
161
- };
162
- }
163
- shouldOverlayTray(minWidth, trayWidth, contentWidth, trayIsOverlayed) {
164
- if (!this._content) return false;
165
- const minWidthPx = (0, _px.px)(minWidth, this._content);
166
- if (trayIsOverlayed) {
167
- return contentWidth - trayWidth < minWidthPx;
168
- } else {
169
- return contentWidth < minWidthPx;
170
- }
171
- }
172
- getNextState(minWidth, trayWidth, contentWidth, trayIsOverlayed) {
173
- const shouldOverlayTray = this.shouldOverlayTray(minWidth, trayWidth, contentWidth, trayIsOverlayed);
174
- return {
175
- trayWidth,
176
- contentWidth,
177
- shouldOverlayTray
178
- };
179
- }
180
- notifyOverlayTrayChange(shouldOverlayTray) {
181
- const onOverlayTrayChange = this.props.onOverlayTrayChange;
182
- if (typeof onOverlayTrayChange === 'function') {
183
- onOverlayTrayChange(shouldOverlayTray);
184
- }
185
- }
186
- renderChildren() {
187
- let trayCount = 0;
188
- let contentCount = 0;
189
- const children = _react.Children.map(this.props.children, (child, _index) => {
190
- if ((0, _matchComponentTypes.matchComponentTypes)(child, [_DrawerTray.DrawerTray])) {
191
- trayCount++;
192
- return (0, _safeCloneElement.safeCloneElement)(child, {
193
- label: child.props.label,
194
- key: child.props.label,
195
- [_DrawerTray.DrawerTray.locatorAttribute]: this._id,
196
- contentRef: this.handleTrayContentRef,
197
- onEnter: this.handleTrayTransitionEnter,
198
- onExit: this.handleTrayTransitionExit
199
- });
200
- } else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_DrawerContent.DrawerContent])) {
201
- contentCount++;
202
- const handleContentRef = el => {
203
- const contentRef = child.props.contentRef;
204
- this._content = el;
205
- if (typeof contentRef === 'function') {
206
- contentRef(el);
207
- }
208
- };
209
- return this.state.trayWidth !== null ? (0, _safeCloneElement.safeCloneElement)(child, {
210
- label: child.props.label,
211
- key: child.props.label,
212
- [_DrawerContent.DrawerContent.locatorAttribute]: this._id,
213
- style: this.contentStyle,
214
- onSizeChange: (0, _createChainedFunction.createChainedFunction)(this.handleContentSizeChange, child.props.onSizeChange),
215
- contentRef: handleContentRef
216
- }) : null;
217
- } else {
218
- return child;
219
- }
220
- });
221
- (0, _console.logError)(trayCount <= 1, `[DrawerLayout] Only one 'DrawerTray' per 'DrawerLayout' is supported.`);
222
- (0, _console.logError)(contentCount <= 1, `[DrawerLayout] Only one 'DrawerContent' per 'DrawerLayout' is supported.`);
223
- return children;
224
- }
225
- render() {
226
- var _this$props$styles;
227
- const props = {
228
- [DrawerLayout.locatorAttribute]: this._id
229
- };
230
- return (0, _jsxRuntime.jsx)(DrawerLayoutContext.Provider, {
231
- value: this.state.shouldOverlayTray,
232
- children: (0, _jsxRuntime.jsx)("div", {
233
- ...props,
234
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerLayout,
235
- ref: this.handleRef,
236
- "data-cid": "DrawerLayout",
237
- children: this.renderChildren()
238
- })
239
- });
240
- }
241
- }, _DrawerLayout.displayName = "DrawerLayout", _DrawerLayout.componentId = 'DrawerLayout', _DrawerLayout.locatorAttribute = 'data-drawer-layout', _DrawerLayout.allowedProps = _props2.allowedProps, _DrawerLayout.defaultProps = {
242
- minWidth: '30rem'
243
- }, _DrawerLayout.Content = _DrawerContent.DrawerContent, _DrawerLayout.Tray = _DrawerTray.DrawerTray, _DrawerLayout)) || _class) || _class) || _class);
244
- var _default = exports.default = DrawerLayout;
245
- const DrawerLayoutContext = exports.DrawerLayoutContext = /*#__PURE__*/(0, _react.createContext)(false);
@@ -1,31 +0,0 @@
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 = ['children', 'minWidth', 'onOverlayTrayChange', 'dir'];
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = () => {
42
- return {
43
- drawerLayout: {
44
- label: 'drawerLayout',
45
- position: 'relative',
46
- height: '100%'
47
- }
48
- };
49
- };
50
- var _default = exports.default = generateStyle;
package/lib/index.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "DrawerContent", {
7
- enumerable: true,
8
- get: function () {
9
- return _DrawerLayout.DrawerContent;
10
- }
11
- });
12
- Object.defineProperty(exports, "DrawerLayout", {
13
- enumerable: true,
14
- get: function () {
15
- return _DrawerLayout.DrawerLayout;
16
- }
17
- });
18
- Object.defineProperty(exports, "DrawerTray", {
19
- enumerable: true,
20
- get: function () {
21
- return _DrawerLayout.DrawerTray;
22
- }
23
- });
24
- var _DrawerLayout = require("./DrawerLayout");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}