@instructure/ui-alerts 8.33.2-snapshot-0 → 8.33.2
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 +1 -5
- package/es/Alert/index.js +2 -44
- package/es/Alert/props.js +1 -0
- package/es/Alert/styles.js +1 -2
- package/es/Alert/theme.js +7 -7
- package/lib/Alert/index.js +2 -63
- package/lib/Alert/props.js +1 -4
- package/lib/Alert/styles.js +1 -3
- package/lib/Alert/theme.js +7 -8
- package/lib/index.js +0 -1
- package/package.json +16 -16
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.33.2
|
|
6
|
+
## [8.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-alerts
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
15
11
|
|
|
16
12
|
**Note:** Version bump only for package @instructure/ui-alerts
|
package/es/Alert/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,7 +22,6 @@ var _dec, _dec2, _class, _class2;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
25
|
/** @jsx jsx */
|
|
28
26
|
import React, { Component } from 'react';
|
|
29
27
|
import ReactDOM from 'react-dom';
|
|
@@ -39,7 +37,6 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
39
37
|
import generateStyle from './styles';
|
|
40
38
|
import generateComponentTheme from './theme';
|
|
41
39
|
import { propTypes, allowedProps } from './props';
|
|
42
|
-
|
|
43
40
|
/**
|
|
44
41
|
---
|
|
45
42
|
category: components
|
|
@@ -58,11 +55,9 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
58
55
|
warning: IconWarningBorderlessSolid
|
|
59
56
|
};
|
|
60
57
|
this.ref = null;
|
|
61
|
-
|
|
62
58
|
this.handleRef = el => {
|
|
63
59
|
this.ref = el;
|
|
64
60
|
};
|
|
65
|
-
|
|
66
61
|
this.handleTimeout = () => {
|
|
67
62
|
if (this.props.timeout > 0) {
|
|
68
63
|
this._timeouts.push(setTimeout(() => {
|
|
@@ -70,13 +65,11 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
70
65
|
}, this.props.timeout));
|
|
71
66
|
}
|
|
72
67
|
};
|
|
73
|
-
|
|
74
68
|
this.onExitTransition = () => {
|
|
75
69
|
if (this.props.onDismiss) {
|
|
76
70
|
this.props.onDismiss();
|
|
77
71
|
}
|
|
78
72
|
};
|
|
79
|
-
|
|
80
73
|
this.close = () => {
|
|
81
74
|
this.clearTimeouts();
|
|
82
75
|
this.removeScreenreaderAlert();
|
|
@@ -88,70 +81,54 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
88
81
|
}
|
|
89
82
|
});
|
|
90
83
|
};
|
|
91
|
-
|
|
92
84
|
this.handleKeyUp = event => {
|
|
93
85
|
if (this.props.renderCloseButtonLabel && event.keyCode === keycode.codes.esc) {
|
|
94
86
|
this.close();
|
|
95
87
|
}
|
|
96
88
|
};
|
|
97
|
-
|
|
98
89
|
this.srid = this.props.deterministicId();
|
|
99
90
|
this.state = {
|
|
100
91
|
open: true
|
|
101
92
|
};
|
|
102
93
|
}
|
|
103
|
-
|
|
104
94
|
clearTimeouts() {
|
|
105
95
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
106
|
-
|
|
107
96
|
this._timeouts = [];
|
|
108
97
|
}
|
|
109
|
-
|
|
110
98
|
// duck type for a dom node
|
|
111
99
|
isDOMNode(n) {
|
|
112
100
|
return n && typeof n === 'object' && n.nodeType === 1;
|
|
113
101
|
}
|
|
114
|
-
|
|
115
102
|
getLiveRegion() {
|
|
116
103
|
let lr = null;
|
|
117
|
-
|
|
118
104
|
if (typeof this.props.liveRegion === 'function') {
|
|
119
105
|
lr = this.props.liveRegion();
|
|
120
106
|
}
|
|
121
|
-
|
|
122
107
|
return this.isDOMNode(lr) ? lr : null;
|
|
123
108
|
}
|
|
124
|
-
|
|
125
109
|
initLiveRegion(liveRegion) {
|
|
126
110
|
error(liveRegion.getAttribute('role') === 'alert', `[Alert] live region must have role='alert' set on page load in order to announce content`);
|
|
127
|
-
|
|
128
111
|
if (liveRegion) {
|
|
129
112
|
liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness);
|
|
130
113
|
liveRegion.setAttribute('aria-relevant', 'additions text');
|
|
131
114
|
liveRegion.setAttribute('aria-atomic', `${this.props.isLiveRegionAtomic}`);
|
|
132
115
|
}
|
|
133
116
|
}
|
|
134
|
-
|
|
135
117
|
createScreenreaderContentNode() {
|
|
136
118
|
return jsx(ScreenReaderContent, null, this.props.children);
|
|
137
119
|
}
|
|
138
|
-
|
|
139
120
|
createScreenreaderAlert() {
|
|
140
121
|
const liveRegion = this.getLiveRegion();
|
|
141
|
-
|
|
142
122
|
if (liveRegion) {
|
|
143
123
|
const div = document.createElement('div');
|
|
144
124
|
div.setAttribute('id', this.srid);
|
|
145
125
|
liveRegion.appendChild(div);
|
|
146
126
|
}
|
|
147
127
|
}
|
|
148
|
-
|
|
149
128
|
removeScreenreaderAlert() {
|
|
150
129
|
const liveRegion = this.getLiveRegion();
|
|
151
|
-
|
|
152
130
|
if (liveRegion) {
|
|
153
131
|
const div = document.getElementById(this.srid);
|
|
154
|
-
|
|
155
132
|
if (div) {
|
|
156
133
|
// Accessibility attributes must be removed for the deletion of the node
|
|
157
134
|
// and then reapplied because JAWS/IE will not respect the
|
|
@@ -164,48 +141,36 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
164
141
|
}
|
|
165
142
|
}
|
|
166
143
|
}
|
|
167
|
-
|
|
168
144
|
componentDidMount() {
|
|
169
145
|
var _this$props$makeStyle, _this$props;
|
|
170
|
-
|
|
171
146
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
172
147
|
const liveRegion = this.getLiveRegion();
|
|
173
|
-
|
|
174
148
|
if (liveRegion) {
|
|
175
149
|
this.initLiveRegion(liveRegion);
|
|
176
150
|
}
|
|
177
|
-
|
|
178
151
|
this.handleTimeout();
|
|
179
152
|
}
|
|
180
|
-
|
|
181
153
|
componentWillUnmount() {
|
|
182
154
|
this.clearTimeouts();
|
|
183
155
|
}
|
|
184
|
-
|
|
185
156
|
componentDidUpdate(prevProps) {
|
|
186
157
|
var _this$props$makeStyle2, _this$props2;
|
|
187
|
-
|
|
188
158
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
189
|
-
|
|
190
159
|
if (!!this.props.open === false && !!this.props.open !== !!prevProps.open) {
|
|
191
160
|
// this outside world is asking us to close the alert, which needs to
|
|
192
161
|
// take place internally so the transition runs
|
|
193
162
|
this.close();
|
|
194
163
|
}
|
|
195
164
|
}
|
|
196
|
-
|
|
197
165
|
renderIcon() {
|
|
198
166
|
var _this$props$styles;
|
|
199
|
-
|
|
200
167
|
const Icon = this.variantUI[this.props.variant];
|
|
201
168
|
return jsx("div", {
|
|
202
169
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
203
170
|
}, jsx(Icon, null));
|
|
204
171
|
}
|
|
205
|
-
|
|
206
172
|
renderCloseButton() {
|
|
207
173
|
var _this$props$styles2;
|
|
208
|
-
|
|
209
174
|
const closeButtonLabel = this.props.renderCloseButtonLabel && callRenderProp(this.props.renderCloseButtonLabel);
|
|
210
175
|
return closeButtonLabel ? jsx("div", {
|
|
211
176
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.closeButton,
|
|
@@ -216,10 +181,8 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
216
181
|
screenReaderLabel: closeButtonLabel
|
|
217
182
|
})) : null;
|
|
218
183
|
}
|
|
219
|
-
|
|
220
184
|
renderAlert() {
|
|
221
185
|
var _this$props$styles3, _this$props$styles4;
|
|
222
|
-
|
|
223
186
|
return jsx(View, {
|
|
224
187
|
as: "div",
|
|
225
188
|
margin: this.props.margin,
|
|
@@ -230,27 +193,23 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
230
193
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.content
|
|
231
194
|
}, this.props.children), this.renderCloseButton());
|
|
232
195
|
}
|
|
233
|
-
|
|
234
196
|
createScreenReaderPortal(liveRegion) {
|
|
235
197
|
const open = this.state.open;
|
|
236
198
|
return open ? /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
|
|
237
199
|
id: this.srid
|
|
238
200
|
}, this.createScreenreaderContentNode()), liveRegion) : null;
|
|
239
201
|
}
|
|
240
|
-
|
|
241
202
|
render() {
|
|
242
203
|
const liveRegion = this.getLiveRegion();
|
|
243
|
-
const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
|
|
244
|
-
|
|
204
|
+
const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
|
|
205
|
+
// Don't render anything if screen reader only
|
|
245
206
|
if (this.props.screenReaderOnly) {
|
|
246
207
|
error(!!this.getLiveRegion(), `[Alert] The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'.`);
|
|
247
208
|
return screenReaderContent;
|
|
248
209
|
}
|
|
249
|
-
|
|
250
210
|
if (this.props.transition === 'none') {
|
|
251
211
|
return this.state.open ? jsx(React.Fragment, null, screenReaderContent, this.renderAlert()) : null;
|
|
252
212
|
}
|
|
253
|
-
|
|
254
213
|
return jsx(React.Fragment, null, screenReaderContent, jsx(Transition, {
|
|
255
214
|
type: this.props.transition,
|
|
256
215
|
transitionOnMount: true,
|
|
@@ -259,7 +218,6 @@ let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gene
|
|
|
259
218
|
onExited: this.onExitTransition
|
|
260
219
|
}, this.renderAlert()));
|
|
261
220
|
}
|
|
262
|
-
|
|
263
221
|
}, _class2.displayName = "Alert", _class2.componentId = 'Alert', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
264
222
|
variant: 'info',
|
|
265
223
|
margin: 'x-small 0',
|
package/es/Alert/props.js
CHANGED
package/es/Alert/styles.js
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const variant = props.variant,
|
|
37
|
-
|
|
37
|
+
hasShadow = props.hasShadow;
|
|
38
38
|
const variantStyles = {
|
|
39
39
|
error: {
|
|
40
40
|
alert: {
|
|
@@ -120,5 +120,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
|
-
|
|
124
123
|
export default generateStyle;
|
package/es/Alert/theme.js
CHANGED
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
spacing = theme.spacing,
|
|
33
|
+
borders = theme.borders,
|
|
34
|
+
typography = theme.typography,
|
|
35
|
+
shadows = theme.shadows,
|
|
36
|
+
themeName = theme.key;
|
|
37
37
|
const themeSpecificStyle = {
|
|
38
38
|
canvas: {
|
|
39
39
|
color: theme['ic-brand-font-color-dark']
|
|
@@ -64,9 +64,9 @@ const generateComponentTheme = theme => {
|
|
|
64
64
|
dangerIconBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundDanger,
|
|
65
65
|
boxShadow: shadows === null || shadows === void 0 ? void 0 : shadows.depth2
|
|
66
66
|
};
|
|
67
|
-
return {
|
|
67
|
+
return {
|
|
68
|
+
...componentVariables,
|
|
68
69
|
...themeSpecificStyle[themeName]
|
|
69
70
|
};
|
|
70
71
|
};
|
|
71
|
-
|
|
72
72
|
export default generateComponentTheme;
|
package/lib/Alert/index.js
CHANGED
|
@@ -1,52 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.Alert = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
15
|
-
|
|
16
11
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
17
|
-
|
|
18
12
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
19
|
-
|
|
20
13
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
21
|
-
|
|
22
14
|
var _CloseButton = require("@instructure/ui-buttons/lib/CloseButton");
|
|
23
|
-
|
|
24
15
|
var _View = require("@instructure/ui-view/lib/View");
|
|
25
|
-
|
|
26
16
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
27
|
-
|
|
28
17
|
var _IconCheckMarkSolid = require("@instructure/ui-icons/lib/IconCheckMarkSolid.js");
|
|
29
|
-
|
|
30
18
|
var _IconInfoBorderlessSolid = require("@instructure/ui-icons/lib/IconInfoBorderlessSolid.js");
|
|
31
|
-
|
|
32
19
|
var _IconWarningBorderlessSolid = require("@instructure/ui-icons/lib/IconWarningBorderlessSolid.js");
|
|
33
|
-
|
|
34
20
|
var _IconNoSolid = require("@instructure/ui-icons/lib/IconNoSolid.js");
|
|
35
|
-
|
|
36
21
|
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
37
|
-
|
|
38
22
|
var _console = require("@instructure/console");
|
|
39
|
-
|
|
40
23
|
var _emotion = require("@instructure/emotion");
|
|
41
|
-
|
|
42
24
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
43
|
-
|
|
44
25
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
45
|
-
|
|
46
26
|
var _props = require("./props");
|
|
47
|
-
|
|
48
27
|
var _dec, _dec2, _class, _class2;
|
|
49
|
-
|
|
50
28
|
/**
|
|
51
29
|
---
|
|
52
30
|
category: components
|
|
@@ -65,11 +43,9 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
65
43
|
warning: _IconWarningBorderlessSolid.IconWarningBorderlessSolid
|
|
66
44
|
};
|
|
67
45
|
this.ref = null;
|
|
68
|
-
|
|
69
46
|
this.handleRef = el => {
|
|
70
47
|
this.ref = el;
|
|
71
48
|
};
|
|
72
|
-
|
|
73
49
|
this.handleTimeout = () => {
|
|
74
50
|
if (this.props.timeout > 0) {
|
|
75
51
|
this._timeouts.push(setTimeout(() => {
|
|
@@ -77,13 +53,11 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
77
53
|
}, this.props.timeout));
|
|
78
54
|
}
|
|
79
55
|
};
|
|
80
|
-
|
|
81
56
|
this.onExitTransition = () => {
|
|
82
57
|
if (this.props.onDismiss) {
|
|
83
58
|
this.props.onDismiss();
|
|
84
59
|
}
|
|
85
60
|
};
|
|
86
|
-
|
|
87
61
|
this.close = () => {
|
|
88
62
|
this.clearTimeouts();
|
|
89
63
|
this.removeScreenreaderAlert();
|
|
@@ -95,70 +69,54 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
95
69
|
}
|
|
96
70
|
});
|
|
97
71
|
};
|
|
98
|
-
|
|
99
72
|
this.handleKeyUp = event => {
|
|
100
73
|
if (this.props.renderCloseButtonLabel && event.keyCode === _keycode.default.codes.esc) {
|
|
101
74
|
this.close();
|
|
102
75
|
}
|
|
103
76
|
};
|
|
104
|
-
|
|
105
77
|
this.srid = this.props.deterministicId();
|
|
106
78
|
this.state = {
|
|
107
79
|
open: true
|
|
108
80
|
};
|
|
109
81
|
}
|
|
110
|
-
|
|
111
82
|
clearTimeouts() {
|
|
112
83
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
113
|
-
|
|
114
84
|
this._timeouts = [];
|
|
115
85
|
}
|
|
116
|
-
|
|
117
86
|
// duck type for a dom node
|
|
118
87
|
isDOMNode(n) {
|
|
119
88
|
return n && typeof n === 'object' && n.nodeType === 1;
|
|
120
89
|
}
|
|
121
|
-
|
|
122
90
|
getLiveRegion() {
|
|
123
91
|
let lr = null;
|
|
124
|
-
|
|
125
92
|
if (typeof this.props.liveRegion === 'function') {
|
|
126
93
|
lr = this.props.liveRegion();
|
|
127
94
|
}
|
|
128
|
-
|
|
129
95
|
return this.isDOMNode(lr) ? lr : null;
|
|
130
96
|
}
|
|
131
|
-
|
|
132
97
|
initLiveRegion(liveRegion) {
|
|
133
98
|
(0, _console.logError)(liveRegion.getAttribute('role') === 'alert', `[Alert] live region must have role='alert' set on page load in order to announce content`);
|
|
134
|
-
|
|
135
99
|
if (liveRegion) {
|
|
136
100
|
liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness);
|
|
137
101
|
liveRegion.setAttribute('aria-relevant', 'additions text');
|
|
138
102
|
liveRegion.setAttribute('aria-atomic', `${this.props.isLiveRegionAtomic}`);
|
|
139
103
|
}
|
|
140
104
|
}
|
|
141
|
-
|
|
142
105
|
createScreenreaderContentNode() {
|
|
143
106
|
return (0, _emotion.jsx)(_ScreenReaderContent.ScreenReaderContent, null, this.props.children);
|
|
144
107
|
}
|
|
145
|
-
|
|
146
108
|
createScreenreaderAlert() {
|
|
147
109
|
const liveRegion = this.getLiveRegion();
|
|
148
|
-
|
|
149
110
|
if (liveRegion) {
|
|
150
111
|
const div = document.createElement('div');
|
|
151
112
|
div.setAttribute('id', this.srid);
|
|
152
113
|
liveRegion.appendChild(div);
|
|
153
114
|
}
|
|
154
115
|
}
|
|
155
|
-
|
|
156
116
|
removeScreenreaderAlert() {
|
|
157
117
|
const liveRegion = this.getLiveRegion();
|
|
158
|
-
|
|
159
118
|
if (liveRegion) {
|
|
160
119
|
const div = document.getElementById(this.srid);
|
|
161
|
-
|
|
162
120
|
if (div) {
|
|
163
121
|
// Accessibility attributes must be removed for the deletion of the node
|
|
164
122
|
// and then reapplied because JAWS/IE will not respect the
|
|
@@ -171,48 +129,36 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
171
129
|
}
|
|
172
130
|
}
|
|
173
131
|
}
|
|
174
|
-
|
|
175
132
|
componentDidMount() {
|
|
176
133
|
var _this$props$makeStyle, _this$props;
|
|
177
|
-
|
|
178
134
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
179
135
|
const liveRegion = this.getLiveRegion();
|
|
180
|
-
|
|
181
136
|
if (liveRegion) {
|
|
182
137
|
this.initLiveRegion(liveRegion);
|
|
183
138
|
}
|
|
184
|
-
|
|
185
139
|
this.handleTimeout();
|
|
186
140
|
}
|
|
187
|
-
|
|
188
141
|
componentWillUnmount() {
|
|
189
142
|
this.clearTimeouts();
|
|
190
143
|
}
|
|
191
|
-
|
|
192
144
|
componentDidUpdate(prevProps) {
|
|
193
145
|
var _this$props$makeStyle2, _this$props2;
|
|
194
|
-
|
|
195
146
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
196
|
-
|
|
197
147
|
if (!!this.props.open === false && !!this.props.open !== !!prevProps.open) {
|
|
198
148
|
// this outside world is asking us to close the alert, which needs to
|
|
199
149
|
// take place internally so the transition runs
|
|
200
150
|
this.close();
|
|
201
151
|
}
|
|
202
152
|
}
|
|
203
|
-
|
|
204
153
|
renderIcon() {
|
|
205
154
|
var _this$props$styles;
|
|
206
|
-
|
|
207
155
|
const Icon = this.variantUI[this.props.variant];
|
|
208
156
|
return (0, _emotion.jsx)("div", {
|
|
209
157
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
210
158
|
}, (0, _emotion.jsx)(Icon, null));
|
|
211
159
|
}
|
|
212
|
-
|
|
213
160
|
renderCloseButton() {
|
|
214
161
|
var _this$props$styles2;
|
|
215
|
-
|
|
216
162
|
const closeButtonLabel = this.props.renderCloseButtonLabel && (0, _callRenderProp.callRenderProp)(this.props.renderCloseButtonLabel);
|
|
217
163
|
return closeButtonLabel ? (0, _emotion.jsx)("div", {
|
|
218
164
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.closeButton,
|
|
@@ -223,10 +169,8 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
223
169
|
screenReaderLabel: closeButtonLabel
|
|
224
170
|
})) : null;
|
|
225
171
|
}
|
|
226
|
-
|
|
227
172
|
renderAlert() {
|
|
228
173
|
var _this$props$styles3, _this$props$styles4;
|
|
229
|
-
|
|
230
174
|
return (0, _emotion.jsx)(_View.View, {
|
|
231
175
|
as: "div",
|
|
232
176
|
margin: this.props.margin,
|
|
@@ -237,27 +181,23 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
237
181
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.content
|
|
238
182
|
}, this.props.children), this.renderCloseButton());
|
|
239
183
|
}
|
|
240
|
-
|
|
241
184
|
createScreenReaderPortal(liveRegion) {
|
|
242
185
|
const open = this.state.open;
|
|
243
186
|
return open ? /*#__PURE__*/_reactDom.default.createPortal((0, _emotion.jsx)("div", {
|
|
244
187
|
id: this.srid
|
|
245
188
|
}, this.createScreenreaderContentNode()), liveRegion) : null;
|
|
246
189
|
}
|
|
247
|
-
|
|
248
190
|
render() {
|
|
249
191
|
const liveRegion = this.getLiveRegion();
|
|
250
|
-
const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
|
|
251
|
-
|
|
192
|
+
const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
|
|
193
|
+
// Don't render anything if screen reader only
|
|
252
194
|
if (this.props.screenReaderOnly) {
|
|
253
195
|
(0, _console.logError)(!!this.getLiveRegion(), `[Alert] The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'.`);
|
|
254
196
|
return screenReaderContent;
|
|
255
197
|
}
|
|
256
|
-
|
|
257
198
|
if (this.props.transition === 'none') {
|
|
258
199
|
return this.state.open ? (0, _emotion.jsx)(_react.default.Fragment, null, screenReaderContent, this.renderAlert()) : null;
|
|
259
200
|
}
|
|
260
|
-
|
|
261
201
|
return (0, _emotion.jsx)(_react.default.Fragment, null, screenReaderContent, (0, _emotion.jsx)(_Transition.Transition, {
|
|
262
202
|
type: this.props.transition,
|
|
263
203
|
transitionOnMount: true,
|
|
@@ -266,7 +206,6 @@ let Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
266
206
|
onExited: this.onExitTransition
|
|
267
207
|
}, this.renderAlert()));
|
|
268
208
|
}
|
|
269
|
-
|
|
270
209
|
}, _class2.displayName = "Alert", _class2.componentId = 'Alert', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
271
210
|
variant: 'info',
|
|
272
211
|
margin: 'x-small 0',
|
package/lib/Alert/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
children: _propTypes.default.node,
|
|
39
36
|
variant: _propTypes.default.oneOf(['info', 'success', 'warning', 'error']),
|
package/lib/Alert/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,7 +40,7 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const variant = props.variant,
|
|
44
|
-
|
|
43
|
+
hasShadow = props.hasShadow;
|
|
45
44
|
const variantStyles = {
|
|
46
45
|
error: {
|
|
47
46
|
alert: {
|
|
@@ -127,6 +126,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
127
126
|
}
|
|
128
127
|
};
|
|
129
128
|
};
|
|
130
|
-
|
|
131
129
|
var _default = generateStyle;
|
|
132
130
|
exports.default = _default;
|
package/lib/Alert/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,11 +35,11 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
spacing = theme.spacing,
|
|
39
|
+
borders = theme.borders,
|
|
40
|
+
typography = theme.typography,
|
|
41
|
+
shadows = theme.shadows,
|
|
42
|
+
themeName = theme.key;
|
|
44
43
|
const themeSpecificStyle = {
|
|
45
44
|
canvas: {
|
|
46
45
|
color: theme['ic-brand-font-color-dark']
|
|
@@ -71,10 +70,10 @@ const generateComponentTheme = theme => {
|
|
|
71
70
|
dangerIconBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundDanger,
|
|
72
71
|
boxShadow: shadows === null || shadows === void 0 ? void 0 : shadows.depth2
|
|
73
72
|
};
|
|
74
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
...componentVariables,
|
|
75
75
|
...themeSpecificStyle[themeName]
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
-
|
|
79
78
|
var _default = generateComponentTheme;
|
|
80
79
|
exports.default = _default;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-alerts",
|
|
3
|
-
"version": "8.33.2
|
|
3
|
+
"version": "8.33.2",
|
|
4
4
|
"description": "An alert component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.33.2
|
|
27
|
-
"@instructure/ui-color-utils": "8.33.2
|
|
28
|
-
"@instructure/ui-test-utils": "8.33.2
|
|
26
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
27
|
+
"@instructure/ui-color-utils": "8.33.2",
|
|
28
|
+
"@instructure/ui-test-utils": "8.33.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.13.10",
|
|
32
|
-
"@instructure/console": "8.33.2
|
|
33
|
-
"@instructure/emotion": "8.33.2
|
|
34
|
-
"@instructure/shared-types": "8.33.2
|
|
35
|
-
"@instructure/ui-a11y-content": "8.33.2
|
|
36
|
-
"@instructure/ui-buttons": "8.33.2
|
|
37
|
-
"@instructure/ui-icons": "8.33.2
|
|
38
|
-
"@instructure/ui-motion": "8.33.2
|
|
39
|
-
"@instructure/ui-react-utils": "8.33.2
|
|
40
|
-
"@instructure/ui-themes": "8.33.2
|
|
41
|
-
"@instructure/ui-utils": "8.33.2
|
|
42
|
-
"@instructure/ui-view": "8.33.2
|
|
43
|
-
"@instructure/uid": "8.33.2
|
|
32
|
+
"@instructure/console": "8.33.2",
|
|
33
|
+
"@instructure/emotion": "8.33.2",
|
|
34
|
+
"@instructure/shared-types": "8.33.2",
|
|
35
|
+
"@instructure/ui-a11y-content": "8.33.2",
|
|
36
|
+
"@instructure/ui-buttons": "8.33.2",
|
|
37
|
+
"@instructure/ui-icons": "8.33.2",
|
|
38
|
+
"@instructure/ui-motion": "8.33.2",
|
|
39
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
40
|
+
"@instructure/ui-themes": "8.33.2",
|
|
41
|
+
"@instructure/ui-utils": "8.33.2",
|
|
42
|
+
"@instructure/ui-view": "8.33.2",
|
|
43
|
+
"@instructure/uid": "8.33.2",
|
|
44
44
|
"keycode": "^2",
|
|
45
45
|
"prop-types": "^15"
|
|
46
46
|
},
|