@instructure/ui-modal 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 (184) hide show
  1. package/CHANGELOG.md +49 -311
  2. package/es/Modal/{ModalBody → v1/ModalBody}/index.js +2 -2
  3. package/es/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
  4. package/es/Modal/{ModalHeader → v1/ModalHeader}/index.js +2 -2
  5. package/es/Modal/{index.js → v1/index.js} +2 -2
  6. package/es/Modal/v2/ModalBody/index.js +132 -0
  7. package/es/Modal/v2/ModalBody/props.js +26 -0
  8. package/es/Modal/v2/ModalBody/styles.js +68 -0
  9. package/es/Modal/v2/ModalContext.js +34 -0
  10. package/es/Modal/v2/ModalFooter/index.js +73 -0
  11. package/es/{index.js → Modal/v2/ModalFooter/props.js} +3 -1
  12. package/es/Modal/v2/ModalFooter/styles.js +60 -0
  13. package/es/Modal/v2/ModalHeader/index.js +112 -0
  14. package/es/Modal/v2/ModalHeader/props.js +26 -0
  15. package/es/Modal/v2/ModalHeader/styles.js +76 -0
  16. package/es/Modal/v2/index.js +259 -0
  17. package/es/Modal/v2/props.js +26 -0
  18. package/es/Modal/v2/styles.js +119 -0
  19. package/es/exports/a.js +24 -0
  20. package/es/exports/b.js +24 -0
  21. package/lib/Modal/{ModalBody → v1/ModalBody}/index.js +4 -4
  22. package/lib/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
  23. package/lib/Modal/{ModalHeader → v1/ModalHeader}/index.js +3 -3
  24. package/lib/Modal/v1/index.js +285 -0
  25. package/lib/Modal/v2/ModalBody/index.js +137 -0
  26. package/lib/Modal/v2/ModalBody/props.js +31 -0
  27. package/lib/Modal/v2/ModalBody/styles.js +74 -0
  28. package/lib/Modal/v2/ModalContext.js +39 -0
  29. package/lib/Modal/v2/ModalFooter/index.js +78 -0
  30. package/lib/Modal/v2/ModalFooter/props.js +31 -0
  31. package/lib/Modal/v2/ModalFooter/styles.js +66 -0
  32. package/lib/Modal/v2/ModalHeader/index.js +118 -0
  33. package/lib/Modal/v2/ModalHeader/props.js +31 -0
  34. package/lib/Modal/v2/ModalHeader/styles.js +82 -0
  35. package/lib/Modal/{index.js → v2/index.js} +3 -4
  36. package/lib/Modal/v2/props.js +31 -0
  37. package/lib/Modal/v2/styles.js +125 -0
  38. package/lib/{index.js → exports/a.js} +5 -5
  39. package/lib/exports/b.js +30 -0
  40. package/package.json +46 -24
  41. package/src/Modal/{ModalBody → v1/ModalBody}/index.tsx +2 -2
  42. package/src/Modal/{ModalFooter → v1/ModalFooter}/index.tsx +1 -1
  43. package/src/Modal/{ModalHeader → v1/ModalHeader}/index.tsx +3 -3
  44. package/src/Modal/{index.tsx → v1/index.tsx} +2 -2
  45. package/src/Modal/v2/ModalBody/index.tsx +164 -0
  46. package/src/Modal/v2/ModalBody/props.ts +72 -0
  47. package/src/Modal/v2/ModalBody/styles.ts +76 -0
  48. package/src/Modal/v2/ModalContext.ts +46 -0
  49. package/src/Modal/v2/ModalFooter/index.tsx +80 -0
  50. package/src/Modal/v2/ModalFooter/props.ts +50 -0
  51. package/src/Modal/v2/ModalFooter/styles.ts +74 -0
  52. package/src/Modal/v2/ModalHeader/index.tsx +138 -0
  53. package/src/Modal/v2/ModalHeader/props.ts +54 -0
  54. package/src/Modal/v2/ModalHeader/styles.ts +99 -0
  55. package/src/Modal/v2/README.md +673 -0
  56. package/src/Modal/v2/index.tsx +326 -0
  57. package/src/Modal/v2/props.ts +235 -0
  58. package/src/Modal/v2/styles.ts +130 -0
  59. package/src/{index.ts → exports/a.ts} +5 -5
  60. package/src/exports/b.ts +29 -0
  61. package/tsconfig.build.tsbuildinfo +1 -1
  62. package/types/Modal/v1/ModalBody/index.d.ts.map +1 -0
  63. package/types/Modal/v1/ModalBody/props.d.ts.map +1 -0
  64. package/types/Modal/v1/ModalBody/styles.d.ts.map +1 -0
  65. package/types/Modal/v1/ModalBody/theme.d.ts.map +1 -0
  66. package/types/Modal/v1/ModalContext.d.ts.map +1 -0
  67. package/types/Modal/v1/ModalFooter/index.d.ts.map +1 -0
  68. package/types/Modal/v1/ModalFooter/props.d.ts.map +1 -0
  69. package/types/Modal/v1/ModalFooter/styles.d.ts.map +1 -0
  70. package/types/Modal/v1/ModalFooter/theme.d.ts.map +1 -0
  71. package/types/Modal/v1/ModalHeader/index.d.ts.map +1 -0
  72. package/types/Modal/v1/ModalHeader/props.d.ts.map +1 -0
  73. package/types/Modal/v1/ModalHeader/styles.d.ts.map +1 -0
  74. package/types/Modal/v1/ModalHeader/theme.d.ts.map +1 -0
  75. package/types/Modal/v1/index.d.ts.map +1 -0
  76. package/types/Modal/v1/props.d.ts.map +1 -0
  77. package/types/Modal/v1/styles.d.ts.map +1 -0
  78. package/types/Modal/v1/theme.d.ts.map +1 -0
  79. package/types/Modal/v2/ModalBody/index.d.ts +36 -0
  80. package/types/Modal/v2/ModalBody/index.d.ts.map +1 -0
  81. package/types/Modal/v2/ModalBody/props.d.ts +23 -0
  82. package/types/Modal/v2/ModalBody/props.d.ts.map +1 -0
  83. package/types/Modal/v2/ModalBody/styles.d.ts +16 -0
  84. package/types/Modal/v2/ModalBody/styles.d.ts.map +1 -0
  85. package/types/Modal/v2/ModalContext.d.ts +17 -0
  86. package/types/Modal/v2/ModalContext.d.ts.map +1 -0
  87. package/types/Modal/v2/ModalFooter/index.d.ts +27 -0
  88. package/types/Modal/v2/ModalFooter/index.d.ts.map +1 -0
  89. package/types/Modal/v2/ModalFooter/props.d.ts +16 -0
  90. package/types/Modal/v2/ModalFooter/props.d.ts.map +1 -0
  91. package/types/Modal/v2/ModalFooter/styles.d.ts +16 -0
  92. package/types/Modal/v2/ModalFooter/styles.d.ts.map +1 -0
  93. package/types/Modal/v2/ModalHeader/index.d.ts +37 -0
  94. package/types/Modal/v2/ModalHeader/index.d.ts.map +1 -0
  95. package/types/Modal/v2/ModalHeader/props.d.ts +19 -0
  96. package/types/Modal/v2/ModalHeader/props.d.ts.map +1 -0
  97. package/types/Modal/v2/ModalHeader/styles.d.ts +16 -0
  98. package/types/Modal/v2/ModalHeader/styles.d.ts.map +1 -0
  99. package/types/Modal/v2/index.d.ts +54 -0
  100. package/types/Modal/v2/index.d.ts.map +1 -0
  101. package/types/Modal/v2/props.d.ts +132 -0
  102. package/types/Modal/v2/props.d.ts.map +1 -0
  103. package/types/Modal/v2/styles.d.ts +16 -0
  104. package/types/Modal/v2/styles.d.ts.map +1 -0
  105. package/types/exports/a.d.ts +6 -0
  106. package/types/exports/a.d.ts.map +1 -0
  107. package/types/exports/b.d.ts +6 -0
  108. package/types/exports/b.d.ts.map +1 -0
  109. package/types/Modal/ModalBody/index.d.ts.map +0 -1
  110. package/types/Modal/ModalBody/props.d.ts.map +0 -1
  111. package/types/Modal/ModalBody/styles.d.ts.map +0 -1
  112. package/types/Modal/ModalBody/theme.d.ts.map +0 -1
  113. package/types/Modal/ModalContext.d.ts.map +0 -1
  114. package/types/Modal/ModalFooter/index.d.ts.map +0 -1
  115. package/types/Modal/ModalFooter/props.d.ts.map +0 -1
  116. package/types/Modal/ModalFooter/styles.d.ts.map +0 -1
  117. package/types/Modal/ModalFooter/theme.d.ts.map +0 -1
  118. package/types/Modal/ModalHeader/index.d.ts.map +0 -1
  119. package/types/Modal/ModalHeader/props.d.ts.map +0 -1
  120. package/types/Modal/ModalHeader/styles.d.ts.map +0 -1
  121. package/types/Modal/ModalHeader/theme.d.ts.map +0 -1
  122. package/types/Modal/index.d.ts.map +0 -1
  123. package/types/Modal/props.d.ts.map +0 -1
  124. package/types/Modal/styles.d.ts.map +0 -1
  125. package/types/Modal/theme.d.ts.map +0 -1
  126. package/types/index.d.ts +0 -6
  127. package/types/index.d.ts.map +0 -1
  128. /package/es/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
  129. /package/es/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
  130. /package/es/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
  131. /package/es/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
  132. /package/es/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
  133. /package/es/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
  134. /package/es/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
  135. /package/es/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
  136. /package/es/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
  137. /package/es/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
  138. /package/es/Modal/{props.js → v1/props.js} +0 -0
  139. /package/es/Modal/{styles.js → v1/styles.js} +0 -0
  140. /package/es/Modal/{theme.js → v1/theme.js} +0 -0
  141. /package/lib/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
  142. /package/lib/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
  143. /package/lib/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
  144. /package/lib/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
  145. /package/lib/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
  146. /package/lib/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
  147. /package/lib/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
  148. /package/lib/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
  149. /package/lib/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
  150. /package/lib/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
  151. /package/lib/Modal/{props.js → v1/props.js} +0 -0
  152. /package/lib/Modal/{styles.js → v1/styles.js} +0 -0
  153. /package/lib/Modal/{theme.js → v1/theme.js} +0 -0
  154. /package/src/Modal/{ModalBody → v1/ModalBody}/props.ts +0 -0
  155. /package/src/Modal/{ModalBody → v1/ModalBody}/styles.ts +0 -0
  156. /package/src/Modal/{ModalBody → v1/ModalBody}/theme.ts +0 -0
  157. /package/src/Modal/{ModalContext.ts → v1/ModalContext.ts} +0 -0
  158. /package/src/Modal/{ModalFooter → v1/ModalFooter}/props.ts +0 -0
  159. /package/src/Modal/{ModalFooter → v1/ModalFooter}/styles.ts +0 -0
  160. /package/src/Modal/{ModalFooter → v1/ModalFooter}/theme.ts +0 -0
  161. /package/src/Modal/{ModalHeader → v1/ModalHeader}/props.ts +0 -0
  162. /package/src/Modal/{ModalHeader → v1/ModalHeader}/styles.ts +0 -0
  163. /package/src/Modal/{ModalHeader → v1/ModalHeader}/theme.ts +0 -0
  164. /package/src/Modal/{README.md → v1/README.md} +0 -0
  165. /package/src/Modal/{props.ts → v1/props.ts} +0 -0
  166. /package/src/Modal/{styles.ts → v1/styles.ts} +0 -0
  167. /package/src/Modal/{theme.ts → v1/theme.ts} +0 -0
  168. /package/types/Modal/{ModalBody → v1/ModalBody}/index.d.ts +0 -0
  169. /package/types/Modal/{ModalBody → v1/ModalBody}/props.d.ts +0 -0
  170. /package/types/Modal/{ModalBody → v1/ModalBody}/styles.d.ts +0 -0
  171. /package/types/Modal/{ModalBody → v1/ModalBody}/theme.d.ts +0 -0
  172. /package/types/Modal/{ModalContext.d.ts → v1/ModalContext.d.ts} +0 -0
  173. /package/types/Modal/{ModalFooter → v1/ModalFooter}/index.d.ts +0 -0
  174. /package/types/Modal/{ModalFooter → v1/ModalFooter}/props.d.ts +0 -0
  175. /package/types/Modal/{ModalFooter → v1/ModalFooter}/styles.d.ts +0 -0
  176. /package/types/Modal/{ModalFooter → v1/ModalFooter}/theme.d.ts +0 -0
  177. /package/types/Modal/{ModalHeader → v1/ModalHeader}/index.d.ts +0 -0
  178. /package/types/Modal/{ModalHeader → v1/ModalHeader}/props.d.ts +0 -0
  179. /package/types/Modal/{ModalHeader → v1/ModalHeader}/styles.d.ts +0 -0
  180. /package/types/Modal/{ModalHeader → v1/ModalHeader}/theme.d.ts +0 -0
  181. /package/types/Modal/{index.d.ts → v1/index.d.ts} +0 -0
  182. /package/types/Modal/{props.d.ts → v1/props.d.ts} +0 -0
  183. /package/types/Modal/{styles.d.ts → v1/styles.d.ts} +0 -0
  184. /package/types/Modal/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,259 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["open", "onOpen", "onClose", "mountNode", "insertAt", "transition", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "constrain", "overflow"];
