@instructure/ui-alerts 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 +36 -295
- package/es/Alert/{index.js → v1/index.js} +3 -3
- package/es/Alert/v2/index.js +263 -0
- package/es/Alert/v2/props.js +26 -0
- package/es/Alert/v2/styles.js +134 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -2
- package/lib/Alert/{index.js → v1/index.js} +9 -9
- package/lib/Alert/v2/index.js +270 -0
- package/lib/Alert/v2/props.js +31 -0
- package/lib/Alert/v2/styles.js +140 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +44 -22
- package/src/Alert/{index.tsx → v1/index.tsx} +4 -4
- package/src/Alert/v2/README.md +249 -0
- package/src/Alert/v2/index.tsx +349 -0
- package/src/Alert/v2/props.ts +148 -0
- package/src/Alert/v2/styles.ts +137 -0
- package/src/exports/a.ts +25 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Alert/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Alert/v1/index.d.ts.map +1 -0
- package/types/Alert/v1/props.d.ts.map +1 -0
- package/types/Alert/v1/styles.d.ts.map +1 -0
- package/types/Alert/v1/theme.d.ts.map +1 -0
- package/types/Alert/v2/index.d.ts +73 -0
- package/types/Alert/v2/index.d.ts.map +1 -0
- package/types/Alert/v2/props.d.ts +92 -0
- package/types/Alert/v2/props.d.ts.map +1 -0
- package/types/Alert/v2/styles.d.ts +15 -0
- package/types/Alert/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Alert/index.d.ts.map +0 -1
- package/types/Alert/props.d.ts.map +0 -1
- package/types/Alert/styles.d.ts.map +0 -1
- package/types/Alert/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Alert/{props.js → v1/props.js} +0 -0
- /package/es/Alert/{styles.js → v1/styles.js} +0 -0
- /package/es/Alert/{theme.js → v1/theme.js} +0 -0
- /package/lib/Alert/{props.js → v1/props.js} +0 -0
- /package/lib/Alert/{styles.js → v1/styles.js} +0 -0
- /package/lib/Alert/{theme.js → v1/theme.js} +0 -0
- /package/src/Alert/{README.md → v1/README.md} +0 -0
- /package/src/Alert/{props.ts → v1/props.ts} +0 -0
- /package/src/Alert/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Alert/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Alert/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Alert/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Alert/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Alert = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
+
var _keycode = _interopRequireDefault(require("keycode"));
|
|
12
|
+
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
13
|
+
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
14
|
+
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
15
|
+
var _latest = require("@instructure/ui-buttons/latest");
|
|
16
|
+
var _latest2 = require("@instructure/ui-view/latest");
|
|
17
|
+
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
18
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
19
|
+
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
20
|
+
var _console = require("@instructure/console");
|
|
21
|
+
var _emotion = require("@instructure/emotion");
|
|
22
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
+
var _props = require("./props");
|
|
24
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
25
|
+
const _excluded = ["margin", "styles", "children", "onDismiss", "variantScreenReaderLabel"];
|
|
26
|
+
var _dec, _dec2, _class, _Alert;
|
|
27
|
+
/*
|
|
28
|
+
* The MIT License (MIT)
|
|
29
|
+
*
|
|
30
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
31
|
+
*
|
|
32
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
* in the Software without restriction, including without limitation the rights
|
|
35
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
* furnished to do so, subject to the following conditions:
|
|
38
|
+
*
|
|
39
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
* copies or substantial portions of the Software.
|
|
41
|
+
*
|
|
42
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
* SOFTWARE.
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
---
|
|
52
|
+
category: components
|
|
53
|
+
---
|
|
54
|
+
**/
|
|
55
|
+
let Alert = exports.Alert = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = (_Alert = class Alert extends _react.Component {
|
|
56
|
+
constructor(props) {
|
|
57
|
+
super(props);
|
|
58
|
+
this._timeouts = [];
|
|
59
|
+
this.srid = void 0;
|
|
60
|
+
this.variantUI = {
|
|
61
|
+
error: _uiIcons.XCircleInstUIIcon,
|
|
62
|
+
info: _uiIcons.InfoInstUIIcon,
|
|
63
|
+
success: _uiIcons.CircleCheckInstUIIcon,
|
|
64
|
+
warning: _uiIcons.TriangleAlertInstUIIcon
|
|
65
|
+
};
|
|
66
|
+
this.ref = null;
|
|
67
|
+
this.handleRef = el => {
|
|
68
|
+
this.ref = el;
|
|
69
|
+
};
|
|
70
|
+
this.handleTimeout = () => {
|
|
71
|
+
if (this.props.timeout > 0) {
|
|
72
|
+
this._timeouts.push(setTimeout(() => {
|
|
73
|
+
this.close();
|
|
74
|
+
}, this.props.timeout));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.onExitTransition = () => {
|
|
78
|
+
if (this.props.onDismiss) {
|
|
79
|
+
this.props.onDismiss();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
this.close = () => {
|
|
83
|
+
this.clearTimeouts();
|
|
84
|
+
this.removeScreenreaderAlert();
|
|
85
|
+
this.setState({
|
|
86
|
+
open: false
|
|
87
|
+
}, () => {
|
|
88
|
+
if (this.props.onDismiss && (this.props.transition === 'none' || this.props.screenReaderOnly)) {
|
|
89
|
+
this.props.onDismiss();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
this.handleKeyUp = event => {
|
|
94
|
+
if (this.props.renderCloseButtonLabel && event.keyCode === _keycode.default.codes.esc) {
|
|
95
|
+
this.close();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this.srid = this.props.deterministicId();
|
|
99
|
+
this.state = {
|
|
100
|
+
open: true
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
clearTimeouts() {
|
|
104
|
+
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
105
|
+
this._timeouts = [];
|
|
106
|
+
}
|
|
107
|
+
// duck type for a dom node
|
|
108
|
+
isDOMNode(n) {
|
|
109
|
+
return n && typeof n === 'object' && n.nodeType === 1;
|
|
110
|
+
}
|
|
111
|
+
getLiveRegion() {
|
|
112
|
+
const lr = typeof this.props.liveRegion === 'function' ? this.props.liveRegion() : this.props.liveRegion;
|
|
113
|
+
return this.isDOMNode(lr) ? lr : null;
|
|
114
|
+
}
|
|
115
|
+
initLiveRegion(liveRegion) {
|
|
116
|
+
(0, _console.logError)(liveRegion.getAttribute('role') === 'alert', `[Alert] live region must have role='alert' set on page load in order to announce content`);
|
|
117
|
+
if (liveRegion) {
|
|
118
|
+
liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness);
|
|
119
|
+
// indicates what notifications the user agent will trigger when the
|
|
120
|
+
// accessibility tree within a live region is modified.
|
|
121
|
+
// additions: elements are added, text: Text content is added
|
|
122
|
+
liveRegion.setAttribute('aria-relevant', 'additions text');
|
|
123
|
+
liveRegion.setAttribute('aria-atomic', `${this.props.isLiveRegionAtomic}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
createScreenreaderContentNode() {
|
|
127
|
+
return (0, _jsxRuntime.jsxs)(_ScreenReaderContent.ScreenReaderContent, {
|
|
128
|
+
children: [this.props.variantScreenReaderLabel || '', " ", this.props.children]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
createScreenreaderAlert() {
|
|
132
|
+
const liveRegion = this.getLiveRegion();
|
|
133
|
+
if (liveRegion) {
|
|
134
|
+
const div = document.createElement('div');
|
|
135
|
+
div.setAttribute('id', this.srid);
|
|
136
|
+
liveRegion.appendChild(div);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
removeScreenreaderAlert() {
|
|
140
|
+
const liveRegion = this.getLiveRegion();
|
|
141
|
+
if (liveRegion) {
|
|
142
|
+
const div = document.getElementById(this.srid);
|
|
143
|
+
if (div) {
|
|
144
|
+
// Accessibility attributes must be removed for the deletion of the node
|
|
145
|
+
// and then reapplied because JAWS/IE will not respect the
|
|
146
|
+
// "aria-relevant" attribute and read when the node is deleted if
|
|
147
|
+
// the attributes are in place
|
|
148
|
+
liveRegion.removeAttribute('aria-live');
|
|
149
|
+
liveRegion.removeAttribute('aria-relevant');
|
|
150
|
+
liveRegion.removeAttribute('aria-atomic');
|
|
151
|
+
this.initLiveRegion(liveRegion);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
componentDidMount() {
|
|
156
|
+
var _this$props$makeStyle, _this$props;
|
|
157
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
158
|
+
const liveRegion = this.getLiveRegion();
|
|
159
|
+
if (liveRegion) {
|
|
160
|
+
this.initLiveRegion(liveRegion);
|
|
161
|
+
}
|
|
162
|
+
this.handleTimeout();
|
|
163
|
+
}
|
|
164
|
+
componentWillUnmount() {
|
|
165
|
+
this.clearTimeouts();
|
|
166
|
+
}
|
|
167
|
+
componentDidUpdate(prevProps) {
|
|
168
|
+
var _this$props$makeStyle2, _this$props2;
|
|
169
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
170
|
+
if (!!this.props.open === false && !!this.props.open !== !!prevProps.open) {
|
|
171
|
+
// this outside world is asking us to close the alert, which needs to
|
|
172
|
+
// take place internally so the transition runs
|
|
173
|
+
this.close();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
renderIcon() {
|
|
177
|
+
const _this$props3 = this.props,
|
|
178
|
+
renderCustomIcon = _this$props3.renderCustomIcon,
|
|
179
|
+
variant = _this$props3.variant,
|
|
180
|
+
styles = _this$props3.styles;
|
|
181
|
+
const Icon = this.variantUI[variant];
|
|
182
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
183
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
184
|
+
children: renderCustomIcon ? (0, _callRenderProp.callRenderProp)(renderCustomIcon) : (0, _jsxRuntime.jsx)(Icon, {})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
renderCloseButton() {
|
|
188
|
+
var _this$props$styles;
|
|
189
|
+
const closeButtonLabel = this.props.renderCloseButtonLabel && (0, _callRenderProp.callRenderProp)(this.props.renderCloseButtonLabel);
|
|
190
|
+
return closeButtonLabel ? (0, _jsxRuntime.jsx)("div", {
|
|
191
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.closeButton,
|
|
192
|
+
children: (0, _jsxRuntime.jsx)(_latest.CloseButton, {
|
|
193
|
+
onClick: this.close,
|
|
194
|
+
size: "small",
|
|
195
|
+
screenReaderLabel: closeButtonLabel
|
|
196
|
+
})
|
|
197
|
+
}, "closeButton") : null;
|
|
198
|
+
}
|
|
199
|
+
renderAlert() {
|
|
200
|
+
// prevent onDismiss from being passed to the View component
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
|
+
const _this$props4 = this.props,
|
|
203
|
+
margin = _this$props4.margin,
|
|
204
|
+
styles = _this$props4.styles,
|
|
205
|
+
children = _this$props4.children,
|
|
206
|
+
onDismiss = _this$props4.onDismiss,
|
|
207
|
+
variantScreenReaderLabel = _this$props4.variantScreenReaderLabel,
|
|
208
|
+
props = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
|
|
209
|
+
return (0, _jsxRuntime.jsxs)(_latest2.View, {
|
|
210
|
+
...(0, _passthroughProps.passthroughProps)({
|
|
211
|
+
...props
|
|
212
|
+
}),
|
|
213
|
+
as: "div",
|
|
214
|
+
margin: margin,
|
|
215
|
+
css: styles === null || styles === void 0 ? void 0 : styles.alert,
|
|
216
|
+
onKeyUp: this.handleKeyUp,
|
|
217
|
+
elementRef: this.handleRef,
|
|
218
|
+
children: [this.renderIcon(), (0, _jsxRuntime.jsxs)("div", {
|
|
219
|
+
css: styles === null || styles === void 0 ? void 0 : styles.content,
|
|
220
|
+
children: [variantScreenReaderLabel && (0, _jsxRuntime.jsx)("span", {
|
|
221
|
+
css: styles === null || styles === void 0 ? void 0 : styles.variantScreenReaderLabel,
|
|
222
|
+
children: variantScreenReaderLabel
|
|
223
|
+
}), children]
|
|
224
|
+
}), this.renderCloseButton()]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
createScreenReaderPortal(liveRegion) {
|
|
228
|
+
const open = this.state.open;
|
|
229
|
+
return open ? /*#__PURE__*/_reactDom.default.createPortal((0, _jsxRuntime.jsx)("div", {
|
|
230
|
+
id: this.srid,
|
|
231
|
+
children: this.createScreenreaderContentNode()
|
|
232
|
+
}), liveRegion) : null;
|
|
233
|
+
}
|
|
234
|
+
render() {
|
|
235
|
+
const liveRegion = this.getLiveRegion();
|
|
236
|
+
const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
|
|
237
|
+
// Don't render anything if screen reader only
|
|
238
|
+
if (this.props.screenReaderOnly) {
|
|
239
|
+
(0, _console.logError)(!!this.getLiveRegion(), `[Alert] The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'.`);
|
|
240
|
+
return screenReaderContent;
|
|
241
|
+
}
|
|
242
|
+
if (this.props.transition === 'none') {
|
|
243
|
+
return this.state.open ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
244
|
+
children: [screenReaderContent, this.renderAlert()]
|
|
245
|
+
}) : null;
|
|
246
|
+
}
|
|
247
|
+
return (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
248
|
+
children: [screenReaderContent, (0, _jsxRuntime.jsx)(_Transition.Transition, {
|
|
249
|
+
type: this.props.transition,
|
|
250
|
+
transitionOnMount: true,
|
|
251
|
+
in: this.state.open,
|
|
252
|
+
unmountOnExit: true,
|
|
253
|
+
onExited: this.onExitTransition,
|
|
254
|
+
children: this.renderAlert()
|
|
255
|
+
})]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}, _Alert.displayName = "Alert", _Alert.componentId = 'Alert', _Alert.allowedProps = _props.allowedProps, _Alert.defaultProps = {
|
|
259
|
+
variant: 'info',
|
|
260
|
+
margin: 'x-small 0',
|
|
261
|
+
timeout: 0,
|
|
262
|
+
transition: 'fade',
|
|
263
|
+
open: true,
|
|
264
|
+
screenReaderOnly: false,
|
|
265
|
+
liveRegionPoliteness: 'assertive',
|
|
266
|
+
isLiveRegionAtomic: false,
|
|
267
|
+
children: null,
|
|
268
|
+
hasShadow: true
|
|
269
|
+
}, _Alert)) || _class) || _class);
|
|
270
|
+
var _default = exports.default = Alert;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['children', 'variant', 'margin', 'liveRegion', 'liveRegionPoliteness', 'isLiveRegionAtomic', 'screenReaderOnly', 'timeout', 'renderCloseButtonLabel', 'onDismiss', 'transition', 'open', 'hasShadow', 'renderCustomIcon'];
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _uiThemes = require("@instructure/ui-themes");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param {Object} componentTheme The theme variable object.
|
|
38
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
39
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
40
|
+
* @return {Object} The final style object, which will be used in the component
|
|
41
|
+
*/
|
|
42
|
+
const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
43
|
+
const variant = props.variant,
|
|
44
|
+
hasShadow = props.hasShadow;
|
|
45
|
+
const variantStyles = {
|
|
46
|
+
error: {
|
|
47
|
+
alert: {
|
|
48
|
+
borderColor: componentTheme.dangerBorderColor
|
|
49
|
+
},
|
|
50
|
+
icon: {
|
|
51
|
+
background: componentTheme.dangerIconBackground,
|
|
52
|
+
borderRightColor: componentTheme.dangerIconBackground
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
info: {
|
|
56
|
+
alert: {
|
|
57
|
+
borderColor: componentTheme.infoBorderColor
|
|
58
|
+
},
|
|
59
|
+
icon: {
|
|
60
|
+
background: componentTheme.infoIconBackground,
|
|
61
|
+
borderRightColor: componentTheme.infoIconBackground
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
success: {
|
|
65
|
+
alert: {
|
|
66
|
+
borderColor: componentTheme.successBorderColor
|
|
67
|
+
},
|
|
68
|
+
icon: {
|
|
69
|
+
backgroundColor: componentTheme.successIconBackground,
|
|
70
|
+
borderRightColor: componentTheme.successIconBackground
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
warning: {
|
|
74
|
+
alert: {
|
|
75
|
+
borderColor: componentTheme.warningBorderColor
|
|
76
|
+
},
|
|
77
|
+
icon: {
|
|
78
|
+
background: componentTheme.warningIconBackground,
|
|
79
|
+
borderRightColor: componentTheme.warningIconBackground
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
alert: {
|
|
85
|
+
label: 'alert',
|
|
86
|
+
color: componentTheme.color,
|
|
87
|
+
background: componentTheme.background,
|
|
88
|
+
boxSizing: 'border-box',
|
|
89
|
+
display: 'flex',
|
|
90
|
+
minWidth: '12rem',
|
|
91
|
+
borderWidth: componentTheme.borderWidth,
|
|
92
|
+
borderStyle: componentTheme.borderStyle,
|
|
93
|
+
borderRadius: componentTheme.borderRadius,
|
|
94
|
+
...variantStyles[variant].alert,
|
|
95
|
+
...(hasShadow && {
|
|
96
|
+
boxShadow: (0, _uiThemes.boxShadowObjectsToCSSString)(sharedTokens.boxShadow.elevation4)
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
icon: {
|
|
100
|
+
color: componentTheme.iconColor,
|
|
101
|
+
boxSizing: 'border-box',
|
|
102
|
+
flex: '0 0 2.5rem',
|
|
103
|
+
display: 'flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
fontSize: '1.125rem',
|
|
107
|
+
borderRight: `${componentTheme.borderWidth} ${componentTheme.borderStyle}`,
|
|
108
|
+
margin: -1,
|
|
109
|
+
borderStartStartRadius: componentTheme.borderRadius,
|
|
110
|
+
borderEndStartRadius: componentTheme.borderRadius,
|
|
111
|
+
...variantStyles[variant].icon
|
|
112
|
+
},
|
|
113
|
+
closeButton: {
|
|
114
|
+
boxSizing: 'border-box',
|
|
115
|
+
display: 'flex',
|
|
116
|
+
alignItems: 'flex-start',
|
|
117
|
+
order: 1,
|
|
118
|
+
marginTop: componentTheme.closeButtonMarginTop,
|
|
119
|
+
marginRight: componentTheme.closeButtonMarginRight
|
|
120
|
+
},
|
|
121
|
+
content: {
|
|
122
|
+
boxSizing: 'border-box',
|
|
123
|
+
flex: 1,
|
|
124
|
+
minWidth: '0.0625rem',
|
|
125
|
+
fontSize: componentTheme.contentFontSize,
|
|
126
|
+
fontFamily: componentTheme.contentFontFamily,
|
|
127
|
+
fontWeight: componentTheme.contentFontWeight,
|
|
128
|
+
lineHeight: componentTheme.contentLineHeight,
|
|
129
|
+
padding: `${componentTheme.contentPaddingVertical} ${componentTheme.contentPaddingHorizontal}`
|
|
130
|
+
},
|
|
131
|
+
variantScreenReaderLabel: {
|
|
132
|
+
position: 'absolute',
|
|
133
|
+
height: '1px',
|
|
134
|
+
width: '1px',
|
|
135
|
+
overflow: 'hidden',
|
|
136
|
+
margin: '-1px'
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
var _default = exports.default = generateStyle;
|
package/lib/exports/b.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-alerts",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-snapshot-129",
|
|
4
4
|
"description": "An alert component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -16,26 +16,26 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
18
|
"keycode": "^2",
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/
|
|
22
|
-
"@instructure/ui-buttons": "11.6.
|
|
23
|
-
"@instructure/
|
|
24
|
-
"@instructure/ui-icons": "11.6.
|
|
25
|
-
"@instructure/ui-react-utils": "11.6.
|
|
26
|
-
"@instructure/ui-motion": "11.6.
|
|
27
|
-
"@instructure/ui-
|
|
28
|
-
"@instructure/ui-
|
|
19
|
+
"@instructure/console": "11.6.1-snapshot-129",
|
|
20
|
+
"@instructure/emotion": "11.6.1-snapshot-129",
|
|
21
|
+
"@instructure/shared-types": "11.6.1-snapshot-129",
|
|
22
|
+
"@instructure/ui-buttons": "11.6.1-snapshot-129",
|
|
23
|
+
"@instructure/ui-a11y-content": "11.6.1-snapshot-129",
|
|
24
|
+
"@instructure/ui-icons": "11.6.1-snapshot-129",
|
|
25
|
+
"@instructure/ui-react-utils": "11.6.1-snapshot-129",
|
|
26
|
+
"@instructure/ui-motion": "11.6.1-snapshot-129",
|
|
27
|
+
"@instructure/ui-view": "11.6.1-snapshot-129",
|
|
28
|
+
"@instructure/ui-themes": "11.6.1-snapshot-129"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@testing-library/jest-dom": "^6.6.3",
|
|
32
32
|
"@testing-library/react": "15.0.7",
|
|
33
33
|
"@testing-library/user-event": "^14.6.1",
|
|
34
34
|
"vitest": "^3.2.2",
|
|
35
|
-
"@instructure/ui-babel-preset": "11.6.
|
|
36
|
-
"@instructure/ui-scripts": "11.6.
|
|
37
|
-
"@instructure/ui-
|
|
38
|
-
"@instructure/ui-
|
|
35
|
+
"@instructure/ui-babel-preset": "11.6.1-snapshot-129",
|
|
36
|
+
"@instructure/ui-scripts": "11.6.1-snapshot-129",
|
|
37
|
+
"@instructure/ui-axe-check": "11.6.1-snapshot-129",
|
|
38
|
+
"@instructure/ui-color-utils": "11.6.1-snapshot-129"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=18 <=19",
|
|
@@ -46,17 +46,39 @@
|
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"exports": {
|
|
49
|
-
".": {
|
|
50
|
-
"types": "./types/index.d.ts",
|
|
51
|
-
"import": "./es/index.js",
|
|
52
|
-
"require": "./lib/index.js",
|
|
53
|
-
"default": "./es/index.js"
|
|
54
|
-
},
|
|
55
49
|
"./lib/*": "./lib/*",
|
|
56
50
|
"./es/*": "./es/*",
|
|
57
51
|
"./types/*": "./types/*",
|
|
58
52
|
"./package.json": "./package.json",
|
|
59
|
-
"./src/*": "./src/*"
|
|
53
|
+
"./src/*": "./src/*",
|
|
54
|
+
".": {
|
|
55
|
+
"src": "./src/exports/a.ts",
|
|
56
|
+
"types": "./types/exports/a.d.ts",
|
|
57
|
+
"import": "./es/exports/a.js",
|
|
58
|
+
"require": "./lib/exports/a.js",
|
|
59
|
+
"default": "./es/exports/a.js"
|
|
60
|
+
},
|
|
61
|
+
"./v11_6": {
|
|
62
|
+
"src": "./src/exports/a.ts",
|
|
63
|
+
"types": "./types/exports/a.d.ts",
|
|
64
|
+
"import": "./es/exports/a.js",
|
|
65
|
+
"require": "./lib/exports/a.js",
|
|
66
|
+
"default": "./es/exports/a.js"
|
|
67
|
+
},
|
|
68
|
+
"./v11_7": {
|
|
69
|
+
"src": "./src/exports/b.ts",
|
|
70
|
+
"types": "./types/exports/b.d.ts",
|
|
71
|
+
"import": "./es/exports/b.js",
|
|
72
|
+
"require": "./lib/exports/b.js",
|
|
73
|
+
"default": "./es/exports/b.js"
|
|
74
|
+
},
|
|
75
|
+
"./latest": {
|
|
76
|
+
"src": "./src/exports/b.ts",
|
|
77
|
+
"types": "./types/exports/b.d.ts",
|
|
78
|
+
"import": "./es/exports/b.js",
|
|
79
|
+
"require": "./lib/exports/b.js",
|
|
80
|
+
"default": "./es/exports/b.js"
|
|
81
|
+
}
|
|
60
82
|
},
|
|
61
83
|
"scripts": {
|
|
62
84
|
"lint": "ui-scripts lint",
|
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
withDeterministicId,
|
|
32
32
|
passthroughProps
|
|
33
33
|
} from '@instructure/ui-react-utils'
|
|
34
|
-
import { CloseButton } from '@instructure/ui-buttons'
|
|
35
|
-
import { View } from '@instructure/ui-view'
|
|
36
|
-
import type { ViewOwnProps } from '@instructure/ui-view'
|
|
34
|
+
import { CloseButton } from '@instructure/ui-buttons/v11_6'
|
|
35
|
+
import { View } from '@instructure/ui-view/v11_6'
|
|
36
|
+
import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
|
|
37
37
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
38
38
|
import {
|
|
39
39
|
IconCheckMarkSolid,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from '@instructure/ui-icons'
|
|
44
44
|
import { Transition } from '@instructure/ui-motion'
|
|
45
45
|
import { logError as error } from '@instructure/console'
|
|
46
|
-
import { withStyle } from '@instructure/emotion'
|
|
46
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
47
47
|
|
|
48
48
|
import generateStyle from './styles'
|
|
49
49
|
import generateComponentTheme from './theme'
|