@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.
- package/CHANGELOG.md +49 -311
- package/es/Modal/{ModalBody → v1/ModalBody}/index.js +2 -2
- package/es/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
- package/es/Modal/{ModalHeader → v1/ModalHeader}/index.js +2 -2
- package/es/Modal/{index.js → v1/index.js} +2 -2
- package/es/Modal/v2/ModalBody/index.js +132 -0
- package/es/Modal/v2/ModalBody/props.js +26 -0
- package/es/Modal/v2/ModalBody/styles.js +68 -0
- package/es/Modal/v2/ModalContext.js +34 -0
- package/es/Modal/v2/ModalFooter/index.js +73 -0
- package/es/{index.js → Modal/v2/ModalFooter/props.js} +3 -1
- package/es/Modal/v2/ModalFooter/styles.js +60 -0
- package/es/Modal/v2/ModalHeader/index.js +112 -0
- package/es/Modal/v2/ModalHeader/props.js +26 -0
- package/es/Modal/v2/ModalHeader/styles.js +76 -0
- package/es/Modal/v2/index.js +259 -0
- package/es/Modal/v2/props.js +26 -0
- package/es/Modal/v2/styles.js +119 -0
- package/es/exports/a.js +24 -0
- package/es/exports/b.js +24 -0
- package/lib/Modal/{ModalBody → v1/ModalBody}/index.js +4 -4
- package/lib/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
- package/lib/Modal/{ModalHeader → v1/ModalHeader}/index.js +3 -3
- package/lib/Modal/v1/index.js +285 -0
- package/lib/Modal/v2/ModalBody/index.js +137 -0
- package/lib/Modal/v2/ModalBody/props.js +31 -0
- package/lib/Modal/v2/ModalBody/styles.js +74 -0
- package/lib/Modal/v2/ModalContext.js +39 -0
- package/lib/Modal/v2/ModalFooter/index.js +78 -0
- package/lib/Modal/v2/ModalFooter/props.js +31 -0
- package/lib/Modal/v2/ModalFooter/styles.js +66 -0
- package/lib/Modal/v2/ModalHeader/index.js +118 -0
- package/lib/Modal/v2/ModalHeader/props.js +31 -0
- package/lib/Modal/v2/ModalHeader/styles.js +82 -0
- package/lib/Modal/{index.js → v2/index.js} +3 -4
- package/lib/Modal/v2/props.js +31 -0
- package/lib/Modal/v2/styles.js +125 -0
- package/lib/{index.js → exports/a.js} +5 -5
- package/lib/exports/b.js +30 -0
- package/package.json +46 -24
- package/src/Modal/{ModalBody → v1/ModalBody}/index.tsx +2 -2
- package/src/Modal/{ModalFooter → v1/ModalFooter}/index.tsx +1 -1
- package/src/Modal/{ModalHeader → v1/ModalHeader}/index.tsx +3 -3
- package/src/Modal/{index.tsx → v1/index.tsx} +2 -2
- package/src/Modal/v2/ModalBody/index.tsx +164 -0
- package/src/Modal/v2/ModalBody/props.ts +72 -0
- package/src/Modal/v2/ModalBody/styles.ts +76 -0
- package/src/Modal/v2/ModalContext.ts +46 -0
- package/src/Modal/v2/ModalFooter/index.tsx +80 -0
- package/src/Modal/v2/ModalFooter/props.ts +50 -0
- package/src/Modal/v2/ModalFooter/styles.ts +74 -0
- package/src/Modal/v2/ModalHeader/index.tsx +138 -0
- package/src/Modal/v2/ModalHeader/props.ts +54 -0
- package/src/Modal/v2/ModalHeader/styles.ts +99 -0
- package/src/Modal/v2/README.md +673 -0
- package/src/Modal/v2/index.tsx +326 -0
- package/src/Modal/v2/props.ts +235 -0
- package/src/Modal/v2/styles.ts +130 -0
- package/src/{index.ts → exports/a.ts} +5 -5
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Modal/v1/ModalBody/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/theme.d.ts.map +1 -0
- package/types/Modal/v1/ModalContext.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/theme.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/theme.d.ts.map +1 -0
- package/types/Modal/v1/index.d.ts.map +1 -0
- package/types/Modal/v1/props.d.ts.map +1 -0
- package/types/Modal/v1/styles.d.ts.map +1 -0
- package/types/Modal/v1/theme.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/index.d.ts +36 -0
- package/types/Modal/v2/ModalBody/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/props.d.ts +23 -0
- package/types/Modal/v2/ModalBody/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/styles.d.ts +16 -0
- package/types/Modal/v2/ModalBody/styles.d.ts.map +1 -0
- package/types/Modal/v2/ModalContext.d.ts +17 -0
- package/types/Modal/v2/ModalContext.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/index.d.ts +27 -0
- package/types/Modal/v2/ModalFooter/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/props.d.ts +16 -0
- package/types/Modal/v2/ModalFooter/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/styles.d.ts +16 -0
- package/types/Modal/v2/ModalFooter/styles.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/index.d.ts +37 -0
- package/types/Modal/v2/ModalHeader/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/props.d.ts +19 -0
- package/types/Modal/v2/ModalHeader/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/styles.d.ts +16 -0
- package/types/Modal/v2/ModalHeader/styles.d.ts.map +1 -0
- package/types/Modal/v2/index.d.ts +54 -0
- package/types/Modal/v2/index.d.ts.map +1 -0
- package/types/Modal/v2/props.d.ts +132 -0
- package/types/Modal/v2/props.d.ts.map +1 -0
- package/types/Modal/v2/styles.d.ts +16 -0
- package/types/Modal/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +6 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +6 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Modal/ModalBody/index.d.ts.map +0 -1
- package/types/Modal/ModalBody/props.d.ts.map +0 -1
- package/types/Modal/ModalBody/styles.d.ts.map +0 -1
- package/types/Modal/ModalBody/theme.d.ts.map +0 -1
- package/types/Modal/ModalContext.d.ts.map +0 -1
- package/types/Modal/ModalFooter/index.d.ts.map +0 -1
- package/types/Modal/ModalFooter/props.d.ts.map +0 -1
- package/types/Modal/ModalFooter/styles.d.ts.map +0 -1
- package/types/Modal/ModalFooter/theme.d.ts.map +0 -1
- package/types/Modal/ModalHeader/index.d.ts.map +0 -1
- package/types/Modal/ModalHeader/props.d.ts.map +0 -1
- package/types/Modal/ModalHeader/styles.d.ts.map +0 -1
- package/types/Modal/ModalHeader/theme.d.ts.map +0 -1
- package/types/Modal/index.d.ts.map +0 -1
- package/types/Modal/props.d.ts.map +0 -1
- package/types/Modal/styles.d.ts.map +0 -1
- package/types/Modal/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -6
- package/types/index.d.ts.map +0 -1
- /package/es/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
- /package/es/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
- /package/es/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
- /package/es/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
- /package/es/Modal/{props.js → v1/props.js} +0 -0
- /package/es/Modal/{styles.js → v1/styles.js} +0 -0
- /package/es/Modal/{theme.js → v1/theme.js} +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
- /package/lib/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
- /package/lib/Modal/{props.js → v1/props.js} +0 -0
- /package/lib/Modal/{styles.js → v1/styles.js} +0 -0
- /package/lib/Modal/{theme.js → v1/theme.js} +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/props.ts +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/styles.ts +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/theme.ts +0 -0
- /package/src/Modal/{ModalContext.ts → v1/ModalContext.ts} +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/props.ts +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/styles.ts +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/theme.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/props.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/styles.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/theme.ts +0 -0
- /package/src/Modal/{README.md → v1/README.md} +0 -0
- /package/src/Modal/{props.ts → v1/props.ts} +0 -0
- /package/src/Modal/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Modal/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/index.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/props.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/styles.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/theme.d.ts +0 -0
- /package/types/Modal/{ModalContext.d.ts → v1/ModalContext.d.ts} +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/index.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/props.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/styles.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/theme.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/index.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/props.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/styles.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/theme.d.ts +0 -0
- /package/types/Modal/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Modal/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Modal/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Modal/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -27,8 +27,8 @@ var _dec, _class, _ModalHeader;
|
|
|
27
27
|
|
|
28
28
|
import { Children, Component } from 'react';
|
|
29
29
|
import { matchComponentTypes, passthroughProps } from '@instructure/ui-react-utils';
|
|
30
|
-
import { withStyle } from '@instructure/emotion';
|
|
31
|
-
import { CloseButton } from '@instructure/ui-buttons';
|
|
30
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion';
|
|
31
|
+
import { CloseButton } from '@instructure/ui-buttons/v11_6';
|
|
32
32
|
import generateStyle from "./styles.js";
|
|
33
33
|
import generateComponentTheme from "./theme.js";
|
|
34
34
|
import { allowedProps } from "./props.js";
|
|
@@ -31,11 +31,11 @@ import { createChainedFunction } from '@instructure/ui-utils';
|
|
|
31
31
|
import { Transition } from '@instructure/ui-motion';
|
|
32
32
|
import { Portal } from '@instructure/ui-portal';
|
|
33
33
|
import { Dialog } from '@instructure/ui-dialog';
|
|
34
|
-
import { Mask } from '@instructure/ui-overlays';
|
|
34
|
+
import { Mask } from '@instructure/ui-overlays/v11_6';
|
|
35
35
|
import { ModalHeader } from "./ModalHeader/index.js";
|
|
36
36
|
import { ModalBody } from "./ModalBody/index.js";
|
|
37
37
|
import { ModalFooter } from "./ModalFooter/index.js";
|
|
38
|
-
import { withStyle } from '@instructure/emotion';
|
|
38
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion';
|
|
39
39
|
import generateStyle from "./styles.js";
|
|
40
40
|
import generateComponentTheme from "./theme.js";
|
|
41
41
|
import { allowedProps } from "./props.js";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["as", "elementRef", "overflow", "variant", "padding", "spacing", "children"];
|
|
3
|
+
var _dec, _class, _ModalBody;
|
|
4
|
+
/*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { Component } from 'react';
|
|
29
|
+
import { View } from '@instructure/ui-view/latest';
|
|
30
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
31
|
+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils';
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
|
+
import generateStyle from "./styles.js";
|
|
34
|
+
import { allowedProps } from "./props.js";
|
|
35
|
+
import ModalContext from "../ModalContext.js";
|
|
36
|
+
/**
|
|
37
|
+
---
|
|
38
|
+
parent: Modal
|
|
39
|
+
id: Modal.Body
|
|
40
|
+
---
|
|
41
|
+
**/
|
|
42
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
43
|
+
let ModalBody = (_dec = withStyle(generateStyle, 'ModalBody'), _dec(_class = (_ModalBody = class ModalBody extends Component {
|
|
44
|
+
constructor(props) {
|
|
45
|
+
super(props);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this.handleRef = el => {
|
|
48
|
+
const elementRef = this.props.elementRef;
|
|
49
|
+
this.ref = el;
|
|
50
|
+
if (typeof elementRef === 'function') {
|
|
51
|
+
elementRef(el);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
var _this$props$makeStyle, _this$props;
|
|
57
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
|
+
|
|
59
|
+
// We detect if -moz- prefixed style is present to identify whether we are in Firefox browser
|
|
60
|
+
const style = this.ref && getCSSStyleDeclaration(this.ref);
|
|
61
|
+
const isFirefox = !!(style && Array.prototype.slice.call(style).join('').match(/(?:-moz-)/));
|
|
62
|
+
if (isFirefox) {
|
|
63
|
+
this.setState({
|
|
64
|
+
isFirefox
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
componentDidUpdate() {
|
|
69
|
+
var _this$props$makeStyle2, _this$props2;
|
|
70
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
71
|
+
}
|
|
72
|
+
getFinalRef(el) {
|
|
73
|
+
if (!el) {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
if (el instanceof Element) {
|
|
77
|
+
return el;
|
|
78
|
+
}
|
|
79
|
+
if (el.ref) {
|
|
80
|
+
return this.getFinalRef(el.ref);
|
|
81
|
+
}
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
var _finalRef$scrollHeigh, _finalRef$getBounding, _finalRef$getBounding2;
|
|
86
|
+
const _this$props3 = this.props,
|
|
87
|
+
as = _this$props3.as,
|
|
88
|
+
elementRef = _this$props3.elementRef,
|
|
89
|
+
overflow = _this$props3.overflow,
|
|
90
|
+
variant = _this$props3.variant,
|
|
91
|
+
padding = _this$props3.padding,
|
|
92
|
+
spacing = _this$props3.spacing,
|
|
93
|
+
children = _this$props3.children,
|
|
94
|
+
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
95
|
+
const passthroughProps = View.omitViewProps(omitProps(rest, ModalBody.allowedProps), ModalBody);
|
|
96
|
+
const isFit = overflow === 'fit';
|
|
97
|
+
// this recursive function is needed because `ref` can be a React component.
|
|
98
|
+
// TODO rethink, the 'as' prop, likely its not a good idea to allow React
|
|
99
|
+
// components. See INSTUI-4674
|
|
100
|
+
const finalRef = this.getFinalRef(this.ref);
|
|
101
|
+
const hasScrollbar = finalRef && Math.abs(((_finalRef$scrollHeigh = finalRef.scrollHeight) !== null && _finalRef$scrollHeigh !== void 0 ? _finalRef$scrollHeigh : 0) - ((_finalRef$getBounding = (_finalRef$getBounding2 = finalRef.getBoundingClientRect()) === null || _finalRef$getBounding2 === void 0 ? void 0 : _finalRef$getBounding2.height) !== null && _finalRef$getBounding !== void 0 ? _finalRef$getBounding : 0)) > 1;
|
|
102
|
+
return _jsx(ModalContext.Consumer, {
|
|
103
|
+
children: value => {
|
|
104
|
+
var _this$props$styles;
|
|
105
|
+
return _jsx(View, {
|
|
106
|
+
...passthroughProps,
|
|
107
|
+
display: "block",
|
|
108
|
+
"data-cid": "ModalBody",
|
|
109
|
+
width: isFit ? '100%' : void 0,
|
|
110
|
+
height: isFit ? '100%' : void 0,
|
|
111
|
+
elementRef: this.handleRef,
|
|
112
|
+
as: as,
|
|
113
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.modalBody,
|
|
114
|
+
padding: spacing ? void 0 : padding
|
|
115
|
+
// check if there is a scrollbar, if so, the element has to be tabbable
|
|
116
|
+
,
|
|
117
|
+
...(hasScrollbar ? {
|
|
118
|
+
tabIndex: 0,
|
|
119
|
+
'aria-label': value.bodyScrollAriaLabel
|
|
120
|
+
} : {}),
|
|
121
|
+
children: children
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, _ModalBody.displayName = "ModalBody", _ModalBody.componentId = 'Modal.Body', _ModalBody.allowedProps = allowedProps, _ModalBody.defaultProps = {
|
|
127
|
+
padding: 'medium',
|
|
128
|
+
as: 'div',
|
|
129
|
+
variant: 'default'
|
|
130
|
+
}, _ModalBody)) || _class);
|
|
131
|
+
export default ModalBody;
|
|
132
|
+
export { ModalBody };
|
|
@@ -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 = ['children', 'padding', 'elementRef', 'as', 'variant', 'overflow', 'spacing'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} sharedTokens Shared theme token object
|
|
33
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
34
|
+
* @return {Object} The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = (componentTheme, props) => {
|
|
37
|
+
const variant = props.variant,
|
|
38
|
+
spacing = props.spacing;
|
|
39
|
+
const sizeVariants = {
|
|
40
|
+
default: {
|
|
41
|
+
padding: componentTheme.padding
|
|
42
|
+
},
|
|
43
|
+
compact: {
|
|
44
|
+
padding: componentTheme.paddingCompact
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const backgroundStyle = variant === 'inverse' ? {
|
|
48
|
+
background: componentTheme.inverseBackgroundColor
|
|
49
|
+
} : {};
|
|
50
|
+
return {
|
|
51
|
+
modalBody: {
|
|
52
|
+
label: 'modalBody',
|
|
53
|
+
borderRadius: 0,
|
|
54
|
+
boxSizing: 'border-box',
|
|
55
|
+
flex: '1 1 auto',
|
|
56
|
+
'&:focus': {
|
|
57
|
+
outline: 'none'
|
|
58
|
+
},
|
|
59
|
+
// ModalBody is set to scrollable above 20rem height
|
|
60
|
+
'@media (min-height: 20rem)': {
|
|
61
|
+
overflowY: 'auto'
|
|
62
|
+
},
|
|
63
|
+
...(spacing ? sizeVariants[spacing] : {}),
|
|
64
|
+
...backgroundStyle
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export default generateStyle;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { createContext } from 'react';
|
|
26
|
+
/**
|
|
27
|
+
* React context created by the `Modal` component
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
const ModalContext = /*#__PURE__*/createContext({
|
|
31
|
+
bodyScrollAriaLabel: void 0
|
|
32
|
+
});
|
|
33
|
+
export default ModalContext;
|
|
34
|
+
export { ModalContext };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["children"];
|
|
3
|
+
var _dec, _class, _ModalFooter;
|
|
4
|
+
/*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { Component } from 'react';
|
|
29
|
+
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
30
|
+
import { withStyle } from '@instructure/emotion';
|
|
31
|
+
import generateStyle from "./styles.js";
|
|
32
|
+
import { allowedProps } from "./props.js";
|
|
33
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
parent: Modal
|
|
37
|
+
id: Modal.Footer
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
let ModalFooter = (_dec = withStyle(generateStyle, 'ModalFooter'), _dec(_class = (_ModalFooter = class ModalFooter extends Component {
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
this.ref = null;
|
|
44
|
+
this.handleRef = el => {
|
|
45
|
+
this.ref = el;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
componentDidMount() {
|
|
49
|
+
var _this$props$makeStyle, _this$props;
|
|
50
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
51
|
+
}
|
|
52
|
+
componentDidUpdate() {
|
|
53
|
+
var _this$props$makeStyle2, _this$props2;
|
|
54
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
var _this$props$styles;
|
|
58
|
+
const _this$props3 = this.props,
|
|
59
|
+
children = _this$props3.children,
|
|
60
|
+
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
61
|
+
return _jsx("div", {
|
|
62
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.modalFooter,
|
|
63
|
+
...passthroughProps(rest),
|
|
64
|
+
ref: this.handleRef,
|
|
65
|
+
"data-cid": "ModalFooter",
|
|
66
|
+
children: children
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, _ModalFooter.displayName = "ModalFooter", _ModalFooter.componentId = 'Modal.Footer', _ModalFooter.allowedProps = allowedProps, _ModalFooter.defaultProps = {
|
|
70
|
+
variant: 'default'
|
|
71
|
+
}, _ModalFooter)) || _class);
|
|
72
|
+
export default ModalFooter;
|
|
73
|
+
export { ModalFooter };
|
|
@@ -21,4 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['children', 'variant', 'spacing'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} sharedTokens Shared theme token object
|
|
33
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
34
|
+
* @return {Object} The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = (componentTheme, props) => {
|
|
37
|
+
const variant = props.variant,
|
|
38
|
+
spacing = props.spacing;
|
|
39
|
+
const backgroundStyle = variant === 'inverse' ? {
|
|
40
|
+
background: componentTheme.inverseBackgroundColor,
|
|
41
|
+
borderTop: `${componentTheme.borderWidth} solid ${componentTheme.inverseBorderColor}`
|
|
42
|
+
} : {
|
|
43
|
+
background: componentTheme.backgroundColor,
|
|
44
|
+
borderTop: `${componentTheme.borderWidth} solid ${componentTheme.borderColor}`
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
modalFooter: {
|
|
48
|
+
label: 'modalFooter',
|
|
49
|
+
flex: '0 0 auto',
|
|
50
|
+
boxSizing: 'border-box',
|
|
51
|
+
padding: spacing === 'compact' ? componentTheme.paddingCompact : componentTheme.padding,
|
|
52
|
+
borderBottomRightRadius: componentTheme.borderRadius,
|
|
53
|
+
borderBottomLeftRadius: componentTheme.borderRadius,
|
|
54
|
+
display: 'flex',
|
|
55
|
+
justifyContent: 'flex-end',
|
|
56
|
+
...backgroundStyle
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export default generateStyle;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["children"];
|
|
3
|
+
var _dec, _class, _ModalHeader;
|
|
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 } from 'react';
|
|
29
|
+
import { matchComponentTypes, passthroughProps } from '@instructure/ui-react-utils';
|
|
30
|
+
import { withStyle } from '@instructure/emotion';
|
|
31
|
+
import { CloseButton } from '@instructure/ui-buttons/latest';
|
|
32
|
+
import generateStyle from "./styles.js";
|
|
33
|
+
import { allowedProps } from "./props.js";
|
|
34
|
+
import ModalContext from "../ModalContext.js";
|
|
35
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
36
|
+
/**
|
|
37
|
+
---
|
|
38
|
+
parent: Modal
|
|
39
|
+
id: Modal.Header
|
|
40
|
+
---
|
|
41
|
+
**/
|
|
42
|
+
let ModalHeader = (_dec = withStyle(generateStyle, 'ModalHeader'), _dec(_class = (_ModalHeader = class ModalHeader extends Component {
|
|
43
|
+
constructor(...args) {
|
|
44
|
+
super(...args);
|
|
45
|
+
this.ref = null;
|
|
46
|
+
/**
|
|
47
|
+
* Gets all text in a DOM subtree, text under <button> nodes is excluded
|
|
48
|
+
*/
|
|
49
|
+
this.getTextExcludingButtons = root => {
|
|
50
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
|
51
|
+
acceptNode(node) {
|
|
52
|
+
var _node$parentElement;
|
|
53
|
+
return (_node$parentElement = node.parentElement) !== null && _node$parentElement !== void 0 && _node$parentElement.closest('button') ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
let text = '';
|
|
57
|
+
let current;
|
|
58
|
+
while (current = walker.nextNode()) {
|
|
59
|
+
text += current.nodeValue;
|
|
60
|
+
}
|
|
61
|
+
return text;
|
|
62
|
+
};
|
|
63
|
+
this.handleRef = el => {
|
|
64
|
+
this.ref = el;
|
|
65
|
+
if (el) {
|
|
66
|
+
var _this$context$setBody, _this$context;
|
|
67
|
+
const txt = this.getTextExcludingButtons(el);
|
|
68
|
+
(_this$context$setBody = (_this$context = this.context).setBodyScrollAriaLabel) === null || _this$context$setBody === void 0 ? void 0 : _this$context$setBody.call(_this$context, txt);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
this.makeStyleProps = () => {
|
|
72
|
+
return {
|
|
73
|
+
withCloseButton: this.usesCloseButton
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
componentDidMount() {
|
|
78
|
+
var _this$props$makeStyle, _this$props;
|
|
79
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
80
|
+
}
|
|
81
|
+
componentDidUpdate() {
|
|
82
|
+
var _this$props$makeStyle2, _this$props2;
|
|
83
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
|
|
84
|
+
}
|
|
85
|
+
get usesCloseButton() {
|
|
86
|
+
let hasCloseButton = false;
|
|
87
|
+
Children.forEach(this.props.children, child => {
|
|
88
|
+
if (child && matchComponentTypes(child, [CloseButton])) {
|
|
89
|
+
hasCloseButton = true;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return hasCloseButton;
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
var _this$props$styles;
|
|
96
|
+
const _this$props3 = this.props,
|
|
97
|
+
children = _this$props3.children,
|
|
98
|
+
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
99
|
+
return _jsx("div", {
|
|
100
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.modalHeader,
|
|
101
|
+
...passthroughProps(rest),
|
|
102
|
+
ref: this.handleRef,
|
|
103
|
+
"data-cid": "ModalHeader",
|
|
104
|
+
children: children
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, _ModalHeader.displayName = "ModalHeader", _ModalHeader.componentId = 'Modal.Header', _ModalHeader.allowedProps = allowedProps, _ModalHeader.defaultProps = {
|
|
108
|
+
variant: 'default',
|
|
109
|
+
spacing: 'default'
|
|
110
|
+
}, _ModalHeader.contextType = ModalContext, _ModalHeader)) || _class);
|
|
111
|
+
export default ModalHeader;
|
|
112
|
+
export { ModalHeader };
|
|
@@ -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 = ['children', 'variant', 'spacing'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} _sharedTokens Shared theme token object (unused)
|
|
33
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
34
|
+
* @return {Object} The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = (componentTheme, props, _sharedTokens, state) => {
|
|
37
|
+
const variant = props.variant,
|
|
38
|
+
spacing = props.spacing;
|
|
39
|
+
const withCloseButton = state.withCloseButton;
|
|
40
|
+
const sizeVariants = {
|
|
41
|
+
default: {
|
|
42
|
+
padding: componentTheme.padding,
|
|
43
|
+
paddingInlineStart: componentTheme.padding,
|
|
44
|
+
paddingInlineEnd: withCloseButton ? `calc(${componentTheme.padding} * 2 + 1em)` : componentTheme.padding
|
|
45
|
+
},
|
|
46
|
+
compact: {
|
|
47
|
+
padding: componentTheme.paddingCompact,
|
|
48
|
+
paddingInlineStart: componentTheme.paddingCompact,
|
|
49
|
+
paddingInlineEnd: withCloseButton ? `calc(${componentTheme.paddingCompact} * 2 + 1em)` : componentTheme.paddingCompact
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const inverseStyle = variant === 'inverse' ? {
|
|
53
|
+
background: componentTheme.inverseBackgroundColor,
|
|
54
|
+
borderBottomColor: componentTheme.inverseBorderColor
|
|
55
|
+
} : {};
|
|
56
|
+
return {
|
|
57
|
+
modalHeader: {
|
|
58
|
+
borderTopLeftRadius: 'inherit',
|
|
59
|
+
borderTopRightRadius: 'inherit',
|
|
60
|
+
label: 'modalHeader',
|
|
61
|
+
boxSizing: 'border-box',
|
|
62
|
+
flex: '0 0 auto',
|
|
63
|
+
background: componentTheme.backgroundColor,
|
|
64
|
+
borderBottomWidth: componentTheme.borderWidth,
|
|
65
|
+
borderBottomStyle: 'solid',
|
|
66
|
+
borderBottomColor: componentTheme.borderColor,
|
|
67
|
+
...sizeVariants[spacing],
|
|
68
|
+
...inverseStyle,
|
|
69
|
+
// Position is set to relative for small viewports to ensure proper close button positioning during scrolling
|
|
70
|
+
'@media (max-height: 20rem)': {
|
|
71
|
+
position: 'relative'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export default generateStyle;
|