3
+ var _dec, _class, _Modal;
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 { Children, Component, isValidElement } from 'react';
29
+ import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils';
30
+ import { createChainedFunction } from '@instructure/ui-utils';
31
+ import { Transition } from '@instructure/ui-motion';
32
+ import { Portal } from '@instructure/ui-portal';
33
+ import { Dialog } from '@instructure/ui-dialog';
34
+ import { Mask } from '@instructure/ui-overlays/latest';
35
+ import { ModalHeader } from "./ModalHeader/index.js";
36
+ import { ModalBody } from "./ModalBody/index.js";
37
+ import { ModalFooter } from "./ModalFooter/index.js";
38
+ import { withStyle } from '@instructure/emotion';
39
+ import generateStyle from "./styles.js";
40
+ import { allowedProps } from "./props.js";
41
+ import ModalContext from "./ModalContext.js";
42
+ /**
43
+ ---
44
+ category: components
45
+ tags: overlay, portal, dialog
46
+ ---
47
+ **/
48
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
49
+ let Modal = (_dec = withStyle(generateStyle), _dec(_class = (_Modal = class Modal extends Component {
50
+ constructor(props) {
51
+ var _props$open;
52
+ super(props);
53
+ this._DOMNode = null;
54
+ this._content = null;
55
+ this.ref = null;
56
+ this.handleRef = el => {
57
+ this.ref = el;
58
+ };
59
+ this.updateHeight = () => {
60
+ this.setState({
61
+ windowHeight: window.innerHeight
62
+ });
63
+ };
64
+ this.handlePortalOpen = DOMNode => {
65
+ this.DOMNode = DOMNode;
66
+ };
67
+ this.handleTransitionComplete = () => {
68
+ this.setState({
69
+ transitioning: false
70
+ });
71
+ };
72
+ this.contentRef = el => {
73
+ this._content = el;
74
+ if (typeof this.props.contentRef === 'function') {
75
+ this.props.contentRef(el);
76
+ }
77
+ };
78
+ this.state = {
79
+ transitioning: false,
80
+ open: (_props$open = props.open) !== null && _props$open !== void 0 ? _props$open : false,
81
+ windowHeight: 99999,
82
+ bodyScrollAriaLabel: void 0
83
+ };
84
+ }
85
+ componentDidMount() {
86
+ var _this$props$makeStyle, _this$props;
87
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
88
+ window.addEventListener('resize', this.updateHeight);
89
+ }
90
+ componentDidUpdate(prevProps) {
91
+ var _this$props$makeStyle2, _this$props2;
92
+ if (this.props.open !== prevProps.open) {
93
+ this.setState({
94
+ transitioning: true,
95
+ open: !!this.props.open
96
+ });
97
+ }
98
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
99
+ }
100
+ componentWillUnmount() {
101
+ window.removeEventListener('resize', this.updateHeight);
102
+ }
103
+ get defaultFocusElement() {
104
+ return this.props.defaultFocusElement;
105
+ }
106
+ get DOMNode() {
107
+ return this._DOMNode;
108
+ }
109
+ set DOMNode(el) {
110
+ this._DOMNode = el;
111
+ }
112
+ get maskPlacement() {
113
+ if (this.props.overflow === 'fit') {
114
+ return 'stretch';
115
+ } else {
116
+ return 'center';
117
+ }
118
+ }
119
+ renderChildren() {
120
+ const _this$props3 = this.props,
121
+ children = _this$props3.children,
122
+ variant = _this$props3.variant,
123
+ overflow = _this$props3.overflow,
124
+ styles = _this$props3.styles;
125
+ const childrenArray = Children.toArray(children);
126
+ const headerAndBody = [];
127
+ const others = [];
128
+ childrenArray.forEach(child => {
129
+ if (/*#__PURE__*/isValidElement(child)) {
130
+ if (child.type === Modal.Header || child.type === Modal.Body) {
131
+ headerAndBody.push(this.cloneChildWithProps(child, variant, overflow));
132
+ } else {
133
+ others.push(this.cloneChildWithProps(child, variant, overflow));
134
+ }
135
+ }
136
+ });
137
+
138
+ // Putting ModalHeader and ModalBody into the same container, so they can be styled together;
139
+ // this is needed to apply a media query breakpoint
140
+ const wrappedHeaderAndBody = headerAndBody.length > 0 ? _jsx("div", {
141
+ css: styles === null || styles === void 0 ? void 0 : styles.joinedHeaderAndBody,
142
+ children: headerAndBody
143
+ }, "header-and-body") : null;
144
+ return [...(wrappedHeaderAndBody ? [wrappedHeaderAndBody] : []), ...others];
145
+ }
146
+ cloneChildWithProps(child, variant, overflow) {
147
+ if (/*#__PURE__*/isValidElement(child)) {
148
+ var _child$props;
149
+ return safeCloneElement(child, {
150
+ variant: variant,
151
+ overflow: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.overflow) || overflow
152
+ });
153
+ } else {
154
+ return child;
155
+ }
156
+ }
157
+ renderDialog(props) {
158
+ const _this$props4 = this.props,
159
+ onDismiss = _this$props4.onDismiss,
160
+ label = _this$props4.label,
161
+ shouldCloseOnDocumentClick = _this$props4.shouldCloseOnDocumentClick,
162
+ shouldReturnFocus = _this$props4.shouldReturnFocus,
163
+ liveRegion = _this$props4.liveRegion,
164
+ size = _this$props4.size,
165
+ constrain = _this$props4.constrain,
166
+ as = _this$props4.as,
167
+ styles = _this$props4.styles;
168
+ const isFullScreen = size === 'fullscreen';
169
+ const dialog = _jsx(Dialog, {
170
+ ...passthroughProps(props),
171
+ as: as,
172
+ open: true,
173
+ label: label,
174
+ defaultFocusElement: this.defaultFocusElement,
175
+ shouldCloseOnDocumentClick: shouldCloseOnDocumentClick,
176
+ shouldCloseOnEscape: true,
177
+ shouldContainFocus: true,
178
+ shouldReturnFocus: shouldReturnFocus,
179
+ liveRegion: liveRegion,
180
+ onDismiss: onDismiss,
181
+ css: styles === null || styles === void 0 ? void 0 : styles.modal,
182
+ ref: this.contentRef
183
+ // aria-modal="true" see VO bug https://bugs.webkit.org/show_bug.cgi?id=174667
184
+ ,
185
+ children: this.renderChildren()
186
+ });
187
+ return _jsx(Mask, {
188
+ placement: this.maskPlacement,
189
+ fullscreen: constrain === 'window',
190
+ themeOverride: isFullScreen ? {
191
+ borderRadius: '0em',
192
+ borderWidth: '0em'
193
+ } : {},
194
+ children: dialog
195
+ });
196
+ }
197
+ render() {
198
+ var _this$props$styles;
199
+ const _this$props5 = this.props,
200
+ open = _this$props5.open,
201
+ onOpen = _this$props5.onOpen,
202
+ onClose = _this$props5.onClose,
203
+ mountNode = _this$props5.mountNode,
204
+ insertAt = _this$props5.insertAt,
205
+ transition = _this$props5.transition,
206
+ onEnter = _this$props5.onEnter,
207
+ onEntering = _this$props5.onEntering,
208
+ onEntered = _this$props5.onEntered,
209
+ onExit = _this$props5.onExit,
210
+ onExiting = _this$props5.onExiting,
211
+ onExited = _this$props5.onExited,
212
+ constrain = _this$props5.constrain,
213
+ overflow = _this$props5.overflow,
214
+ passthroughProps = _objectWithoutProperties(_this$props5, _excluded);
215
+ const portalIsOpen = this.state.open || this.state.transitioning;
216
+ return _jsx(Portal, {
217
+ mountNode: mountNode,
218
+ insertAt: insertAt,
219
+ open: portalIsOpen,
220
+ onOpen: this.handlePortalOpen,
221
+ "data-cid": "Modal",
222
+ children: _jsx(Transition, {
223
+ in: open,
224
+ transitionOnMount: true,
225
+ type: transition,
226
+ onEnter: onEnter,
227
+ onEntering: onEntering,
228
+ onEntered: createChainedFunction(this.handleTransitionComplete, onEntered, onOpen),
229
+ onExit: onExit,
230
+ onExiting: onExiting,
231
+ onExited: createChainedFunction(this.handleTransitionComplete, onExited, onClose),
232
+ children: _jsx(ModalContext.Provider, {
233
+ value: {
234
+ bodyScrollAriaLabel: this.state.bodyScrollAriaLabel,
235
+ setBodyScrollAriaLabel: txt => this.setState({
236
+ bodyScrollAriaLabel: txt
237
+ })
238
+ },
239
+ children: constrain === 'parent' ? _jsx("span", {
240
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.constrainContext,
241
+ children: this.renderDialog(passthroughProps)
242
+ }) : this.renderDialog(passthroughProps)
243
+ })
244
+ })
245
+ });
246
+ }
247
+ }, _Modal.displayName = "Modal", _Modal.componentId = 'Modal', _Modal.allowedProps = allowedProps, _Modal.defaultProps = {
248
+ open: false,
249
+ size: 'auto',
250
+ variant: 'default',
251
+ transition: 'fade',
252
+ insertAt: 'bottom',
253
+ shouldCloseOnDocumentClick: true,
254
+ shouldReturnFocus: true,
255
+ constrain: 'window',
256
+ overflow: 'scroll'
257
+ }, _Modal.Header = ModalHeader, _Modal.Body = ModalBody, _Modal.Footer = ModalFooter, _Modal)) || _class);
258
+ export default Modal;
259
+ export { Modal, ModalHeader, ModalBody, ModalFooter };
@@ -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', 'as', 'size', 'variant', 'open', 'defaultFocusElement', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'onOpen', 'onClose', 'onDismiss', 'contentRef', 'mountNode', 'insertAt', 'liveRegion', 'transition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'constrain', 'overflow'];
26
+ export { allowedProps };
@@ -0,0 +1,119 @@
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} props the props of the component, the style is applied to
33
+ * @param {Object} sharedTokens Shared theme token object
34
+ * @param {Object} state the state of the component, the style is applied to
35
+ * @return {Object} The final style object, which will be used in the component
36
+ */
37
+ const generateStyle = (componentTheme, props) => {
38
+ const size = props.size,
39
+ variant = props.variant,
40
+ overflow = props.overflow;
41
+ const commonSizeStyleExceptForFullscreen = {
42
+ maxWidth: '95%',
43
+ maxHeight: '95%',
44
+ ...(overflow === 'fit' && {
45
+ transform: 'translateY(2.5%)'
46
+ })
47
+ };
48
+ const sizeStyles = {
49
+ auto: {
50
+ flex: '0 1 auto',
51
+ minWidth: componentTheme.autoMinWidth,
52
+ ...commonSizeStyleExceptForFullscreen
53
+ },
54
+ small: {
55
+ flex: `0 1 ${componentTheme.smallMaxWidth}`,
56
+ ...commonSizeStyleExceptForFullscreen
57
+ },
58
+ medium: {
59
+ flex: `0 1 ${componentTheme.mediumMaxWidth}`,
60
+ ...commonSizeStyleExceptForFullscreen
61
+ },
62
+ large: {
63
+ flex: `0 1 ${componentTheme.largeMaxWidth}`,
64
+ ...commonSizeStyleExceptForFullscreen
65
+ },
66
+ fullscreen: {
67
+ flex: 1,
68
+ width: '100%',
69
+ height: '100%',
70
+ boxShadow: 'none',
71
+ border: 'none',
72
+ borderRadius: 0
73
+ }
74
+ };
75
+ const backgroundStyles = variant === 'inverse' ? {
76
+ background: componentTheme.inverseBackgroundColor,
77
+ border: `${componentTheme.borderWidth} solid ${componentTheme.inverseBorderColor}`,
78
+ color: componentTheme.inverseTextColor
79
+ } : {
80
+ background: componentTheme.backgroundColor,
81
+ border: `${componentTheme.borderWidth} solid ${componentTheme.borderColor}`,
82
+ color: componentTheme.textColor
83
+ };
84
+ return {
85
+ modal: {
86
+ label: 'modal',
87
+ fontFamily: componentTheme.fontFamily,
88
+ display: 'flex',
89
+ minWidth: '1px',
90
+ flexDirection: 'column',
91
+ position: 'relative',
92
+ boxSizing: 'border-box',
93
+ boxShadow: boxShadowObjectsToCSSString(componentTheme.boxShadow),
94
+ borderRadius: componentTheme.borderRadius,
95
+ overflow: 'hidden',
96
+ ...sizeStyles[size],
97
+ ...backgroundStyles
98
+ },
99
+ constrainContext: {
100
+ label: 'modal__constrainContext',
101
+ display: 'block',
102
+ position: 'relative',
103
+ width: '100%',
104
+ height: '100%'
105
+ },
106
+ joinedHeaderAndBody: {
107
+ display: 'flex',
108
+ flexDirection: 'column',
109
+ overflow: 'hidden',
110
+ flex: '1 1 auto',
111
+ // ModalHeader and ModalBody is set to scrollable above 20rem height instead of just the ModalBody
112
+ '@media (max-height: 20rem)': {
113
+ overflowY: 'auto',
114
+ maxHeight: '20rem'
115
+ }
116
+ }
117
+ };
118
+ };
119
+ export default generateStyle;
@@ -0,0 +1,24 @@
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
+ export { Modal, ModalBody, ModalFooter, ModalHeader } from "../Modal/v1/index.js";
@@ -0,0 +1,24 @@
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
+ export { Modal, ModalBody, ModalFooter, ModalHeader } from "../Modal/v2/index.js";
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.ModalBody = void 0;
8
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
9
  var _react = require("react");
