@instructure/ui-alerts 11.0.1-snapshot-0 → 11.0.1-snapshot-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 -1
- package/package.json +15 -15
- package/src/Alert/README.md +81 -199
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.0.1-snapshot-
|
|
6
|
+
## [11.0.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v11.0.0...v11.0.1-snapshot-2) (2025-10-10)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-alerts
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-alerts",
|
|
3
|
-
"version": "11.0.1-snapshot-
|
|
3
|
+
"version": "11.0.1-snapshot-2",
|
|
4
4
|
"description": "An alert component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "11.0.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "11.0.1-snapshot-
|
|
28
|
-
"@instructure/ui-color-utils": "11.0.1-snapshot-
|
|
29
|
-
"@instructure/ui-scripts": "11.0.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "11.0.1-snapshot-2",
|
|
27
|
+
"@instructure/ui-babel-preset": "11.0.1-snapshot-2",
|
|
28
|
+
"@instructure/ui-color-utils": "11.0.1-snapshot-2",
|
|
29
|
+
"@instructure/ui-scripts": "11.0.1-snapshot-2",
|
|
30
30
|
"@testing-library/jest-dom": "^6.6.3",
|
|
31
31
|
"@testing-library/react": "15.0.7",
|
|
32
32
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.27.6",
|
|
37
|
-
"@instructure/console": "11.0.1-snapshot-
|
|
38
|
-
"@instructure/emotion": "11.0.1-snapshot-
|
|
39
|
-
"@instructure/shared-types": "11.0.1-snapshot-
|
|
40
|
-
"@instructure/ui-a11y-content": "11.0.1-snapshot-
|
|
41
|
-
"@instructure/ui-buttons": "11.0.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "11.0.1-snapshot-
|
|
43
|
-
"@instructure/ui-motion": "11.0.1-snapshot-
|
|
44
|
-
"@instructure/ui-react-utils": "11.0.1-snapshot-
|
|
45
|
-
"@instructure/ui-themes": "11.0.1-snapshot-
|
|
46
|
-
"@instructure/ui-view": "11.0.1-snapshot-
|
|
37
|
+
"@instructure/console": "11.0.1-snapshot-2",
|
|
38
|
+
"@instructure/emotion": "11.0.1-snapshot-2",
|
|
39
|
+
"@instructure/shared-types": "11.0.1-snapshot-2",
|
|
40
|
+
"@instructure/ui-a11y-content": "11.0.1-snapshot-2",
|
|
41
|
+
"@instructure/ui-buttons": "11.0.1-snapshot-2",
|
|
42
|
+
"@instructure/ui-icons": "11.0.1-snapshot-2",
|
|
43
|
+
"@instructure/ui-motion": "11.0.1-snapshot-2",
|
|
44
|
+
"@instructure/ui-react-utils": "11.0.1-snapshot-2",
|
|
45
|
+
"@instructure/ui-themes": "11.0.1-snapshot-2",
|
|
46
|
+
"@instructure/ui-view": "11.0.1-snapshot-2",
|
|
47
47
|
"keycode": "^2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
package/src/Alert/README.md
CHANGED
|
@@ -81,217 +81,99 @@ ensure that element has the correct ARIA attributes.
|
|
|
81
81
|
For more information about live regions, see
|
|
82
82
|
[this MDN article](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions).
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const alerts = [...this.state.alerts]
|
|
102
|
-
const key = new Number(this.i)
|
|
103
|
-
alerts.push({
|
|
104
|
-
key,
|
|
84
|
+
```js
|
|
85
|
+
---
|
|
86
|
+
type: example
|
|
87
|
+
---
|
|
88
|
+
const Example = () => {
|
|
89
|
+
const [alerts, setAlerts] = useState([])
|
|
90
|
+
const [count, setcount] = useState(0)
|
|
91
|
+
|
|
92
|
+
const variants = ['info', 'success', 'warning', 'error']
|
|
93
|
+
|
|
94
|
+
const addAlert = () => {
|
|
95
|
+
const variant = variants[count % variants.length]
|
|
96
|
+
const politeness = Math.random() < 0.5 ? 'polite' : 'assertive'
|
|
97
|
+
setAlerts([
|
|
98
|
+
...alerts,
|
|
99
|
+
{
|
|
100
|
+
key: count,
|
|
105
101
|
variant,
|
|
106
|
-
politeness
|
|
107
|
-
onDismiss: () => this.closeAlert(key)
|
|
108
|
-
})
|
|
109
|
-
this.setState({ alerts })
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
closeAlert(key) {
|
|
113
|
-
const alerts = this.state.alerts.filter((alert) => {
|
|
114
|
-
return alert.key !== key
|
|
115
|
-
})
|
|
116
|
-
this.setState({ alerts })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getScreenReaderLabel(variant) {
|
|
120
|
-
const labels = {
|
|
121
|
-
info: 'Information, ',
|
|
122
|
-
success: 'Success, ',
|
|
123
|
-
warning: 'Warning, ',
|
|
124
|
-
error: 'Error, '
|
|
102
|
+
politeness
|
|
125
103
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
render() {
|
|
130
|
-
return (
|
|
131
|
-
<div>
|
|
132
|
-
<Button onClick={this.addAlert.bind(this)}>Add Alert</Button>
|
|
133
|
-
{this.state.alerts.map((alert) => {
|
|
134
|
-
return (
|
|
135
|
-
<View key={alert.key} display="block" margin="small 0">
|
|
136
|
-
<Alert
|
|
137
|
-
variant={alert.variant}
|
|
138
|
-
renderCloseButtonLabel="Close"
|
|
139
|
-
onDismiss={alert.onDismiss}
|
|
140
|
-
liveRegion={() => document.getElementById('flash-messages')}
|
|
141
|
-
liveRegionPoliteness={alert.politeness}
|
|
142
|
-
margin="small 0"
|
|
143
|
-
variantScreenReaderLabel={this.getScreenReaderLabel(
|
|
144
|
-
alert.variant
|
|
145
|
-
)}
|
|
146
|
-
>
|
|
147
|
-
This is {alert.politeness === 'polite' ? 'a' : 'an'}{' '}
|
|
148
|
-
{alert.politeness} {alert.variant} alert
|
|
149
|
-
</Alert>
|
|
150
|
-
</View>
|
|
151
|
-
)
|
|
152
|
-
})}
|
|
153
|
-
</div>
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
render(<Example />)
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
- ```js
|
|
162
|
-
const Example = () => {
|
|
163
|
-
const [alerts, setAlerts] = useState([])
|
|
164
|
-
const [count, setcount] = useState(0)
|
|
165
|
-
|
|
166
|
-
const variants = ['info', 'success', 'warning', 'error']
|
|
167
|
-
|
|
168
|
-
const addAlert = () => {
|
|
169
|
-
const variant = variants[count % variants.length]
|
|
170
|
-
const politeness = Math.random() < 0.5 ? 'polite' : 'assertive'
|
|
171
|
-
setAlerts([
|
|
172
|
-
...alerts,
|
|
173
|
-
{
|
|
174
|
-
key: count,
|
|
175
|
-
variant,
|
|
176
|
-
politeness
|
|
177
|
-
}
|
|
178
|
-
])
|
|
179
|
-
setcount(count + 1)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const closeAlert = (key) =>
|
|
183
|
-
setAlerts(alerts.filter((alert) => alert.key !== key))
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div>
|
|
187
|
-
<Button onClick={addAlert}>Add Alert</Button>
|
|
188
|
-
{alerts.map((alert) => {
|
|
189
|
-
return (
|
|
190
|
-
<View key={alert.key} display="block" margin="small 0">
|
|
191
|
-
<Alert
|
|
192
|
-
variant={alert.variant}
|
|
193
|
-
renderCloseButtonLabel="Close"
|
|
194
|
-
onDismiss={() => closeAlert(alert.key)}
|
|
195
|
-
liveRegion={() => document.getElementById('flash-messages')}
|
|
196
|
-
liveRegionPoliteness={alert.politeness}
|
|
197
|
-
margin="small 0"
|
|
198
|
-
>
|
|
199
|
-
This is {alert.politeness === 'polite' ? 'a' : 'an'}{' '}
|
|
200
|
-
{alert.politeness} {alert.variant} alert
|
|
201
|
-
</Alert>
|
|
202
|
-
</View>
|
|
203
|
-
)
|
|
204
|
-
})}
|
|
205
|
-
</div>
|
|
206
|
-
)
|
|
104
|
+
])
|
|
105
|
+
setcount(count + 1)
|
|
207
106
|
}
|
|
208
107
|
|
|
209
|
-
|
|
210
|
-
|
|
108
|
+
const closeAlert = (key) =>
|
|
109
|
+
setAlerts(alerts.filter((alert) => alert.key !== key))
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div>
|
|
113
|
+
<Button onClick={addAlert}>Add Alert</Button>
|
|
114
|
+
{alerts.map((alert) => {
|
|
115
|
+
return (
|
|
116
|
+
<View key={alert.key} display="block" margin="small 0">
|
|
117
|
+
<Alert
|
|
118
|
+
variant={alert.variant}
|
|
119
|
+
renderCloseButtonLabel="Close"
|
|
120
|
+
onDismiss={() => closeAlert(alert.key)}
|
|
121
|
+
liveRegion={() => document.getElementById('flash-messages')}
|
|
122
|
+
liveRegionPoliteness={alert.politeness}
|
|
123
|
+
margin="small 0"
|
|
124
|
+
>
|
|
125
|
+
This is {alert.politeness === 'polite' ? 'a' : 'an'}{' '}
|
|
126
|
+
{alert.politeness} {alert.variant} alert
|
|
127
|
+
</Alert>
|
|
128
|
+
</View>
|
|
129
|
+
)
|
|
130
|
+
})}
|
|
131
|
+
</div>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
render(<Example />)
|
|
136
|
+
```
|
|
211
137
|
|
|
212
138
|
Alerts can be used to emit screenreader only messages too
|
|
213
139
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
count: 1
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
changeMessage = () => {
|
|
226
|
-
this.setState({
|
|
227
|
-
message: `this is message ${this.state.count}`,
|
|
228
|
-
count: this.state.count + 1
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
clearMessage = () => {
|
|
233
|
-
this.setState({
|
|
234
|
-
message: null,
|
|
235
|
-
count: this.state.count + 1
|
|
236
|
-
})
|
|
237
|
-
}
|
|
140
|
+
```js
|
|
141
|
+
---
|
|
142
|
+
type: example
|
|
143
|
+
---
|
|
144
|
+
const Example = () => {
|
|
145
|
+
const [message, setMessage] = useState(null)
|
|
146
|
+
const [count, setCount] = useState(1)
|
|
238
147
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<Button onClick={this.changeMessage}>Change Message</Button>
|
|
243
|
-
<Button onClick={this.clearMessage} margin="0 0 0 small">
|
|
244
|
-
Clear Message
|
|
245
|
-
</Button>
|
|
246
|
-
<Alert
|
|
247
|
-
liveRegion={() => document.getElementById('flash-messages')}
|
|
248
|
-
isLiveRegionAtomic
|
|
249
|
-
screenReaderOnly
|
|
250
|
-
>
|
|
251
|
-
{this.state.message}
|
|
252
|
-
</Alert>
|
|
253
|
-
</div>
|
|
254
|
-
)
|
|
255
|
-
}
|
|
148
|
+
const changeMessage = () => {
|
|
149
|
+
setMessage(`this is message ${count}`)
|
|
150
|
+
setCount(count + 1)
|
|
256
151
|
}
|
|
257
152
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
- ```js
|
|
262
|
-
const Example = () => {
|
|
263
|
-
const [message, setMessage] = useState(null)
|
|
264
|
-
const [count, setCount] = useState(1)
|
|
265
|
-
|
|
266
|
-
const changeMessage = () => {
|
|
267
|
-
setMessage(`this is message ${count}`)
|
|
268
|
-
setCount(count + 1)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const clearMessage = () => {
|
|
272
|
-
setMessage(null)
|
|
273
|
-
setCount(count + 1)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<div>
|
|
278
|
-
<Button onClick={changeMessage}>Change Message</Button>
|
|
279
|
-
<Button onClick={clearMessage} margin="0 0 0 small">
|
|
280
|
-
Clear Message
|
|
281
|
-
</Button>
|
|
282
|
-
<Alert
|
|
283
|
-
liveRegion={() => document.getElementById('flash-messages')}
|
|
284
|
-
isLiveRegionAtomic
|
|
285
|
-
screenReaderOnly
|
|
286
|
-
>
|
|
287
|
-
{message}
|
|
288
|
-
</Alert>
|
|
289
|
-
</div>
|
|
290
|
-
)
|
|
153
|
+
const clearMessage = () => {
|
|
154
|
+
setMessage(null)
|
|
155
|
+
setCount(count + 1)
|
|
291
156
|
}
|
|
292
157
|
|
|
293
|
-
|
|
294
|
-
|
|
158
|
+
return (
|
|
159
|
+
<div>
|
|
160
|
+
<Button onClick={changeMessage}>Change Message</Button>
|
|
161
|
+
<Button onClick={clearMessage} margin="0 0 0 small">
|
|
162
|
+
Clear Message
|
|
163
|
+
</Button>
|
|
164
|
+
<Alert
|
|
165
|
+
liveRegion={() => document.getElementById('flash-messages')}
|
|
166
|
+
isLiveRegionAtomic
|
|
167
|
+
screenReaderOnly
|
|
168
|
+
>
|
|
169
|
+
{message}
|
|
170
|
+
</Alert>
|
|
171
|
+
</div>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
render(<Example />)
|
|
176
|
+
```
|
|
295
177
|
|
|
296
178
|
When Alerts are used inline, the shadow can be removed with the `hasShadow` property.
|
|
297
179
|
|