@instructure/ui-drawer-layout 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 (139) hide show
  1. package/CHANGELOG.md +36 -295
  2. package/es/DrawerLayout/{DrawerContent → v1/DrawerContent}/index.js +1 -1
  3. package/es/DrawerLayout/{DrawerTray → v1/DrawerTray}/index.js +1 -1
  4. package/es/DrawerLayout/{index.js → v1/index.js} +1 -1
  5. package/es/DrawerLayout/v2/DrawerContent/index.js +124 -0
  6. package/es/DrawerLayout/v2/DrawerContent/props.js +26 -0
  7. package/es/DrawerLayout/v2/DrawerContent/styles.js +51 -0
  8. package/es/DrawerLayout/v2/DrawerTray/index.js +227 -0
  9. package/es/DrawerLayout/v2/DrawerTray/props.js +26 -0
  10. package/es/DrawerLayout/v2/DrawerTray/styles.js +94 -0
  11. package/es/DrawerLayout/v2/__fixtures__/DrawerLayout.fixture.js +73 -0
  12. package/es/DrawerLayout/v2/index.js +224 -0
  13. package/es/DrawerLayout/v2/props.js +26 -0
  14. package/es/DrawerLayout/v2/styles.js +44 -0
  15. package/es/{index.js → exports/a.js} +1 -1
  16. package/es/exports/b.js +24 -0
  17. package/lib/DrawerLayout/{DrawerContent → v1/DrawerContent}/index.js +1 -1
  18. package/lib/DrawerLayout/{DrawerTray → v1/DrawerTray}/index.js +1 -1
  19. package/lib/DrawerLayout/v1/index.js +245 -0
  20. package/lib/DrawerLayout/v2/DrawerContent/index.js +129 -0
  21. package/lib/DrawerLayout/v2/DrawerContent/props.js +31 -0
  22. package/lib/DrawerLayout/v2/DrawerContent/styles.js +57 -0
  23. package/lib/DrawerLayout/v2/DrawerTray/index.js +232 -0
  24. package/lib/DrawerLayout/v2/DrawerTray/props.js +31 -0
  25. package/lib/DrawerLayout/v2/DrawerTray/styles.js +100 -0
  26. package/lib/DrawerLayout/v2/__fixtures__/DrawerLayout.fixture.js +79 -0
  27. package/lib/DrawerLayout/{index.js → v2/index.js} +1 -1
  28. package/lib/DrawerLayout/v2/props.js +31 -0
  29. package/lib/DrawerLayout/v2/styles.js +50 -0
  30. package/lib/{index.js → exports/a.js} +4 -4
  31. package/lib/exports/b.js +24 -0
  32. package/package.json +47 -25
  33. package/src/DrawerLayout/{DrawerContent → v1/DrawerContent}/index.tsx +1 -1
  34. package/src/DrawerLayout/{DrawerTray → v1/DrawerTray}/index.tsx +1 -1
  35. package/src/DrawerLayout/v1/index.tsx +334 -0
  36. package/src/DrawerLayout/v2/DrawerContent/index.tsx +147 -0
  37. package/src/DrawerLayout/v2/DrawerContent/props.ts +73 -0
  38. package/src/DrawerLayout/v2/DrawerContent/styles.ts +68 -0
  39. package/src/DrawerLayout/v2/DrawerTray/index.tsx +288 -0
  40. package/src/DrawerLayout/v2/DrawerTray/props.ts +228 -0
  41. package/src/DrawerLayout/v2/DrawerTray/styles.ts +106 -0
  42. package/src/DrawerLayout/v2/README.md +231 -0
  43. package/src/DrawerLayout/v2/__fixtures__/DrawerLayout.fixture.tsx +75 -0
  44. package/src/DrawerLayout/{index.tsx → v2/index.tsx} +1 -1
  45. package/src/DrawerLayout/v2/props.ts +72 -0
  46. package/src/DrawerLayout/v2/styles.ts +47 -0
  47. package/src/{index.ts → exports/a.ts} +4 -4
  48. package/src/exports/b.ts +29 -0
  49. package/tsconfig.build.tsbuildinfo +1 -1
  50. package/types/DrawerLayout/v1/DrawerContent/index.d.ts.map +1 -0
  51. package/types/DrawerLayout/v1/DrawerContent/props.d.ts.map +1 -0
  52. package/types/DrawerLayout/v1/DrawerContent/styles.d.ts.map +1 -0
  53. package/types/DrawerLayout/v1/DrawerContent/theme.d.ts.map +1 -0
  54. package/types/DrawerLayout/v1/DrawerTray/index.d.ts.map +1 -0
  55. package/types/DrawerLayout/v1/DrawerTray/props.d.ts.map +1 -0
  56. package/types/DrawerLayout/v1/DrawerTray/styles.d.ts.map +1 -0
  57. package/types/DrawerLayout/v1/DrawerTray/theme.d.ts.map +1 -0
  58. package/types/DrawerLayout/v1/__fixtures__/DrawerLayout.fixture.d.ts.map +1 -0
  59. package/types/DrawerLayout/v1/index.d.ts.map +1 -0
  60. package/types/DrawerLayout/v1/props.d.ts.map +1 -0
  61. package/types/DrawerLayout/v1/styles.d.ts.map +1 -0
  62. package/types/DrawerLayout/v2/DrawerContent/index.d.ts +35 -0
  63. package/types/DrawerLayout/v2/DrawerContent/index.d.ts.map +1 -0
  64. package/types/DrawerLayout/v2/DrawerContent/props.d.ts +28 -0
  65. package/types/DrawerLayout/v2/DrawerContent/props.d.ts.map +1 -0
  66. package/types/DrawerLayout/v2/DrawerContent/styles.d.ts +16 -0
  67. package/types/DrawerLayout/v2/DrawerContent/styles.d.ts.map +1 -0
  68. package/types/DrawerLayout/v2/DrawerTray/index.d.ts +61 -0
  69. package/types/DrawerLayout/v2/DrawerTray/index.d.ts.map +1 -0
  70. package/types/DrawerLayout/v2/DrawerTray/props.d.ts +120 -0
  71. package/types/DrawerLayout/v2/DrawerTray/props.d.ts.map +1 -0
  72. package/types/DrawerLayout/v2/DrawerTray/styles.d.ts +16 -0
  73. package/types/DrawerLayout/v2/DrawerTray/styles.d.ts.map +1 -0
  74. package/types/DrawerLayout/v2/__fixtures__/DrawerLayout.fixture.d.ts +22 -0
  75. package/types/DrawerLayout/v2/__fixtures__/DrawerLayout.fixture.d.ts.map +1 -0
  76. package/types/DrawerLayout/v2/index.d.ts +146 -0
  77. package/types/DrawerLayout/v2/index.d.ts.map +1 -0
  78. package/types/DrawerLayout/v2/props.d.ts +33 -0
  79. package/types/DrawerLayout/v2/props.d.ts.map +1 -0
  80. package/types/DrawerLayout/v2/styles.d.ts +14 -0
  81. package/types/DrawerLayout/v2/styles.d.ts.map +1 -0
  82. package/types/exports/a.d.ts +5 -0
  83. package/types/exports/a.d.ts.map +1 -0
  84. package/types/exports/b.d.ts +5 -0
  85. package/types/exports/b.d.ts.map +1 -0
  86. package/types/DrawerLayout/DrawerContent/index.d.ts.map +0 -1
  87. package/types/DrawerLayout/DrawerContent/props.d.ts.map +0 -1
  88. package/types/DrawerLayout/DrawerContent/styles.d.ts.map +0 -1
  89. package/types/DrawerLayout/DrawerContent/theme.d.ts.map +0 -1
  90. package/types/DrawerLayout/DrawerTray/index.d.ts.map +0 -1
  91. package/types/DrawerLayout/DrawerTray/props.d.ts.map +0 -1
  92. package/types/DrawerLayout/DrawerTray/styles.d.ts.map +0 -1
  93. package/types/DrawerLayout/DrawerTray/theme.d.ts.map +0 -1
  94. package/types/DrawerLayout/__fixtures__/DrawerLayout.fixture.d.ts.map +0 -1
  95. package/types/DrawerLayout/index.d.ts.map +0 -1
  96. package/types/DrawerLayout/props.d.ts.map +0 -1
  97. package/types/DrawerLayout/styles.d.ts.map +0 -1
  98. package/types/index.d.ts +0 -5
  99. package/types/index.d.ts.map +0 -1
  100. /package/es/DrawerLayout/{DrawerContent → v1/DrawerContent}/props.js +0 -0
  101. /package/es/DrawerLayout/{DrawerContent → v1/DrawerContent}/styles.js +0 -0
  102. /package/es/DrawerLayout/{DrawerContent → v1/DrawerContent}/theme.js +0 -0
  103. /package/es/DrawerLayout/{DrawerTray → v1/DrawerTray}/props.js +0 -0
  104. /package/es/DrawerLayout/{DrawerTray → v1/DrawerTray}/styles.js +0 -0
  105. /package/es/DrawerLayout/{DrawerTray → v1/DrawerTray}/theme.js +0 -0
  106. /package/es/DrawerLayout/{__fixtures__ → v1/__fixtures__}/DrawerLayout.fixture.js +0 -0
  107. /package/es/DrawerLayout/{props.js → v1/props.js} +0 -0
  108. /package/es/DrawerLayout/{styles.js → v1/styles.js} +0 -0
  109. /package/lib/DrawerLayout/{DrawerContent → v1/DrawerContent}/props.js +0 -0
  110. /package/lib/DrawerLayout/{DrawerContent → v1/DrawerContent}/styles.js +0 -0
  111. /package/lib/DrawerLayout/{DrawerContent → v1/DrawerContent}/theme.js +0 -0
  112. /package/lib/DrawerLayout/{DrawerTray → v1/DrawerTray}/props.js +0 -0
  113. /package/lib/DrawerLayout/{DrawerTray → v1/DrawerTray}/styles.js +0 -0
  114. /package/lib/DrawerLayout/{DrawerTray → v1/DrawerTray}/theme.js +0 -0
  115. /package/lib/DrawerLayout/{__fixtures__ → v1/__fixtures__}/DrawerLayout.fixture.js +0 -0
  116. /package/lib/DrawerLayout/{props.js → v1/props.js} +0 -0
  117. /package/lib/DrawerLayout/{styles.js → v1/styles.js} +0 -0
  118. /package/src/DrawerLayout/{DrawerContent → v1/DrawerContent}/props.ts +0 -0
  119. /package/src/DrawerLayout/{DrawerContent → v1/DrawerContent}/styles.ts +0 -0
  120. /package/src/DrawerLayout/{DrawerContent → v1/DrawerContent}/theme.ts +0 -0
  121. /package/src/DrawerLayout/{DrawerTray → v1/DrawerTray}/props.ts +0 -0
  122. /package/src/DrawerLayout/{DrawerTray → v1/DrawerTray}/styles.ts +0 -0
  123. /package/src/DrawerLayout/{DrawerTray → v1/DrawerTray}/theme.ts +0 -0
  124. /package/src/DrawerLayout/{README.md → v1/README.md} +0 -0
  125. /package/src/DrawerLayout/{__fixtures__ → v1/__fixtures__}/DrawerLayout.fixture.tsx +0 -0
  126. /package/src/DrawerLayout/{props.ts → v1/props.ts} +0 -0
  127. /package/src/DrawerLayout/{styles.ts → v1/styles.ts} +0 -0
  128. /package/types/DrawerLayout/{DrawerContent → v1/DrawerContent}/index.d.ts +0 -0
  129. /package/types/DrawerLayout/{DrawerContent → v1/DrawerContent}/props.d.ts +0 -0
  130. /package/types/DrawerLayout/{DrawerContent → v1/DrawerContent}/styles.d.ts +0 -0
  131. /package/types/DrawerLayout/{DrawerContent → v1/DrawerContent}/theme.d.ts +0 -0
  132. /package/types/DrawerLayout/{DrawerTray → v1/DrawerTray}/index.d.ts +0 -0
  133. /package/types/DrawerLayout/{DrawerTray → v1/DrawerTray}/props.d.ts +0 -0
  134. /package/types/DrawerLayout/{DrawerTray → v1/DrawerTray}/styles.d.ts +0 -0
  135. /package/types/DrawerLayout/{DrawerTray → v1/DrawerTray}/theme.d.ts +0 -0
  136. /package/types/DrawerLayout/{__fixtures__ → v1/__fixtures__}/DrawerLayout.fixture.d.ts +0 -0
  137. /package/types/DrawerLayout/{index.d.ts → v1/index.d.ts} +0 -0
  138. /package/types/DrawerLayout/{props.d.ts → v1/props.d.ts} +0 -0
  139. /package/types/DrawerLayout/{styles.d.ts → v1/styles.d.ts} +0 -0
