@instructure/ui-alerts 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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 CHANGED
@@ -3,6 +3,19 @@
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
+ ## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-alerts
@@ -1,28 +1,5 @@
1
- var _dec, _dec2, _class;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Fragment, Component } from 'react';
27
4
  import ReactDOM from 'react-dom';
28
5
  import keycode from 'keycode';
@@ -37,237 +14,223 @@ import { withStyle } from '@instructure/emotion';
37
14
  import generateStyle from './styles.js';
38
15
  import generateComponentTheme from './theme.js';
39
16
  import { allowedProps } from './props.js';
40
- import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
41
- /**
42
- ---
43
- category: components
44
- ---
45
- **/
46
- let Alert = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class Alert extends Component {
47
- static displayName = 'Alert';
48
- static componentId = 'Alert';
49
- static allowedProps = allowedProps;
50
- static defaultProps = {
51
- variant: 'info',
52
- margin: 'x-small 0',
53
- timeout: 0,
54
- transition: 'fade',
55
- open: true,
56
- screenReaderOnly: false,
57
- liveRegionPoliteness: 'assertive',
58
- isLiveRegionAtomic: false,
59
- children: null,
60
- hasShadow: true
61
- };
62
- constructor(props) {
63
- super(props);
64
- this.srid = this.props.deterministicId();
65
- this.state = {
66
- open: true
67
- };
68
- }
69
- _timeouts = [];
70
- srid;
71
- variantUI = {
72
- error: IconNoSolid,
73
- info: IconInfoBorderlessSolid,
74
- success: IconCheckMarkSolid,
75
- warning: IconWarningBorderlessSolid
76
- };
77
- ref = null;
78
- handleRef = el => {
79
- this.ref = el;
80
- const {
81
- elementRef
82
- } = this.props;
83
- if (typeof elementRef === 'function') {
84
- elementRef(el);
17
+ class Alert extends Component {
18
+ static{
19
+ this.displayName = 'Alert';
85
20
  }
86
- };
87
- handleTimeout = () => {
88
- if (this.props.timeout > 0) {
89
- this._timeouts.push(setTimeout(() => {
90
- this.close();
91
- }, this.props.timeout));
21
+ static{
22
+ this.componentId = 'Alert';
92
23
  }
93
- };
94
- clearTimeouts() {
95
- this._timeouts.forEach(timeout => clearTimeout(timeout));
96
- this._timeouts = [];
97
- }
98
- onExitTransition = () => {
99
- if (this.props.onDismiss) {
100
- this.props.onDismiss();
24
+ static{
25
+ this.allowedProps = allowedProps;
101
26
  }
102
- };
103
- close = () => {
104
- this.clearTimeouts();
105
- this.removeScreenreaderAlert();
106
- this.setState({
107
- open: false
108
- }, () => {
109
- if (this.props.onDismiss && (this.props.transition === 'none' || this.props.screenReaderOnly)) {
110
- this.props.onDismiss();
111
- }
112
- });
113
- };
114
-
115
- // duck type for a dom node
116
- isDOMNode(n) {
117
- return n && typeof n === 'object' && n.nodeType === 1;
118
- }
119
- getLiveRegion() {
120
- const lr = typeof this.props.liveRegion === 'function' ? this.props.liveRegion() : this.props.liveRegion;
121
- return this.isDOMNode(lr) ? lr : null;
122
- }
123
- initLiveRegion(liveRegion) {
124
- error(liveRegion.getAttribute('role') === 'alert', `[Alert] live region must have role='alert' set on page load in order to announce content`);
125
- if (liveRegion) {
126
- liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness);
127
- // indicates what notifications the user agent will trigger when the
128
- // accessibility tree within a live region is modified.
129
- // additions: elements are added, text: Text content is added
130
- liveRegion.setAttribute('aria-relevant', 'additions text');
131
- liveRegion.setAttribute('aria-atomic', `${this.props.isLiveRegionAtomic}`);
27
+ static{
28
+ this.defaultProps = {
29
+ variant: 'info',
30
+ margin: 'x-small 0',
31
+ timeout: 0,
32
+ transition: 'fade',
33
+ open: true,
34
+ screenReaderOnly: false,
35
+ liveRegionPoliteness: 'assertive',
36
+ isLiveRegionAtomic: false,
37
+ children: null,
38
+ hasShadow: true
39
+ };
132
40
  }
133
- }
134
- createScreenreaderContentNode() {
135
- return _jsxs(ScreenReaderContent, {
136
- children: [this.props.variantScreenReaderLabel || '', " ", this.props.children]
137
- });
138
- }
139
- createScreenreaderAlert() {
140
- const liveRegion = this.getLiveRegion();
141
- if (liveRegion) {
142
- const div = document.createElement('div');
143
- div.setAttribute('id', this.srid);
144
- liveRegion.appendChild(div);
41
+ constructor(props){
42
+ super(props), this._timeouts = [], this.variantUI = {
43
+ error: IconNoSolid,
44
+ info: IconInfoBorderlessSolid,
45
+ success: IconCheckMarkSolid,
46
+ warning: IconWarningBorderlessSolid
47
+ }, this.ref = null, this.handleRef = (el)=>{
48
+ this.ref = el;
49
+ const { elementRef } = this.props;
50
+ if (typeof elementRef === 'function') {
51
+ elementRef(el);
52
+ }
53
+ }, this.handleTimeout = ()=>{
54
+ if (this.props.timeout > 0) {
55
+ this._timeouts.push(setTimeout(()=>{
56
+ this.close();
57
+ }, this.props.timeout));
58
+ }
59
+ }, this.onExitTransition = ()=>{
60
+ if (this.props.onDismiss) {
61
+ this.props.onDismiss();
62
+ }
63
+ }, this.close = ()=>{
64
+ this.clearTimeouts();
65
+ this.removeScreenreaderAlert();
66
+ this.setState({
67
+ open: false
68
+ }, ()=>{
69
+ if (this.props.onDismiss && (this.props.transition === 'none' || this.props.screenReaderOnly)) {
70
+ this.props.onDismiss();
71
+ }
72
+ });
73
+ }, this.handleKeyUp = (event)=>{
74
+ if (this.props.renderCloseButtonLabel && event.keyCode === keycode.codes.esc) {
75
+ this.close();
76
+ }
77
+ };
78
+ this.srid = this.props.deterministicId();
79
+ this.state = {
80
+ open: true
81
+ };
145
82
  }
146
- }
147
- removeScreenreaderAlert() {
148
- const liveRegion = this.getLiveRegion();
149
- if (liveRegion) {
150
- const div = document.getElementById(this.srid);
151
- if (div) {
152
- // Accessibility attributes must be removed for the deletion of the node
153
- // and then reapplied because JAWS/IE will not respect the
154
- // "aria-relevant" attribute and read when the node is deleted if
155
- // the attributes are in place
156
- liveRegion.removeAttribute('aria-live');
157
- liveRegion.removeAttribute('aria-relevant');
158
- liveRegion.removeAttribute('aria-atomic');
159
- this.initLiveRegion(liveRegion);
160
- }
83
+ clearTimeouts() {
84
+ this._timeouts.forEach((timeout)=>clearTimeout(timeout));
85
+ this._timeouts = [];
161
86
  }
162
- }
163
- handleKeyUp = event => {
164
- if (this.props.renderCloseButtonLabel && event.keyCode === keycode.codes.esc) {
165
- this.close();
87
+ isDOMNode(n) {
88
+ return n && typeof n === 'object' && n.nodeType === 1;
166
89
  }
167
- };
168
- componentDidMount() {
169
- this.props.makeStyles?.();
170
- const liveRegion = this.getLiveRegion();
171
- if (liveRegion) {
172
- this.initLiveRegion(liveRegion);
90
+ getLiveRegion() {
91
+ const lr = typeof this.props.liveRegion === 'function' ? this.props.liveRegion() : this.props.liveRegion;
92
+ return this.isDOMNode(lr) ? lr : null;
173
93
  }
174
- this.handleTimeout();
175
- }
176
- componentWillUnmount() {
177
- this.clearTimeouts();
178
- }
179
- componentDidUpdate(prevProps) {
180
- this.props.makeStyles?.();
181
- if (!!this.props.open === false && !!this.props.open !== !!prevProps.open) {
182
- // this outside world is asking us to close the alert, which needs to
183
- // take place internally so the transition runs
184
- this.close();
94
+ initLiveRegion(liveRegion) {
95
+ error(liveRegion.getAttribute('role') === 'alert', `[Alert] live region must have role='alert' set on page load in order to announce content`);
96
+ if (liveRegion) {
97
+ liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness);
98
+ liveRegion.setAttribute('aria-relevant', 'additions text');
99
+ liveRegion.setAttribute('aria-atomic', `${this.props.isLiveRegionAtomic}`);
100
+ }
185
101
  }
186
- }
187
- renderIcon() {
188
- const {
189
- renderCustomIcon,
190
- variant,
191
- styles
192
- } = this.props;
193
- const Icon = this.variantUI[variant];
194
- return _jsx("div", {
195
- css: styles?.icon,
196
- children: renderCustomIcon ? callRenderProp(renderCustomIcon) : _jsx(Icon, {})
197
- });
198
- }
199
- renderCloseButton() {
200
- const closeButtonLabel = this.props.renderCloseButtonLabel && callRenderProp(this.props.renderCloseButtonLabel);
201
- return closeButtonLabel ? _jsx("div", {
202
- css: this.props.styles?.closeButton,
203
- children: _jsx(CloseButton, {
204
- onClick: this.close,
205
- size: "small",
206
- screenReaderLabel: closeButtonLabel
207
- })
208
- }, "closeButton") : null;
209
- }
210
- renderAlert() {
211
- // prevent onDismiss from being passed to the View component
212
- const {
213
- margin,
214
- styles,
215
- children,
216
- onDismiss,
217
- variantScreenReaderLabel,
218
- ...props
219
- } = this.props;
220
- return _jsxs(View, {
221
- ...passthroughProps({
222
- ...props
223
- }),
224
- as: "div",
225
- margin: margin,
226
- css: styles?.alert,
227
- onKeyUp: this.handleKeyUp,
228
- elementRef: this.handleRef,
229
- children: [this.renderIcon(), _jsxs("div", {
230
- css: styles?.content,
231
- children: [variantScreenReaderLabel && _jsx("span", {
232
- css: styles?.variantScreenReaderLabel,
233
- children: variantScreenReaderLabel
234
- }), children]
235
- }), this.renderCloseButton()]
236
- });
237
- }
238
- createScreenReaderPortal(liveRegion) {
239
- const {
240
- open
241
- } = this.state;
242
- return open ? /*#__PURE__*/ReactDOM.createPortal(_jsx("div", {
243
- id: this.srid,
244
- children: this.createScreenreaderContentNode()
245
- }), liveRegion) : null;
246
- }
247
- render() {
248
- const liveRegion = this.getLiveRegion();
249
- const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
250
- // Don't render anything if screen reader only
251
- if (this.props.screenReaderOnly) {
252
- error(!!this.getLiveRegion(), `[Alert] The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'.`);
253
- return screenReaderContent;
102
+ createScreenreaderContentNode() {
103
+ return /*#__PURE__*/ _jsxs(ScreenReaderContent, {
104
+ children: [
105
+ this.props.variantScreenReaderLabel || '',
106
+ " ",
107
+ this.props.children
108
+ ]
109
+ });
254
110
  }
255
- if (this.props.transition === 'none') {
256
- return this.state.open ? _jsxs(Fragment, {
257
- children: [screenReaderContent, this.renderAlert()]
258
- }) : null;
111
+ createScreenreaderAlert() {
112
+ const liveRegion = this.getLiveRegion();
113
+ if (liveRegion) {
114
+ const div = document.createElement('div');
115
+ div.setAttribute('id', this.srid);
116
+ liveRegion.appendChild(div);
117
+ }
259
118
  }
260
- return _jsxs(Fragment, {
261
- children: [screenReaderContent, _jsx(Transition, {
262
- type: this.props.transition,
263
- transitionOnMount: true,
264
- in: this.state.open,
265
- unmountOnExit: true,
266
- onExited: this.onExitTransition,
267
- children: this.renderAlert()
268
- })]
269
- });
270
- }
271
- }) || _class) || _class);
119
+ removeScreenreaderAlert() {
120
+ const liveRegion = this.getLiveRegion();
121
+ if (liveRegion) {
122
+ const div = document.getElementById(this.srid);
123
+ if (div) {
124
+ liveRegion.removeAttribute('aria-live');
125
+ liveRegion.removeAttribute('aria-relevant');
126
+ liveRegion.removeAttribute('aria-atomic');
127
+ this.initLiveRegion(liveRegion);
128
+ }
129
+ }
130
+ }
131
+ componentDidMount() {
132
+ this.props.makeStyles?.();
133
+ const liveRegion = this.getLiveRegion();
134
+ if (liveRegion) {
135
+ this.initLiveRegion(liveRegion);
136
+ }
137
+ this.handleTimeout();
138
+ }
139
+ componentWillUnmount() {
140
+ this.clearTimeouts();
141
+ }
142
+ componentDidUpdate(prevProps) {
143
+ this.props.makeStyles?.();
144
+ if (!!this.props.open === false && !!this.props.open !== !!prevProps.open) {
145
+ this.close();
146
+ }
147
+ }
148
+ renderIcon() {
149
+ const { renderCustomIcon, variant, styles } = this.props;
150
+ const Icon = this.variantUI[variant];
151
+ return /*#__PURE__*/ _jsx("div", {
152
+ css: styles?.icon,
153
+ children: renderCustomIcon ? callRenderProp(renderCustomIcon) : /*#__PURE__*/ _jsx(Icon, {})
154
+ });
155
+ }
156
+ renderCloseButton() {
157
+ const closeButtonLabel = this.props.renderCloseButtonLabel && callRenderProp(this.props.renderCloseButtonLabel);
158
+ return closeButtonLabel ? /*#__PURE__*/ _jsx("div", {
159
+ css: this.props.styles?.closeButton,
160
+ children: /*#__PURE__*/ _jsx(CloseButton, {
161
+ onClick: this.close,
162
+ size: "small",
163
+ screenReaderLabel: closeButtonLabel
164
+ })
165
+ }, "closeButton") : null;
166
+ }
167
+ renderAlert() {
168
+ const { margin, styles, children, onDismiss, variantScreenReaderLabel, ...props } = this.props;
169
+ return /*#__PURE__*/ _jsxs(View, {
170
+ ...passthroughProps({
171
+ ...props
172
+ }),
173
+ as: "div",
174
+ margin: margin,
175
+ css: styles?.alert,
176
+ onKeyUp: this.handleKeyUp,
177
+ elementRef: this.handleRef,
178
+ children: [
179
+ this.renderIcon(),
180
+ /*#__PURE__*/ _jsxs("div", {
181
+ css: styles?.content,
182
+ children: [
183
+ variantScreenReaderLabel && /*#__PURE__*/ _jsx("span", {
184
+ css: styles?.variantScreenReaderLabel,
185
+ children: variantScreenReaderLabel
186
+ }),
187
+ children
188
+ ]
189
+ }),
190
+ this.renderCloseButton()
191
+ ]
192
+ });
193
+ }
194
+ createScreenReaderPortal(liveRegion) {
195
+ const { open } = this.state;
196
+ return open ? /*#__PURE__*/ ReactDOM.createPortal(/*#__PURE__*/ _jsx("div", {
197
+ id: this.srid,
198
+ children: this.createScreenreaderContentNode()
199
+ }), liveRegion) : null;
200
+ }
201
+ render() {
202
+ const liveRegion = this.getLiveRegion();
203
+ const screenReaderContent = liveRegion ? this.createScreenReaderPortal(liveRegion) : null;
204
+ if (this.props.screenReaderOnly) {
205
+ error(!!this.getLiveRegion(), `[Alert] The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'.`);
206
+ return screenReaderContent;
207
+ }
208
+ if (this.props.transition === 'none') {
209
+ return this.state.open ? /*#__PURE__*/ _jsxs(Fragment, {
210
+ children: [
211
+ screenReaderContent,
212
+ this.renderAlert()
213
+ ]
214
+ }) : null;
215
+ }
216
+ return /*#__PURE__*/ _jsxs(Fragment, {
217
+ children: [
218
+ screenReaderContent,
219
+ /*#__PURE__*/ _jsx(Transition, {
220
+ type: this.props.transition,
221
+ transitionOnMount: true,
222
+ in: this.state.open,
223
+ unmountOnExit: true,
224
+ onExited: this.onExitTransition,
225
+ children: this.renderAlert()
226
+ })
227
+ ]
228
+ });
229
+ }
230
+ }
231
+ Alert = _ts_decorate([
232
+ withDeterministicId(),
233
+ withStyle(generateStyle, generateComponentTheme)
234
+ ], Alert);
272
235
  export default Alert;
273
- export { Alert };
236
+ export { Alert };
@@ -1,26 +1,18 @@
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', 'margin', 'liveRegion', 'liveRegionPoliteness', 'isLiveRegionAtomic', 'screenReaderOnly', 'timeout', 'renderCloseButtonLabel', 'onDismiss', 'transition', 'open', 'hasShadow', 'renderCustomIcon', 'elementRef'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'children',
3
+ 'variant',
4
+ 'margin',
5
+ 'liveRegion',
6
+ 'liveRegionPoliteness',
7
+ 'isLiveRegionAtomic',
8
+ 'screenReaderOnly',
9
+ 'timeout',
10
+ 'renderCloseButtonLabel',
11
+ 'onDismiss',
12
+ 'transition',
13
+ 'open',
14
+ 'hasShadow',
15
+ 'renderCustomIcon',
16
+ 'elementRef'
17
+ ];
18
+ export { allowedProps };