10
- var _View = require("@instructure/ui-view/lib/View");
10
+ var _v11_ = require("@instructure/ui-view/v11_6");
11
11
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
12
  var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
13
13
  var _emotion = require("@instructure/emotion");
@@ -47,7 +47,7 @@ parent: Modal
47
47
  id: Modal.Body
48
48
  ---
49
49
  **/
50
- let ModalBody = exports.ModalBody = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ModalBody = class ModalBody extends _react.Component {
50
+ let ModalBody = exports.ModalBody = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_ModalBody = class ModalBody extends _react.Component {
51
51
  constructor(props) {
52
52
  super(props);
53
53
  this.ref = null;
@@ -98,7 +98,7 @@ let ModalBody = exports.ModalBody = (_dec = (0, _emotion.withStyle)(_styles.defa
98
98
  padding = _this$props3.padding,
99
99
  children = _this$props3.children,
100
100
  rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
101
- const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(rest, ModalBody.allowedProps), ModalBody);
101
+ const passthroughProps = _v11_.View.omitViewProps((0, _omitProps.omitProps)(rest, ModalBody.allowedProps), ModalBody);
102
102
  const isFit = overflow === 'fit';
103
103
  // this recursive function is needed because `ref` can be a React component.
104
104
  // TODO rethink, the 'as' prop, likely its not a good idea to allow React
@@ -108,7 +108,7 @@ let ModalBody = exports.ModalBody = (_dec = (0, _emotion.withStyle)(_styles.defa
108
108
  return (0, _jsxRuntime.jsx)(_ModalContext.default.Consumer, {
109
109
  children: value => {
110
110
  var _this$props$styles;
111
- return (0, _jsxRuntime.jsx)(_View.View, {
111
+ return (0, _jsxRuntime.jsx)(_v11_.View, {
112
112
  ...passthroughProps,
113
113
  display: "block",
114
114
  "data-cid": "ModalBody",
@@ -44,7 +44,7 @@ parent: Modal
44
44
  id: Modal.Footer
45
45
  ---
46
46
  **/
47
- let ModalFooter = exports.ModalFooter = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ModalFooter = class ModalFooter extends _react.Component {
47
+ let ModalFooter = exports.ModalFooter = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_ModalFooter = class ModalFooter extends _react.Component {
48
48
  constructor(...args) {
49
49
  super(...args);
50
50
  this.ref = null;
@@ -10,7 +10,7 @@ var _react = require("react");
10
10
  var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
11
11
  var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
12
12
  var _emotion = require("@instructure/emotion");
13
- var _CloseButton = require("@instructure/ui-buttons/lib/CloseButton");
13
+ var _v11_ = require("@instructure/ui-buttons/v11_6");
14
14
  var _styles = _interopRequireDefault(require("./styles"));
15
15
  var _theme = _interopRequireDefault(require("./theme"));
16
16
  var _props = require("./props");
@@ -47,7 +47,7 @@ parent: Modal
47
47
  id: Modal.Header
48
48
  ---
49
49
  **/
50
- let ModalHeader = exports.ModalHeader = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ModalHeader = class ModalHeader extends _react.Component {
50
+ let ModalHeader = exports.ModalHeader = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_ModalHeader = class ModalHeader extends _react.Component {
51
51
  constructor(...args) {
52
52
  super(...args);
53
53
  this.ref = null;
@@ -93,7 +93,7 @@ let ModalHeader = exports.ModalHeader = (_dec = (0, _emotion.withStyle)(_styles.
93
93
  get usesCloseButton() {
94
94
  let hasCloseButton = false;
95
95
  _react.Children.forEach(this.props.children, child => {
96
- if (child && (0, _matchComponentTypes.matchComponentTypes)(child, [_CloseButton.CloseButton])) {
96
+ if (child && (0, _matchComponentTypes.matchComponentTypes)(child, [_v11_.CloseButton])) {
97
97
  hasCloseButton = true;
98
98
  }
99
99
  });