@@ -0,0 +1,129 @@
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 _props = require("./props");
15
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
+ var _dec, _class, _DrawerContent;
17
+ /*
18
+ * The MIT License (MIT)
19
+ *
20
+ * Copyright (c) 2015 - present Instructure, Inc.
21
+ *
22
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ * of this software and associated documentation files (the "Software"), to deal
24
+ * in the Software without restriction, including without limitation the rights
25
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ * copies of the Software, and to permit persons to whom the Software is
27
+ * furnished to do so, subject to the following conditions:
28
+ *
29
+ * The above copyright notice and this permission notice shall be included in all
30
+ * copies or substantial portions of the Software.
31
+ *
32
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ * SOFTWARE.
39
+ */
40
+ /**
41
+ ---
42
+ parent: DrawerLayout
43
+ id: DrawerLayout.Content
44
+ ---
45
+ **/
46
+ let DrawerContent = exports.DrawerContent = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_DrawerContent = class DrawerContent extends _react.Component {
47
+ constructor(...args) {
48
+ super(...args);
49
+ this.ref = null;
50
+ this._resizeListener = void 0;
51
+ this._debounced = void 0;
52
+ this.makeStyleProps = shouldTransition => {
53
+ return {
54
+ shouldTransition
55
+ };
56
+ };
57
+ this.handleContentRef = node => {
58
+ this.ref = node;
59
+ if (typeof this.props.contentRef === 'function') {
60
+ this.props.contentRef(node);
61
+ }
62
+ };
63
+ }
64
+ get _content() {
65
+ return this.ref;
66
+ }
67
+ componentDidMount() {
68
+ var _this$props$makeStyle, _this$props;
69
+ const rect = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref);
70
+ const origSize = {
71
+ width: rect.width
72
+ };
73
+ // set initial size
74
+ if (typeof this.props.onSizeChange === 'function') {
75
+ this.props.onSizeChange({
76
+ width: rect.width,
77
+ height: rect.height
78
+ });
79
+
80
+ // listen for changes to size
81
+ this._debounced = (0, _debounce.debounce)(this.props.onSizeChange, 100, {
82
+ leading: false,
83
+ trailing: true
84
+ });
85
+ }
86
+ this._resizeListener = new ResizeObserver(entries => {
87
+ for (const entry of entries) {
88
+ const size = {
89
+ width: entry.contentRect.width
90
+ };
91
+ if (size.width !== origSize.width) {
92
+ var _this$_debounced;
93
+ (_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this, size);
94
+ }
95
+ }
96
+ });
97
+ this._resizeListener.observe(this.ref);
98
+ (_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
+ }
100
+ componentDidUpdate() {
101
+ var _this$props$makeStyle2, _this$props2;
102
+ (_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));
103
+ }
104
+ componentWillUnmount() {
105
+ var _this$_resizeListener, _this$_debounced2;
106
+ (_this$_resizeListener = this._resizeListener) === null || _this$_resizeListener === void 0 ? void 0 : _this$_resizeListener.disconnect();
107
+ (_this$_debounced2 = this._debounced) === null || _this$_debounced2 === void 0 ? void 0 : _this$_debounced2.cancel();
108
+ }
109
+ render() {
110
+ var _this$props$styles;
111
+ const _this$props3 = this.props,
112
+ style = _this$props3.style,
113
+ label = _this$props3.label,
114
+ role = _this$props3.role;
115
+ return (0, _jsxRuntime.jsx)("div", {
116
+ ...(0, _omitProps.omitProps)(this.props, DrawerContent.allowedProps),
117
+ role: role,
118
+ style: style,
119
+ ref: this.handleContentRef,
120
+ "aria-label": label,
121
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerContent,
122
+ "data-cid": "DrawerContent",
123
+ children: this.props.children
124
+ });
125
+ }
126
+ }, _DrawerContent.displayName = "DrawerContent", _DrawerContent.componentId = 'DrawerLayout.Content', _DrawerContent.locatorAttribute = 'data-drawer-content', _DrawerContent.allowedProps = _props.allowedProps, _DrawerContent.defaultProps = {
127
+ role: 'region'
128
+ }, _DrawerContent)) || _class);
129
+ var _default = exports.default = DrawerContent;
@@ -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', 'contentRef', 'onSizeChange', 'role'];
@@ -0,0 +1,57 @@
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} sharedTokens Shared token object that stores common values for the theme.
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, _props, _sharedTokens, state) => {
43
+ const shouldTransition = state.shouldTransition;
44
+ const transitionState = shouldTransition ? {
45
+ transition: `margin ${componentTheme.duration}`
46
+ } : {};
47
+ return {
48
+ drawerContent: {
49
+ label: 'drawerLayout__content',
50
+ overflowY: componentTheme.overflowY,
51
+ height: '100%',
52
+ boxSizing: 'content-box',
53
+ ...transitionState
54
+ }
55
+ };
56
+ };
57
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,232 @@
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 _index = require("../index");
20
+ var _props = require("./props");
21
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
+ 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"];
23
+ var _dec, _dec2, _class, _DrawerTray;
24
+ /*
25
+ * The MIT License (MIT)
26
+ *
27
+ * Copyright (c) 2015 - present Instructure, Inc.
28
+ *
29
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ * of this software and associated documentation files (the "Software"), to deal
31
+ * in the Software without restriction, including without limitation the rights
32
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ * copies of the Software, and to permit persons to whom the Software is
34
+ * furnished to do so, subject to the following conditions:
35
+ *
36
+ * The above copyright notice and this permission notice shall be included in all
37
+ * copies or substantial portions of the Software.
38
+ *
39
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ * SOFTWARE.
46
+ */
47
+ /**
48
+ ---
49
+ parent: DrawerLayout
50
+ id: DrawerLayout.Tray
51
+ ---
52
+ **/
53
+ let DrawerTray = exports.DrawerTray = (_dec = (0, _emotion.withStyle)(_styles.default), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = (_DrawerTray = class DrawerTray extends _react.Component {
54
+ get _content() {
55
+ return this.ref;
56
+ }
57
+ constructor(props) {
58
+ super(props);
59
+ this.ref = null;
60
+ this._DOMNode = null;
61
+ this.makeStyleProps = () => {
62
+ return {
63
+ placement: this.placement
64
+ };
65
+ };
66
+ this.handleContentRef = node => {
67
+ this.ref = node;
68
+ if (typeof this.props.contentRef === 'function') {
69
+ this.props.contentRef(node);
70
+ }
71
+ };
72
+ this.handleTransitionEntered = _transitionType => {
73
+ this.setState({
74
+ transitioning: false
75
+ });
76
+ };
77
+ this.handleTransitionExited = _transitionType => {
78
+ this.setState({
79
+ transitioning: false
80
+ });
81
+ };
82
+ this.handlePortalOpen = DOMNode => {
83
+ this.DOMNode = DOMNode;
84
+ this.setState({
85
+ portalOpen: true
86
+ });
87
+ };
88
+ this.state = {
89
+ transitioning: false,
90
+ portalOpen: false
91
+ };
92
+ }
93
+ componentDidMount() {
94
+ var _this$props$makeStyle, _this$props;
95
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
96
+ }
97
+ componentDidUpdate(prevProps) {
98
+ var _this$props$makeStyle2, _this$props2;
99
+ if (this.props.open !== prevProps.open) {
100
+ this.setState({
101
+ transitioning: true
102
+ });
103
+ }
104
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
105
+ }
106
+ get placement() {
107
+ const _this$props3 = this.props,
108
+ placement = _this$props3.placement,
109
+ dir = _this$props3.dir;
110
+ const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
111
+ return isRtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement;
112
+ }
113
+ get transition() {
114
+ return this.placement === 'end' ? 'fade' : 'slide-left';
115
+ }
116
+ get DOMNode() {
117
+ return this._DOMNode;
118
+ }
119
+ set DOMNode(el) {
120
+ this._DOMNode = el;
121
+ }
122
+ renderContent() {
123
+ const _this$props4 = this.props,
124
+ children = _this$props4.children,
125
+ render = _this$props4.render;
126
+ if (typeof render === 'function') {
127
+ return render();
128
+ } else if (typeof children === 'function') {
129
+ return children();
130
+ } else {
131
+ return children;
132
+ }
133
+ }
134
+ render() {
135
+ const _this$props5 = this.props,
136
+ label = _this$props5.label,
137
+ children = _this$props5.children,
138
+ render = _this$props5.render,
139
+ placement = _this$props5.placement,
140
+ open = _this$props5.open,
141
+ onOpen = _this$props5.onOpen,
142
+ onClose = _this$props5.onClose,
143
+ border = _this$props5.border,
144
+ shadow = _this$props5.shadow,
145
+ onEnter = _this$props5.onEnter,
146
+ onEntering = _this$props5.onEntering,
147
+ onEntered = _this$props5.onEntered,
148
+ onExit = _this$props5.onExit,
149
+ onExiting = _this$props5.onExiting,
150
+ onExited = _this$props5.onExited,
151
+ contentRef = _this$props5.contentRef,
152
+ mountNode = _this$props5.mountNode,
153
+ defaultFocusElement = _this$props5.defaultFocusElement,
154
+ liveRegion = _this$props5.liveRegion,
155
+ onDismiss = _this$props5.onDismiss,
156
+ onTransition = _this$props5.onTransition,
157
+ shouldReturnFocus = _this$props5.shouldReturnFocus,
158
+ shouldCloseOnEscape = _this$props5.shouldCloseOnEscape,
159
+ shouldCloseOnDocumentClick = _this$props5.shouldCloseOnDocumentClick,
160
+ shouldContainFocus = _this$props5.shouldContainFocus,
161
+ styles = _this$props5.styles,
162
+ props = (0, _objectWithoutProperties2.default)(_this$props5, _excluded);
163
+ return (0, _jsxRuntime.jsx)(_index.DrawerLayoutContext.Consumer, {
164
+ children: shouldOverlayTray => {
165
+ var _this$props$styles;
166
+ const portalOpen = this.state.portalOpen;
167
+ const needsPortal = shouldOverlayTray && !!mountNode;
168
+ // we have to handle the shadow version here,
169
+ // because passing and handling it in styles.js makes it
170
+ // rerender the component during the transition, breaking it
171
+ const trayStyles = shadow && shouldOverlayTray ? styles === null || styles === void 0 ? void 0 : styles.drawerTrayWithShadow : styles === null || styles === void 0 ? void 0 : styles.drawerTray;
172
+ let transitionIn = open;
173
+ if (needsPortal && !portalOpen) {
174
+ transitionIn = false;
175
+ }
176
+ const content = (0, _jsxRuntime.jsx)(_Transition.Transition, {
177
+ in: transitionIn,
178
+ type: this.transition,
179
+ onTransition: onTransition,
180
+ onEnter: onEnter,
181
+ onEntering: onEntering,
182
+ onEntered: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionEntered, onEntered, onOpen),
183
+ onExit: onExit,
184
+ onExiting: onExiting,
185
+ onExited: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionExited, onExited, onClose),
186
+ unmountOnExit: true,
187
+ children: (0, _jsxRuntime.jsx)("div", {
188
+ ...(0, _omitProps.omitProps)(props, DrawerTray.allowedProps),
189
+ ref: this.handleContentRef,
190
+ css: trayStyles,
191
+ "data-cid": "DrawerTray",
192
+ children: (0, _jsxRuntime.jsx)(_Dialog.Dialog, {
193
+ open: true,
194
+ role: shouldOverlayTray ? 'dialog' : 'region',
195
+ label: label,
196
+ shouldReturnFocus: shouldReturnFocus,
197
+ shouldContainFocus: !this.state.transitioning && shouldContainFocus && shouldOverlayTray,
198
+ shouldCloseOnDocumentClick: shouldCloseOnDocumentClick && shouldOverlayTray,
199
+ shouldCloseOnEscape: shouldCloseOnEscape && shouldOverlayTray,
200
+ defaultFocusElement: defaultFocusElement,
201
+ liveRegion: liveRegion,
202
+ onDismiss: onDismiss,
203
+ as: "div",
204
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.drawerTrayContent,
205
+ children: this.renderContent()
206
+ })
207
+ })
208
+ });
209
+ if (needsPortal) {
210
+ return (0, _jsxRuntime.jsx)(_Portal.Portal, {
211
+ mountNode: mountNode,
212
+ open: true,
213
+ onOpen: this.handlePortalOpen,
214
+ children: content
215
+ });
216
+ } else {
217
+ return content;
218
+ }
219
+ }
220
+ });
221
+ }
222
+ }, _DrawerTray.displayName = "DrawerTray", _DrawerTray.componentId = 'DrawerLayout.Tray', _DrawerTray.locatorAttribute = 'data-drawer-tray', _DrawerTray.allowedProps = _props.allowedProps, _DrawerTray.defaultProps = {
223
+ shouldContainFocus: true,
224
+ shouldCloseOnEscape: true,
225
+ shouldCloseOnDocumentClick: true,
226
+ shouldReturnFocus: true,
227
+ open: false,
228
+ shadow: true,
229
+ border: true,
230
+ placement: 'start'
231
+ }, _DrawerTray)) || _class) || _class);
232
+ var _default = exports.default = DrawerTray;
@@ -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', 'render', 'placement', 'open', 'onOpen', 'onClose', 'border', 'shadow', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'contentRef', 'mountNode', 'defaultFocusElement', 'liveRegion', 'onDismiss', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'shouldCloseOnEscape', 'dir'];
@@ -0,0 +1,100 @@
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} sharedTokens Shared token object that stores common values for the theme.
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, props, _sharedTokens, state) => {
43
+ const border = props.border;
44
+ const placement = state.placement;
45
+ const borderPlacementStyle = {
46
+ start: {
47
+ borderRightWidth: componentTheme.borderWidth
48
+ },
49
+ end: {
50
+ borderLeftWidth: componentTheme.borderWidth
51
+ }
52
+ };
53
+ const borderStyles = border ? {
54
+ borderWidth: 0,
55
+ borderColor: componentTheme.borderColor,
56
+ borderStyle: componentTheme.borderStyle,
57
+ boxSizing: 'border-box',
58
+ ...borderPlacementStyle[placement]
59
+ } : {
60
+ boxSizing: 'content-box'
61
+ };
62
+ const placementStyleMap = {
63
+ start: {
64
+ left: 0
65
+ },
66
+ end: {
67
+ right: 0
68
+ }
69
+ };
70
+ const trayStyle = {
71
+ position: 'absolute',
72
+ backgroundColor: componentTheme.background,
73
+ zIndex: componentTheme.zIndex,
74
+ overflowY: componentTheme.overflowY,
75
+ overflowX: componentTheme.overflowX,
76
+ ...borderStyles,
77
+ top: 0,
78
+ bottom: 0,
79
+ ...placementStyleMap[placement]
80
+ };
81
+ return {
82
+ drawerTray: {
83
+ label: 'drawerTray',
84
+ ...trayStyle
85
+ },
86
+ drawerTrayWithShadow: {
87
+ label: 'drawerTray--with-shadow',
88
+ ...trayStyle,
89
+ boxShadow: componentTheme.boxShadow,
90
+ border: 0
91
+ },
92
+ drawerTrayContent: {
93
+ label: 'drawerTray__content',
94
+ overflowY: componentTheme.contentOverflowY,
95
+ height: '100%',
96
+ boxSizing: 'content-box'
97
+ }
98
+ };
99
+ };
100
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,79 @@
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
+ };
@@ -63,7 +63,7 @@ var _dec, _dec2, _dec3, _class, _DrawerLayout;
63
63
  category: components
64
64
  ---
65
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 {
66
+ let DrawerLayout = exports.DrawerLayout = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec3 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = _dec3(_class = (_DrawerLayout = class DrawerLayout extends _react.Component {
67
67
  constructor(_props) {
68
68
  super(_props);
69
69
  this._id = void 0;