@fluentui/react-toast 9.3.1 → 9.3.5
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.json +205 -1
- package/CHANGELOG.md +62 -2
- package/lib/components/AriaLive/useAriaLive.js +3 -5
- package/lib/components/AriaLive/useAriaLive.js.map +1 -1
- package/lib/components/ToastContainer/useToastContainer.js +12 -12
- package/lib/components/ToastContainer/useToastContainer.js.map +1 -1
- package/lib/components/ToastTrigger/useToastTrigger.js +5 -6
- package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -1
- package/lib/components/Toaster/useToaster.js +2 -2
- package/lib/components/Toaster/useToaster.js.map +1 -1
- package/lib/contexts/toastContainerContext.js +4 -2
- package/lib/contexts/toastContainerContext.js.map +1 -1
- package/lib/state/useToastController.js +1 -2
- package/lib/state/useToastController.js.map +1 -1
- package/lib/state/useToaster.js +8 -12
- package/lib/state/useToaster.js.map +1 -1
- package/lib/state/vanilla/createToaster.js +4 -4
- package/lib/state/vanilla/createToaster.js.map +1 -1
- package/lib-commonjs/components/AriaLive/useAriaLive.js +3 -5
- package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/useToastContainer.js +12 -12
- package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -1
- package/lib-commonjs/components/ToastTrigger/useToastTrigger.js +5 -6
- package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToaster.js +2 -2
- package/lib-commonjs/components/Toaster/useToaster.js.map +1 -1
- package/lib-commonjs/contexts/toastContainerContext.js +4 -2
- package/lib-commonjs/contexts/toastContainerContext.js.map +1 -1
- package/lib-commonjs/state/useToastController.js +1 -2
- package/lib-commonjs/state/useToastController.js.map +1 -1
- package/lib-commonjs/state/useToaster.js +8 -12
- package/lib-commonjs/state/useToaster.js.map +1 -1
- package/lib-commonjs/state/vanilla/createToaster.js +4 -4
- package/lib-commonjs/state/vanilla/createToaster.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,211 @@
|
|
|
2
2
|
"name": "@fluentui/react-toast",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Tue, 26 Sep 2023 17:44:19 GMT",
|
|
6
|
+
"tag": "@fluentui/react-toast_v9.3.5",
|
|
7
|
+
"version": "9.3.5",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "yuanboxue@microsoft.com",
|
|
12
|
+
"package": "@fluentui/react-toast",
|
|
13
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d",
|
|
14
|
+
"comment": "chore: trigger manual version bump after broken release"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-toast",
|
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v9.0.6",
|
|
20
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-toast",
|
|
25
|
+
"comment": "Bump @fluentui/react-aria to v9.3.38",
|
|
26
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-toast",
|
|
31
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.12",
|
|
32
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@fluentui/react-toast",
|
|
37
|
+
"comment": "Bump @fluentui/react-portal to v9.3.18",
|
|
38
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "@fluentui/react-toast",
|
|
43
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.9.1",
|
|
44
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "beachball",
|
|
48
|
+
"package": "@fluentui/react-toast",
|
|
49
|
+
"comment": "Bump @fluentui/react-tabster to v9.13.1",
|
|
50
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "beachball",
|
|
54
|
+
"package": "@fluentui/react-toast",
|
|
55
|
+
"comment": "Bump @fluentui/react-theme to v9.1.14",
|
|
56
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"author": "beachball",
|
|
60
|
+
"package": "@fluentui/react-toast",
|
|
61
|
+
"comment": "Bump @fluentui/react-utilities to v9.13.5",
|
|
62
|
+
"commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"date": "Tue, 26 Sep 2023 15:31:43 GMT",
|
|
69
|
+
"tag": "@fluentui/react-toast_v9.3.4",
|
|
70
|
+
"version": "9.3.4",
|
|
71
|
+
"comments": {
|
|
72
|
+
"patch": [
|
|
73
|
+
{
|
|
74
|
+
"author": "martinhochel@microsoft.com",
|
|
75
|
+
"package": "@fluentui/react-toast",
|
|
76
|
+
"commit": "e61473fa10195f6ebf2308205c1e72e91b711831",
|
|
77
|
+
"comment": "fix: bump swc core to mitigate transpilation memory leaks"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"author": "ololubek@microsoft.com",
|
|
81
|
+
"package": "@fluentui/react-toast",
|
|
82
|
+
"commit": "a31e7394d9f169bc5aa55430a22cdc65425a1b49",
|
|
83
|
+
"comment": "chore: Update react-icons version to pick up IconDirectionContextProvider updated export"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"author": "beachball",
|
|
87
|
+
"package": "@fluentui/react-toast",
|
|
88
|
+
"comment": "Bump @fluentui/keyboard-keys to v9.0.5",
|
|
89
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"author": "beachball",
|
|
93
|
+
"package": "@fluentui/react-toast",
|
|
94
|
+
"comment": "Bump @fluentui/react-aria to v9.3.37",
|
|
95
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"author": "beachball",
|
|
99
|
+
"package": "@fluentui/react-toast",
|
|
100
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.11",
|
|
101
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"author": "beachball",
|
|
105
|
+
"package": "@fluentui/react-toast",
|
|
106
|
+
"comment": "Bump @fluentui/react-portal to v9.3.17",
|
|
107
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"author": "beachball",
|
|
111
|
+
"package": "@fluentui/react-toast",
|
|
112
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.9.0",
|
|
113
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"author": "beachball",
|
|
117
|
+
"package": "@fluentui/react-toast",
|
|
118
|
+
"comment": "Bump @fluentui/react-tabster to v9.13.0",
|
|
119
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"author": "beachball",
|
|
123
|
+
"package": "@fluentui/react-toast",
|
|
124
|
+
"comment": "Bump @fluentui/react-theme to v9.1.13",
|
|
125
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"author": "beachball",
|
|
129
|
+
"package": "@fluentui/react-toast",
|
|
130
|
+
"comment": "Bump @fluentui/react-utilities to v9.13.4",
|
|
131
|
+
"commit": "e16520437e10cd824ac254dd797e32762b5de72d"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"date": "Wed, 20 Sep 2023 17:47:45 GMT",
|
|
138
|
+
"tag": "@fluentui/react-toast_v9.3.3",
|
|
139
|
+
"version": "9.3.3",
|
|
140
|
+
"comments": {
|
|
141
|
+
"patch": [
|
|
142
|
+
{
|
|
143
|
+
"author": "martinhochel@microsoft.com",
|
|
144
|
+
"package": "@fluentui/react-toast",
|
|
145
|
+
"commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0",
|
|
146
|
+
"comment": "chore: trigger manual version bump after broken release"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"author": "beachball",
|
|
150
|
+
"package": "@fluentui/react-toast",
|
|
151
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.10",
|
|
152
|
+
"commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"author": "beachball",
|
|
156
|
+
"package": "@fluentui/react-toast",
|
|
157
|
+
"comment": "Bump @fluentui/react-portal to v9.3.16",
|
|
158
|
+
"commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"author": "beachball",
|
|
162
|
+
"package": "@fluentui/react-toast",
|
|
163
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.8.1",
|
|
164
|
+
"commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"author": "beachball",
|
|
168
|
+
"package": "@fluentui/react-toast",
|
|
169
|
+
"comment": "Bump @fluentui/react-tabster to v9.12.11",
|
|
170
|
+
"commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"date": "Wed, 20 Sep 2023 14:59:53 GMT",
|
|
177
|
+
"tag": "@fluentui/react-toast_v9.3.2",
|
|
178
|
+
"version": "9.3.2",
|
|
179
|
+
"comments": {
|
|
180
|
+
"patch": [
|
|
181
|
+
{
|
|
182
|
+
"author": "beachball",
|
|
183
|
+
"package": "@fluentui/react-toast",
|
|
184
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.9",
|
|
185
|
+
"commit": "c60d4e7169457535c8d23701f6b951d1fff478ab"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"author": "beachball",
|
|
189
|
+
"package": "@fluentui/react-toast",
|
|
190
|
+
"comment": "Bump @fluentui/react-portal to v9.3.15",
|
|
191
|
+
"commit": "c60d4e7169457535c8d23701f6b951d1fff478ab"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"author": "beachball",
|
|
195
|
+
"package": "@fluentui/react-toast",
|
|
196
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.8.0",
|
|
197
|
+
"commit": "c60d4e7169457535c8d23701f6b951d1fff478ab"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"author": "beachball",
|
|
201
|
+
"package": "@fluentui/react-toast",
|
|
202
|
+
"comment": "Bump @fluentui/react-tabster to v9.12.10",
|
|
203
|
+
"commit": "c60d4e7169457535c8d23701f6b951d1fff478ab"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"date": "Thu, 14 Sep 2023 16:44:47 GMT",
|
|
6
210
|
"tag": "@fluentui/react-toast_v9.3.1",
|
|
7
211
|
"version": "9.3.1",
|
|
8
212
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-toast
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 26 Sep 2023 17:44:19 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.3.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.3.5)
|
|
8
|
+
|
|
9
|
+
Tue, 26 Sep 2023 17:44:19 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.3.4..@fluentui/react-toast_v9.3.5)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- chore: trigger manual version bump after broken release ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by yuanboxue@microsoft.com)
|
|
15
|
+
- Bump @fluentui/keyboard-keys to v9.0.6 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
16
|
+
- Bump @fluentui/react-aria to v9.3.38 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
17
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.12 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
18
|
+
- Bump @fluentui/react-portal to v9.3.18 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
19
|
+
- Bump @fluentui/react-shared-contexts to v9.9.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
20
|
+
- Bump @fluentui/react-tabster to v9.13.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
21
|
+
- Bump @fluentui/react-theme to v9.1.14 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
22
|
+
- Bump @fluentui/react-utilities to v9.13.5 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
|
|
23
|
+
|
|
24
|
+
## [9.3.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.3.4)
|
|
25
|
+
|
|
26
|
+
Tue, 26 Sep 2023 15:31:43 GMT
|
|
27
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.3.3..@fluentui/react-toast_v9.3.4)
|
|
28
|
+
|
|
29
|
+
### Patches
|
|
30
|
+
|
|
31
|
+
- fix: bump swc core to mitigate transpilation memory leaks ([PR #29253](https://github.com/microsoft/fluentui/pull/29253) by martinhochel@microsoft.com)
|
|
32
|
+
- chore: Update react-icons version to pick up IconDirectionContextProvider updated export ([PR #29151](https://github.com/microsoft/fluentui/pull/29151) by ololubek@microsoft.com)
|
|
33
|
+
- Bump @fluentui/keyboard-keys to v9.0.5 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
34
|
+
- Bump @fluentui/react-aria to v9.3.37 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
35
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.11 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
36
|
+
- Bump @fluentui/react-portal to v9.3.17 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
37
|
+
- Bump @fluentui/react-shared-contexts to v9.9.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
38
|
+
- Bump @fluentui/react-tabster to v9.13.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
39
|
+
- Bump @fluentui/react-theme to v9.1.13 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
40
|
+
- Bump @fluentui/react-utilities to v9.13.4 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
|
|
41
|
+
|
|
42
|
+
## [9.3.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.3.3)
|
|
43
|
+
|
|
44
|
+
Wed, 20 Sep 2023 17:47:45 GMT
|
|
45
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.3.2..@fluentui/react-toast_v9.3.3)
|
|
46
|
+
|
|
47
|
+
### Patches
|
|
48
|
+
|
|
49
|
+
- chore: trigger manual version bump after broken release ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by martinhochel@microsoft.com)
|
|
50
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.10 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
|
|
51
|
+
- Bump @fluentui/react-portal to v9.3.16 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
|
|
52
|
+
- Bump @fluentui/react-shared-contexts to v9.8.1 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
|
|
53
|
+
- Bump @fluentui/react-tabster to v9.12.11 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
|
|
54
|
+
|
|
55
|
+
## [9.3.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.3.2)
|
|
56
|
+
|
|
57
|
+
Wed, 20 Sep 2023 14:59:53 GMT
|
|
58
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.3.1..@fluentui/react-toast_v9.3.2)
|
|
59
|
+
|
|
60
|
+
### Patches
|
|
61
|
+
|
|
62
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.9 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
|
|
63
|
+
- Bump @fluentui/react-portal to v9.3.15 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
|
|
64
|
+
- Bump @fluentui/react-shared-contexts to v9.8.0 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
|
|
65
|
+
- Bump @fluentui/react-tabster to v9.12.10 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
|
|
66
|
+
|
|
7
67
|
## [9.3.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.3.1)
|
|
8
68
|
|
|
9
|
-
Thu, 14 Sep 2023 16:
|
|
69
|
+
Thu, 14 Sep 2023 16:44:47 GMT
|
|
10
70
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.3.0..@fluentui/react-toast_v9.3.1)
|
|
11
71
|
|
|
12
72
|
### Patches
|
|
@@ -9,7 +9,6 @@ import { createPriorityQueue, useEventCallback, slot } from '@fluentui/react-uti
|
|
|
9
9
|
*
|
|
10
10
|
* @param props - props from this instance of AriaLive
|
|
11
11
|
*/ export const useAriaLive_unstable = (props)=>{
|
|
12
|
-
var _currentMessage, _currentMessage1;
|
|
13
12
|
const [currentMessage, setCurrentMessage] = React.useState(undefined);
|
|
14
13
|
// Can't rely on Date.now() if user invokes announce more than once in a code block
|
|
15
14
|
const order = React.useRef(0);
|
|
@@ -20,9 +19,8 @@ import { createPriorityQueue, useEventCallback, slot } from '@fluentui/react-uti
|
|
|
20
19
|
return a.politeness === 'assertive' ? -1 : 1;
|
|
21
20
|
}));
|
|
22
21
|
const announce = useEventCallback((message, options)=>{
|
|
23
|
-
var _currentMessage;
|
|
24
22
|
const { politeness } = options;
|
|
25
|
-
if (message === (
|
|
23
|
+
if (message === (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.message)) {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
26
|
const liveMessage = {
|
|
@@ -50,8 +48,8 @@ import { createPriorityQueue, useEventCallback, slot } from '@fluentui/react-uti
|
|
|
50
48
|
messageQueue
|
|
51
49
|
]);
|
|
52
50
|
React.useImperativeHandle(props.announceRef, ()=>announce);
|
|
53
|
-
const politeMessage = (
|
|
54
|
-
const assertiveMessage = (
|
|
51
|
+
const politeMessage = (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.politeness) === 'polite' ? currentMessage.message : undefined;
|
|
52
|
+
const assertiveMessage = (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.politeness) === 'assertive' ? currentMessage.message : undefined;
|
|
55
53
|
return {
|
|
56
54
|
components: {
|
|
57
55
|
assertive: 'div',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useAriaLive.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue, useEventCallback, slot } from '@fluentui/react-utilities';\nimport type { AnnounceOptions, AriaLiveProps, AriaLiveState, LiveMessage } from './AriaLive.types';\n\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */\nconst MESSAGE_DURATION = 500;\n\n/**\n * Create the state required to render AriaLive.\n *\n * The returned state can be modified with hooks such as useAriaLiveStyles_unstable,\n * before being passed to renderAriaLive_unstable.\n *\n * @param props - props from this instance of AriaLive\n */\nexport const useAriaLive_unstable = (props: AriaLiveProps): AriaLiveState => {\n const [currentMessage, setCurrentMessage] = React.useState<LiveMessage | undefined>(undefined);\n // Can't rely on Date.now() if user invokes announce more than once in a code block\n const order = React.useRef(0);\n const [messageQueue] = React.useState(() =>\n createPriorityQueue<LiveMessage>((a, b) => {\n if (a.politeness === b.politeness) {\n return a.createdAt - b.createdAt;\n }\n\n return a.politeness === 'assertive' ? -1 : 1;\n }),\n );\n\n const announce = useEventCallback((message: string, options: AnnounceOptions) => {\n const { politeness } = options;\n if (message === currentMessage?.message) {\n return;\n }\n\n const liveMessage: LiveMessage = {\n message,\n politeness,\n createdAt: order.current++,\n };\n\n if (!currentMessage) {\n setCurrentMessage(liveMessage);\n } else {\n messageQueue.enqueue(liveMessage);\n }\n });\n\n React.useEffect(() => {\n const timeout = setTimeout(() => {\n if (messageQueue.peek()) {\n setCurrentMessage(messageQueue.dequeue());\n } else {\n setCurrentMessage(undefined);\n }\n }, MESSAGE_DURATION);\n\n return () => clearTimeout(timeout);\n }, [currentMessage, messageQueue]);\n\n React.useImperativeHandle(props.announceRef, () => announce);\n\n const politeMessage = currentMessage?.politeness === 'polite' ? currentMessage.message : undefined;\n const assertiveMessage = currentMessage?.politeness === 'assertive' ? currentMessage.message : undefined;\n\n return {\n components: {\n assertive: 'div',\n polite: 'div',\n },\n\n assertive: slot.always(props.assertive, {\n defaultProps: { 'aria-live': 'assertive', children: assertiveMessage },\n elementType: 'div',\n }),\n polite: slot.always(props.polite, {\n defaultProps: { 'aria-live': 'polite', children: politeMessage },\n elementType: 'div',\n }),\n };\n};\n"],"names":["React","createPriorityQueue","useEventCallback","slot","MESSAGE_DURATION","useAriaLive_unstable","props","currentMessage","setCurrentMessage","useState","undefined","order","useRef","messageQueue","a","b","politeness","createdAt","announce","message","options","liveMessage","current","enqueue","useEffect","timeout","setTimeout","peek","dequeue","clearTimeout","useImperativeHandle","announceRef","politeMessage","assertiveMessage","components","assertive","polite","always","defaultProps","children","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,4BAA4B;AAGxF,gHAAgH,GAChH,MAAMC,mBAAmB;AAEzB;;;;;;;CAOC,GACD,OAAO,MAAMC,uBAAuB,CAACC;
|
|
1
|
+
{"version":3,"sources":["useAriaLive.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue, useEventCallback, slot } from '@fluentui/react-utilities';\nimport type { AnnounceOptions, AriaLiveProps, AriaLiveState, LiveMessage } from './AriaLive.types';\n\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */\nconst MESSAGE_DURATION = 500;\n\n/**\n * Create the state required to render AriaLive.\n *\n * The returned state can be modified with hooks such as useAriaLiveStyles_unstable,\n * before being passed to renderAriaLive_unstable.\n *\n * @param props - props from this instance of AriaLive\n */\nexport const useAriaLive_unstable = (props: AriaLiveProps): AriaLiveState => {\n const [currentMessage, setCurrentMessage] = React.useState<LiveMessage | undefined>(undefined);\n // Can't rely on Date.now() if user invokes announce more than once in a code block\n const order = React.useRef(0);\n const [messageQueue] = React.useState(() =>\n createPriorityQueue<LiveMessage>((a, b) => {\n if (a.politeness === b.politeness) {\n return a.createdAt - b.createdAt;\n }\n\n return a.politeness === 'assertive' ? -1 : 1;\n }),\n );\n\n const announce = useEventCallback((message: string, options: AnnounceOptions) => {\n const { politeness } = options;\n if (message === currentMessage?.message) {\n return;\n }\n\n const liveMessage: LiveMessage = {\n message,\n politeness,\n createdAt: order.current++,\n };\n\n if (!currentMessage) {\n setCurrentMessage(liveMessage);\n } else {\n messageQueue.enqueue(liveMessage);\n }\n });\n\n React.useEffect(() => {\n const timeout = setTimeout(() => {\n if (messageQueue.peek()) {\n setCurrentMessage(messageQueue.dequeue());\n } else {\n setCurrentMessage(undefined);\n }\n }, MESSAGE_DURATION);\n\n return () => clearTimeout(timeout);\n }, [currentMessage, messageQueue]);\n\n React.useImperativeHandle(props.announceRef, () => announce);\n\n const politeMessage = currentMessage?.politeness === 'polite' ? currentMessage.message : undefined;\n const assertiveMessage = currentMessage?.politeness === 'assertive' ? currentMessage.message : undefined;\n\n return {\n components: {\n assertive: 'div',\n polite: 'div',\n },\n\n assertive: slot.always(props.assertive, {\n defaultProps: { 'aria-live': 'assertive', children: assertiveMessage },\n elementType: 'div',\n }),\n polite: slot.always(props.polite, {\n defaultProps: { 'aria-live': 'polite', children: politeMessage },\n elementType: 'div',\n }),\n };\n};\n"],"names":["React","createPriorityQueue","useEventCallback","slot","MESSAGE_DURATION","useAriaLive_unstable","props","currentMessage","setCurrentMessage","useState","undefined","order","useRef","messageQueue","a","b","politeness","createdAt","announce","message","options","liveMessage","current","enqueue","useEffect","timeout","setTimeout","peek","dequeue","clearTimeout","useImperativeHandle","announceRef","politeMessage","assertiveMessage","components","assertive","polite","always","defaultProps","children","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,4BAA4B;AAGxF,gHAAgH,GAChH,MAAMC,mBAAmB;AAEzB;;;;;;;CAOC,GAC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C,QAAQ;QACV;QAEAD,WAAWhC,KAAKkC,MAAM,CAAC/B,MAAM6B,SAAS,EAAE;YACtCG,cAAc;gBAAE,aAAa;gBAAaC,UAAUN;YAAiB;YACrEO,aAAa;QACf;QACAJ,QAAQjC,KAAKkC,MAAM,CAAC/B,MAAM8B,MAAM,EAAE;YAChCE,cAAc;gBAAE,aAAa;gBAAUC,UAAUP;YAAc;YAC/DQ,aAAa;QACf;IACF;AACF,EAAE"}
|
|
@@ -38,28 +38,28 @@ const intentPolitenessMap = {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
const close = useEventCallback(()=>{
|
|
41
|
-
var
|
|
42
|
-
const activeElement =
|
|
41
|
+
var _toastRef_current;
|
|
42
|
+
const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
|
43
43
|
if (activeElement && ((_toastRef_current = toastRef.current) === null || _toastRef_current === void 0 ? void 0 : _toastRef_current.contains(activeElement))) {
|
|
44
44
|
focusedToastBeforeClose.current = true;
|
|
45
45
|
}
|
|
46
46
|
closeProp();
|
|
47
47
|
});
|
|
48
48
|
const onStatusChange = useEventCallback((status)=>{
|
|
49
|
-
var _props_onStatusChange
|
|
50
|
-
return (_props_onStatusChange =
|
|
49
|
+
var _props_onStatusChange;
|
|
50
|
+
return (_props_onStatusChange = props.onStatusChange) === null || _props_onStatusChange === void 0 ? void 0 : _props_onStatusChange.call(props, null, {
|
|
51
51
|
status,
|
|
52
52
|
...props
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
const pause = useEventCallback(()=>setRunning(false));
|
|
56
56
|
const play = useEventCallback(()=>{
|
|
57
|
-
var
|
|
57
|
+
var _toastRef_current;
|
|
58
58
|
if (imperativePauseRef.current) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
var _targetDocument_activeElement;
|
|
62
|
-
const containsActive = !!((_toastRef_current = toastRef.current) === null || _toastRef_current === void 0 ? void 0 : _toastRef_current.contains((_targetDocument_activeElement =
|
|
62
|
+
const containsActive = !!((_toastRef_current = toastRef.current) === null || _toastRef_current === void 0 ? void 0 : _toastRef_current.contains((_targetDocument_activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) !== null && _targetDocument_activeElement !== void 0 ? _targetDocument_activeElement : null));
|
|
63
63
|
if (timerTimeout < 0) {
|
|
64
64
|
setRunning(true);
|
|
65
65
|
return;
|
|
@@ -137,18 +137,18 @@ const intentPolitenessMap = {
|
|
|
137
137
|
onStatusChange
|
|
138
138
|
]);
|
|
139
139
|
const onMouseEnter = useEventCallback((e)=>{
|
|
140
|
-
var _userRootSlot_onMouseEnter
|
|
140
|
+
var _userRootSlot_onMouseEnter;
|
|
141
141
|
pause();
|
|
142
|
-
|
|
142
|
+
userRootSlot === null || userRootSlot === void 0 ? void 0 : (_userRootSlot_onMouseEnter = userRootSlot.onMouseEnter) === null || _userRootSlot_onMouseEnter === void 0 ? void 0 : _userRootSlot_onMouseEnter.call(userRootSlot, e);
|
|
143
143
|
});
|
|
144
144
|
const onMouseLeave = useEventCallback((e)=>{
|
|
145
|
-
var _userRootSlot_onMouseEnter
|
|
145
|
+
var _userRootSlot_onMouseEnter;
|
|
146
146
|
play();
|
|
147
|
-
|
|
147
|
+
userRootSlot === null || userRootSlot === void 0 ? void 0 : (_userRootSlot_onMouseEnter = userRootSlot.onMouseEnter) === null || _userRootSlot_onMouseEnter === void 0 ? void 0 : _userRootSlot_onMouseEnter.call(userRootSlot, e);
|
|
148
148
|
});
|
|
149
149
|
const { findFirstFocusable, findLastFocusable } = useFocusFinders();
|
|
150
150
|
const onKeyDown = useEventCallback((e)=>{
|
|
151
|
-
var _userRootSlot_onKeyDown
|
|
151
|
+
var _userRootSlot_onKeyDown;
|
|
152
152
|
if (e.key === Delete) {
|
|
153
153
|
e.preventDefault();
|
|
154
154
|
close();
|
|
@@ -163,7 +163,7 @@ const intentPolitenessMap = {
|
|
|
163
163
|
(_findFirstFocusable = findFirstFocusable(e.currentTarget)) === null || _findFirstFocusable === void 0 ? void 0 : _findFirstFocusable.focus();
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
userRootSlot === null || userRootSlot === void 0 ? void 0 : (_userRootSlot_onKeyDown = userRootSlot.onKeyDown) === null || _userRootSlot_onKeyDown === void 0 ? void 0 : _userRootSlot_onKeyDown.call(userRootSlot, e);
|
|
167
167
|
});
|
|
168
168
|
React.useEffect(()=>{
|
|
169
169
|
var _toastRef_current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useToastContainer.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getNativeElementProps,\n useMergedRefs,\n ExtractSlotProps,\n Slot,\n useEventCallback,\n useId,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { Delete, Tab } from '@fluentui/keyboard-keys';\nimport { useFocusableGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { ToastStatus } from '../../state';\nimport type { ToastContainerProps, ToastContainerState } from './ToastContainer.types';\nimport { Timer, TimerProps } from '../Timer/Timer';\n\nconst intentPolitenessMap = {\n success: 'assertive',\n warning: 'assertive',\n error: 'assertive',\n info: 'polite',\n} as const;\n\n/**\n * Create the state required to render ToastContainer.\n *\n * The returned state can be modified with hooks such as useToastContainerStyles_unstable,\n * before being passed to renderToastContainer_unstable.\n *\n * @param props - props from this instance of ToastContainer\n * @param ref - reference to root HTMLElement of ToastContainer\n */\nexport const useToastContainer_unstable = (\n props: ToastContainerProps,\n ref: React.Ref<HTMLElement>,\n): ToastContainerState => {\n const {\n visible,\n children,\n close: closeProp,\n remove,\n updateId,\n announce,\n data,\n timeout: timerTimeout,\n politeness: desiredPoliteness,\n intent = 'info',\n pauseOnHover,\n pauseOnWindowBlur,\n imperativeRef,\n tryRestoreFocus,\n ...rest\n } = props;\n const titleId = useId('toast-title');\n const bodyId = useId('toast-body');\n const toastRef = React.useRef<HTMLDivElement | null>(null);\n const { targetDocument } = useFluent_unstable();\n const [running, setRunning] = React.useState(false);\n const imperativePauseRef = React.useRef(false);\n const focusedToastBeforeClose = React.useRef(false);\n const focusableGroupAttribute = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n // Users should only use Tab to focus into the toast\n // Escape is already reserved to dismiss all toasts\n ignoreDefaultKeydown: { Tab: true, Escape: true, Enter: true },\n });\n\n const close = useEventCallback(() => {\n const activeElement = targetDocument?.activeElement;\n if (activeElement && toastRef.current?.contains(activeElement)) {\n focusedToastBeforeClose.current = true;\n }\n\n closeProp();\n });\n const onStatusChange = useEventCallback((status: ToastStatus) => props.onStatusChange?.(null, { status, ...props }));\n const pause = useEventCallback(() => setRunning(false));\n const play = useEventCallback(() => {\n if (imperativePauseRef.current) {\n return;\n }\n const containsActive = !!toastRef.current?.contains(targetDocument?.activeElement ?? null);\n if (timerTimeout < 0) {\n setRunning(true);\n return;\n }\n\n if (!containsActive) {\n setRunning(true);\n }\n });\n\n React.useImperativeHandle(imperativeRef, () => ({\n focus: () => {\n if (!toastRef.current) {\n return;\n }\n\n toastRef.current.focus();\n },\n\n play: () => {\n imperativePauseRef.current = false;\n play();\n },\n pause: () => {\n imperativePauseRef.current = true;\n pause();\n },\n }));\n\n React.useEffect(() => {\n return () => onStatusChange('unmounted');\n }, [onStatusChange]);\n\n React.useEffect(() => {\n if (!targetDocument) {\n return;\n }\n\n if (pauseOnWindowBlur) {\n targetDocument.defaultView?.addEventListener('focus', play);\n targetDocument.defaultView?.addEventListener('blur', pause);\n return () => {\n targetDocument.defaultView?.removeEventListener('focus', play);\n targetDocument.defaultView?.removeEventListener('blur', pause);\n };\n }\n }, [targetDocument, pause, play, pauseOnWindowBlur]);\n\n // It's impossible to animate to height: auto in CSS, the actual pixel value must be known\n // Get the height of the toast before animation styles have been applied and set a CSS\n // variable with its height. The CSS variable will be used by the styles\n const onTransitionEntering = () => {\n if (!toastRef.current) {\n return;\n }\n\n const element = toastRef.current;\n element.style.setProperty('--fui-toast-height', `${element.scrollHeight}px`);\n };\n\n // Users never actually use ToastContainer as a JSX but imperatively through useToastContainerController\n const userRootSlot = (data as { root?: ExtractSlotProps<Slot<'div'>> }).root;\n\n // Using a ref callback here because addEventListener supports `once`\n const toastAnimationRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n if (el && toastRef.current) {\n toastRef.current.addEventListener(\n 'animationend',\n () => {\n // start toast once it's fully animated in\n play();\n onStatusChange('visible');\n },\n { once: true },\n );\n }\n },\n [play, onStatusChange],\n );\n\n const onMouseEnter = useEventCallback((e: React.MouseEvent<HTMLDivElement>) => {\n pause();\n userRootSlot?.onMouseEnter?.(e);\n });\n\n const onMouseLeave = useEventCallback((e: React.MouseEvent<HTMLDivElement>) => {\n play();\n userRootSlot?.onMouseEnter?.(e);\n });\n\n const { findFirstFocusable, findLastFocusable } = useFocusFinders();\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Delete) {\n e.preventDefault();\n close();\n }\n\n if (e.key === Tab && e.currentTarget === e.target) {\n e.preventDefault();\n if (e.shiftKey) {\n findLastFocusable(e.currentTarget)?.focus();\n } else {\n findFirstFocusable(e.currentTarget)?.focus();\n }\n }\n\n userRootSlot?.onKeyDown?.(e);\n });\n\n React.useEffect(() => {\n if (!visible) {\n return;\n }\n\n const politeness = desiredPoliteness ?? intentPolitenessMap[intent];\n announce(toastRef.current?.textContent ?? '', { politeness });\n }, [announce, desiredPoliteness, toastRef, visible, updateId, intent]);\n\n React.useEffect(() => {\n return () => {\n if (focusedToastBeforeClose.current) {\n focusedToastBeforeClose.current = false;\n tryRestoreFocus();\n }\n };\n }, [tryRestoreFocus]);\n\n return {\n components: {\n timer: Timer,\n root: 'div',\n },\n timer: slot.always<TimerProps>(\n { key: updateId, onTimeout: close, running, timeout: timerTimeout ?? -1 },\n { elementType: Timer },\n ),\n root: slot.always(\n getNativeElementProps('div', {\n ref: useMergedRefs(ref, toastRef, toastAnimationRef),\n children,\n tabIndex: 0,\n role: 'listitem',\n 'aria-labelledby': titleId,\n 'aria-describedby': bodyId,\n ...rest,\n ...userRootSlot,\n ...focusableGroupAttribute,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n }),\n { elementType: 'div' },\n ),\n timerTimeout,\n transitionTimeout: 500,\n running,\n visible,\n remove,\n close,\n onTransitionEntering,\n updateId,\n nodeRef: toastRef,\n intent,\n titleId,\n bodyId,\n };\n};\n"],"names":["React","getNativeElementProps","useMergedRefs","useEventCallback","useId","slot","useFluent_unstable","Delete","Tab","useFocusableGroup","useFocusFinders","Timer","intentPolitenessMap","success","warning","error","info","useToastContainer_unstable","props","ref","visible","children","close","closeProp","remove","updateId","announce","data","timeout","timerTimeout","politeness","desiredPoliteness","intent","pauseOnHover","pauseOnWindowBlur","imperativeRef","tryRestoreFocus","rest","titleId","bodyId","toastRef","useRef","targetDocument","running","setRunning","useState","imperativePauseRef","focusedToastBeforeClose","focusableGroupAttribute","tabBehavior","ignoreDefaultKeydown","Escape","Enter","activeElement","current","contains","onStatusChange","status","pause","play","containsActive","useImperativeHandle","focus","useEffect","defaultView","addEventListener","removeEventListener","onTransitionEntering","element","style","setProperty","scrollHeight","userRootSlot","root","toastAnimationRef","useCallback","el","once","onMouseEnter","e","onMouseLeave","findFirstFocusable","findLastFocusable","onKeyDown","key","preventDefault","currentTarget","target","shiftKey","textContent","components","timer","always","onTimeout","elementType","tabIndex","role","transitionTimeout","nodeRef"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,qBAAqB,EACrBC,aAAa,EAGbC,gBAAgB,EAChBC,KAAK,EACLC,IAAI,QACC,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,MAAM,EAAEC,GAAG,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,0BAA0B;AAG7E,SAASC,KAAK,QAAoB,iBAAiB;AAEnD,MAAMC,sBAAsB;IAC1BC,SAAS;IACTC,SAAS;IAC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AC1B8B;YACAE;YACAG;QACF,IACA;YAAEW,aAAa;QAAM;QAEvBjE;QACAoE,mBAAmB;QACnBtD;QACAvB;QACAI;QACAF;QACA6C;QACA1C;QACAyE,SAAS1D;QACTR;QACAM;QACAC;IACF;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["useToastContainer.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getNativeElementProps,\n useMergedRefs,\n ExtractSlotProps,\n Slot,\n useEventCallback,\n useId,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { Delete, Tab } from '@fluentui/keyboard-keys';\nimport { useFocusableGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { ToastStatus } from '../../state';\nimport type { ToastContainerProps, ToastContainerState } from './ToastContainer.types';\nimport { Timer, TimerProps } from '../Timer/Timer';\n\nconst intentPolitenessMap = {\n success: 'assertive',\n warning: 'assertive',\n error: 'assertive',\n info: 'polite',\n} as const;\n\n/**\n * Create the state required to render ToastContainer.\n *\n * The returned state can be modified with hooks such as useToastContainerStyles_unstable,\n * before being passed to renderToastContainer_unstable.\n *\n * @param props - props from this instance of ToastContainer\n * @param ref - reference to root HTMLElement of ToastContainer\n */\nexport const useToastContainer_unstable = (\n props: ToastContainerProps,\n ref: React.Ref<HTMLElement>,\n): ToastContainerState => {\n const {\n visible,\n children,\n close: closeProp,\n remove,\n updateId,\n announce,\n data,\n timeout: timerTimeout,\n politeness: desiredPoliteness,\n intent = 'info',\n pauseOnHover,\n pauseOnWindowBlur,\n imperativeRef,\n tryRestoreFocus,\n ...rest\n } = props;\n const titleId = useId('toast-title');\n const bodyId = useId('toast-body');\n const toastRef = React.useRef<HTMLDivElement | null>(null);\n const { targetDocument } = useFluent_unstable();\n const [running, setRunning] = React.useState(false);\n const imperativePauseRef = React.useRef(false);\n const focusedToastBeforeClose = React.useRef(false);\n const focusableGroupAttribute = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n // Users should only use Tab to focus into the toast\n // Escape is already reserved to dismiss all toasts\n ignoreDefaultKeydown: { Tab: true, Escape: true, Enter: true },\n });\n\n const close = useEventCallback(() => {\n const activeElement = targetDocument?.activeElement;\n if (activeElement && toastRef.current?.contains(activeElement)) {\n focusedToastBeforeClose.current = true;\n }\n\n closeProp();\n });\n const onStatusChange = useEventCallback((status: ToastStatus) => props.onStatusChange?.(null, { status, ...props }));\n const pause = useEventCallback(() => setRunning(false));\n const play = useEventCallback(() => {\n if (imperativePauseRef.current) {\n return;\n }\n const containsActive = !!toastRef.current?.contains(targetDocument?.activeElement ?? null);\n if (timerTimeout < 0) {\n setRunning(true);\n return;\n }\n\n if (!containsActive) {\n setRunning(true);\n }\n });\n\n React.useImperativeHandle(imperativeRef, () => ({\n focus: () => {\n if (!toastRef.current) {\n return;\n }\n\n toastRef.current.focus();\n },\n\n play: () => {\n imperativePauseRef.current = false;\n play();\n },\n pause: () => {\n imperativePauseRef.current = true;\n pause();\n },\n }));\n\n React.useEffect(() => {\n return () => onStatusChange('unmounted');\n }, [onStatusChange]);\n\n React.useEffect(() => {\n if (!targetDocument) {\n return;\n }\n\n if (pauseOnWindowBlur) {\n targetDocument.defaultView?.addEventListener('focus', play);\n targetDocument.defaultView?.addEventListener('blur', pause);\n return () => {\n targetDocument.defaultView?.removeEventListener('focus', play);\n targetDocument.defaultView?.removeEventListener('blur', pause);\n };\n }\n }, [targetDocument, pause, play, pauseOnWindowBlur]);\n\n // It's impossible to animate to height: auto in CSS, the actual pixel value must be known\n // Get the height of the toast before animation styles have been applied and set a CSS\n // variable with its height. The CSS variable will be used by the styles\n const onTransitionEntering = () => {\n if (!toastRef.current) {\n return;\n }\n\n const element = toastRef.current;\n element.style.setProperty('--fui-toast-height', `${element.scrollHeight}px`);\n };\n\n // Users never actually use ToastContainer as a JSX but imperatively through useToastContainerController\n const userRootSlot = (data as { root?: ExtractSlotProps<Slot<'div'>> }).root;\n\n // Using a ref callback here because addEventListener supports `once`\n const toastAnimationRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n if (el && toastRef.current) {\n toastRef.current.addEventListener(\n 'animationend',\n () => {\n // start toast once it's fully animated in\n play();\n onStatusChange('visible');\n },\n { once: true },\n );\n }\n },\n [play, onStatusChange],\n );\n\n const onMouseEnter = useEventCallback((e: React.MouseEvent<HTMLDivElement>) => {\n pause();\n userRootSlot?.onMouseEnter?.(e);\n });\n\n const onMouseLeave = useEventCallback((e: React.MouseEvent<HTMLDivElement>) => {\n play();\n userRootSlot?.onMouseEnter?.(e);\n });\n\n const { findFirstFocusable, findLastFocusable } = useFocusFinders();\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Delete) {\n e.preventDefault();\n close();\n }\n\n if (e.key === Tab && e.currentTarget === e.target) {\n e.preventDefault();\n if (e.shiftKey) {\n findLastFocusable(e.currentTarget)?.focus();\n } else {\n findFirstFocusable(e.currentTarget)?.focus();\n }\n }\n\n userRootSlot?.onKeyDown?.(e);\n });\n\n React.useEffect(() => {\n if (!visible) {\n return;\n }\n\n const politeness = desiredPoliteness ?? intentPolitenessMap[intent];\n announce(toastRef.current?.textContent ?? '', { politeness });\n }, [announce, desiredPoliteness, toastRef, visible, updateId, intent]);\n\n React.useEffect(() => {\n return () => {\n if (focusedToastBeforeClose.current) {\n focusedToastBeforeClose.current = false;\n tryRestoreFocus();\n }\n };\n }, [tryRestoreFocus]);\n\n return {\n components: {\n timer: Timer,\n root: 'div',\n },\n timer: slot.always<TimerProps>(\n { key: updateId, onTimeout: close, running, timeout: timerTimeout ?? -1 },\n { elementType: Timer },\n ),\n root: slot.always(\n getNativeElementProps('div', {\n ref: useMergedRefs(ref, toastRef, toastAnimationRef),\n children,\n tabIndex: 0,\n role: 'listitem',\n 'aria-labelledby': titleId,\n 'aria-describedby': bodyId,\n ...rest,\n ...userRootSlot,\n ...focusableGroupAttribute,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n }),\n { elementType: 'div' },\n ),\n timerTimeout,\n transitionTimeout: 500,\n running,\n visible,\n remove,\n close,\n onTransitionEntering,\n updateId,\n nodeRef: toastRef,\n intent,\n titleId,\n bodyId,\n };\n};\n"],"names":["React","getNativeElementProps","useMergedRefs","useEventCallback","useId","slot","useFluent_unstable","Delete","Tab","useFocusableGroup","useFocusFinders","Timer","intentPolitenessMap","success","warning","error","info","useToastContainer_unstable","props","ref","visible","children","close","closeProp","remove","updateId","announce","data","timeout","timerTimeout","politeness","desiredPoliteness","intent","pauseOnHover","pauseOnWindowBlur","imperativeRef","tryRestoreFocus","rest","titleId","bodyId","toastRef","useRef","targetDocument","running","setRunning","useState","imperativePauseRef","focusedToastBeforeClose","focusableGroupAttribute","tabBehavior","ignoreDefaultKeydown","Escape","Enter","activeElement","current","contains","onStatusChange","status","pause","play","containsActive","useImperativeHandle","focus","useEffect","defaultView","addEventListener","removeEventListener","onTransitionEntering","element","style","setProperty","scrollHeight","userRootSlot","root","toastAnimationRef","useCallback","el","once","onMouseEnter","e","onMouseLeave","findFirstFocusable","findLastFocusable","onKeyDown","key","preventDefault","currentTarget","target","shiftKey","textContent","components","timer","always","onTimeout","elementType","tabIndex","role","transitionTimeout","nodeRef"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,qBAAqB,EACrBC,aAAa,EAGbC,gBAAgB,EAChBC,KAAK,EACLC,IAAI,QACC,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,MAAM,EAAEC,GAAG,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,0BAA0B;AAG7E,SAASC,KAAK,QAAoB,iBAAiB;AAEnD,MAAMC,sBAAsB;IAC1BC,SAAS;IACTC,SAAS;IACTC,OAAO;IACPC,MAAM;AACR;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAM,EACJC,OAAO,EACPC,QAAQ,EACRC,OAAOC,SAAS,EAChBC,MAAM,E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cAAvBX,8CAAAA,6BAAAA,cAA0BO;IAC5B;IAEA/E,MAAM+D,SAAS,CAAC;YAMLvB;QALT,IAAI,CAACpB,SAAS;YACZ;QACF;QAEA,MAAMU,aAAaC,8BAAAA,+BAAAA,oBAAqBnB,mBAAmB,CAACoB,OAAO;YAC1DQ;QAATd,SAASc,CAAAA,iCAAAA,oBAAAA,SAASc,OAAO,cAAhBd,wCAAAA,kBAAkBiD,WAAW,cAA7BjD,2CAAAA,gCAAiC,IAAI;YAAEV;QAAW;IAC7D,GAAG;QAACJ;QAAUK;QAAmBS;QAAUpB;QAASK;QAAUO;KAAO;IAErEhC,MAAM+D,SAAS,CAAC;QACd,OAAO;YACL,IAAIhB,wBAAwBO,OAAO,EAAE;gBACnCP,wBAAwBO,OAAO,GAAG;gBAClClB;YACF;QACF;IACF,GAAG;QAACA;KAAgB;IAEpB,OAAO;QACLsD,YAAY;YACVC,OAAOhF;YACP8D,MAAM;QACR;QACAkB,OAAOtF,KAAKuF,MAAM,CAChB;YAAER,KAAK3D;YAAUoE,WAAWvE;YAAOqB;YAASf,SAASC,yBAAAA,0BAAAA,eAAgB,CAAC;QAAE,GACxE;YAAEiE,aAAanF;QAAM;QAEvB8D,MAAMpE,KAAKuF,MAAM,CACf3F,sBAAsB,OAAO;YAC3BkB,KAAKjB,cAAciB,KAAKqB,UAAUkC;YAClCrD;YACA0E,UAAU;YACVC,MAAM;YACN,mBAAmB1D;YACnB,oBAAoBC;YACpB,GAAGF,IAAI;YACP,GAAGmC,YAAY;YACf,GAAGxB,uBAAuB;YAC1B8B;YACAE;YACAG;QACF,IACA;YAAEW,aAAa;QAAM;QAEvBjE;QACAoE,mBAAmB;QACnBtD;QACAvB;QACAI;QACAF;QACA6C;QACA1C;QACAyE,SAAS1D;QACTR;QACAM;QACAC;IACF;AACF,EAAE"}
|
|
@@ -11,23 +11,22 @@ import { useToastContainerContext } from '../../contexts/toastContainerContext';
|
|
|
11
11
|
* Besides being a trigger that closes a toast through context this component doesn't do much,
|
|
12
12
|
* making it basically unnecessary in cases where the trigger is outside of a toast.
|
|
13
13
|
*/ export const useToastTrigger_unstable = (props)=>{
|
|
14
|
-
var _child, _child1, _child2, _child3;
|
|
15
14
|
const { children, disableButtonEnhancement = false } = props;
|
|
16
15
|
const { close } = useToastContainerContext();
|
|
17
16
|
const child = getTriggerChild(children);
|
|
18
17
|
const handleClick = useEventCallback((e)=>{
|
|
19
|
-
var _child_props_onClick,
|
|
20
|
-
|
|
18
|
+
var _child_props_onClick, _child_props;
|
|
19
|
+
child === null || child === void 0 ? void 0 : (_child_props_onClick = (_child_props = child.props).onClick) === null || _child_props_onClick === void 0 ? void 0 : _child_props_onClick.call(_child_props, e);
|
|
21
20
|
if (!e.isDefaultPrevented()) {
|
|
22
21
|
close();
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
24
|
const triggerChildProps = {
|
|
26
|
-
...
|
|
27
|
-
ref:
|
|
25
|
+
...child === null || child === void 0 ? void 0 : child.props,
|
|
26
|
+
ref: child === null || child === void 0 ? void 0 : child.ref,
|
|
28
27
|
onClick: handleClick
|
|
29
28
|
};
|
|
30
|
-
const ariaButtonTriggerChildProps = useARIAButtonProps((
|
|
29
|
+
const ariaButtonTriggerChildProps = useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', {
|
|
31
30
|
...triggerChildProps,
|
|
32
31
|
type: 'button'
|
|
33
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, getTriggerChild, useEventCallback } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: child?.ref,\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","
|
|
1
|
+
{"version":3,"sources":["useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, getTriggerChild, useEventCallback } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: child?.ref,\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","children","disableButtonEnhancement","close","child","handleClick","e","onClick","isDefaultPrevented","triggerChildProps","ref","ariaButtonTriggerChildProps","type"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,4BAA4B;AAC3G,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,wBAAwB,QAAQ,uCAAuC;AAEhF;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGF;IACvD,MAAM,EAAEG,KAAK,EAAE,GAAGL;IAElB,MAAMM,QAAQT,gBAAgBM;IAE9B,MAAMI,cAAcT,iBAClB,CAACU;YACCF,sBAAAA;QAAAA,kBAAAA,6BAAAA,uBAAAA,CAAAA,eAAAA,MAAOJ,KAAK,EAACO,OAAO,cAApBH,2CAAAA,0BAAAA,cAAuBE;QACvB,IAAI,CAACA,EAAEE,kBAAkB,IAAI;YAC3BL;QACF;IACF;IAGF,MAAMM,oBAAoB;WACrBL,kBAAAA,4BAAAA,MAAOJ,KAAK,AAAf;QACAU,GAAG,EAAEN,kBAAAA,4BAAAA,MAAOM,GAAG;QACfH,SAASF;IACX;IAEA,MAAMM,8BAA8Bd,mBAClCO,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,YAAYR,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,MAAMR,MAAMQ,IAAI,GAAG,OAC/D;QACE,GAAGH,iBAAiB;QACpBG,MAAM;IACR;IAGF,OAAO;QACLX,UAAUP,4BACRO,UACAC,2BAA2BO,oBAAoBE;IAEnD;AACF,EAAE"}
|
|
@@ -27,12 +27,12 @@ import { useToastAnnounce } from './useToastAnnounce';
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
const onKeyDown = useEventCallback((e)=>{
|
|
30
|
-
var _props_onKeyDown
|
|
30
|
+
var _props_onKeyDown;
|
|
31
31
|
if (e.key === Escape) {
|
|
32
32
|
e.preventDefault();
|
|
33
33
|
closeAllToasts();
|
|
34
34
|
}
|
|
35
|
-
(_props_onKeyDown =
|
|
35
|
+
(_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);
|
|
36
36
|
});
|
|
37
37
|
const usePositionSlot = (toastPosition)=>{
|
|
38
38
|
var _toastsToRender_get;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getNativeElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const rootProps = slot.always(getNativeElementProps('div', rest), { elementType: 'div' });\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n props.onKeyDown?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getNativeElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","onKeyDown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAGEC,qBAAqB,EACrBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,MAAM,QAAQ,0BAA0B;AAEjD,SAASC,eAAe,EAAiBC,UAAU,QAAQ,cAAc;AAEzE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,kCAAkC,QAAQ,8BAA8B;AACjF,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,UAAUC,YAAY,EAAEC,SAAS,EAAEC,SAAS,KAAK,EAAE,GAAGC,MAAM,GAAGN;IAC/E,MAAMO,cAActB,MAAMuB,MAAM,CAAW,IAAM;IACjD,MAAM,EAAEC,cAAc,EAAEC,cAAc,EAAEC,cAAc,EAAEC,aAAa,EAAEC,eAAe,EAAEC,cAAc,EAAE,GACtGnB,WAA2BW;IAC7B,MAAMJ,WAAWjB,MAAM8B,WAAW,CAAW,CAACC,SAASC,UAAYV,YAAYW,OAAO,CAACF,SAASC,UAAU,EAAE;IAC5G,MAAM,EAAEE,GAAG,EAAE,GAAG5B;IAEhB,MAAM6B,YAAY/B,KAAKgC,MAAM,CAACnC,sBAAsB,OAAOoB,OAAO;QAAEgB,aAAa;IAAM;IACvF,MAAMC,qBAAqB/B,kBAAkB;QAC3CgC,aAAa;QACbC,sBAAsB;YAAEhC,QAAQ;QAAK;IACvC;IACA,MAAMiC,YAAYvC,iBAAiB,CAACwC;YAKlC3B
|
|
1
|
+
{"version":3,"sources":["useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getNativeElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const rootProps = slot.always(getNativeElementProps('div', rest), { elementType: 'div' });\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n props.onKeyDown?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getNativeElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","onKeyDown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAGEC,qBAAqB,EACrBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,MAAM,QAAQ,0BAA0B;AAEjD,SAASC,eAAe,EAAiBC,UAAU,QAAQ,cAAc;AAEzE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,kCAAkC,QAAQ,8BAA8B;AACjF,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,UAAUC,YAAY,EAAEC,SAAS,EAAEC,SAAS,KAAK,EAAE,GAAGC,MAAM,GAAGN;IAC/E,MAAMO,cAActB,MAAMuB,MAAM,CAAW,IAAM;IACjD,MAAM,EAAEC,cAAc,EAAEC,cAAc,EAAEC,cAAc,EAAEC,aAAa,EAAEC,eAAe,EAAEC,cAAc,EAAE,GACtGnB,WAA2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AAY;YACVC,MAAM;YACNC,aAAa;YACbC,WAAW;YACXC,UAAU;YACVC,QAAQ;YACRC,KAAK;YACLC,QAAQ;QACV;QACAN,MAAM5D,KAAKgC,MAAM,CAACD,WAAW;YAAEE,aAAa;QAAM;QAClD4B,aAAapB,gBAAgBpC,gBAAgBwD,WAAW;QACxDC,WAAWrB,gBAAgBpC,gBAAgByD,SAAS;QACpDC,UAAUtB,gBAAgBpC,gBAAgB0D,QAAQ;QAClDC,QAAQvB,gBAAgBpC,gBAAgB2D,MAAM;QAC9CC,KAAKxB,gBAAgBpC,gBAAgB4D,GAAG;QACxCC,QAAQzB,gBAAgBpC,gBAAgB6D,MAAM;QAC9ChD;QACAN;QACAC,UAAUC,yBAAAA,0BAAAA,eAAgBD;QAC1BsD,gBAAgB,CAACrD;QACjBE;IACF;AACF,EAAE"}
|
|
@@ -7,5 +7,7 @@ const toastContainerContextDefaultValue = {
|
|
|
7
7
|
};
|
|
8
8
|
const ToastContainerContext = /*#__PURE__*/ React.createContext(undefined);
|
|
9
9
|
export const ToastContainerContextProvider = ToastContainerContext.Provider;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export const useToastContainerContext = ()=>{
|
|
11
|
+
var _React_useContext;
|
|
12
|
+
return (_React_useContext = React.useContext(ToastContainerContext)) !== null && _React_useContext !== void 0 ? _React_useContext : toastContainerContextDefaultValue;
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["toastContainerContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ToastIntent } from '../state/types';\n\nexport type ToastContainerContextValue = {\n close: () => void;\n intent: ToastIntent | undefined;\n bodyId: string;\n titleId: string;\n};\n\nconst toastContainerContextDefaultValue: ToastContainerContextValue = {\n close: () => null,\n intent: undefined,\n bodyId: '',\n titleId: '',\n};\n\nconst ToastContainerContext = React.createContext<ToastContainerContextValue | undefined>(undefined);\n\nexport const ToastContainerContextProvider = ToastContainerContext.Provider;\nexport const useToastContainerContext = () =>\n React.useContext(ToastContainerContext) ?? toastContainerContextDefaultValue;\n"],"names":["React","toastContainerContextDefaultValue","close","intent","undefined","bodyId","titleId","ToastContainerContext","createContext","ToastContainerContextProvider","Provider","useToastContainerContext","useContext"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAU/B,MAAMC,oCAAgE;IACpEC,OAAO,IAAM;IACbC,QAAQC;IACRC,QAAQ;IACRC,SAAS;AACX;AAEA,MAAMC,sCAAwBP,MAAMQ,aAAa,CAAyCJ;AAE1F,OAAO,MAAMK,gCAAgCF,sBAAsBG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["toastContainerContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ToastIntent } from '../state/types';\n\nexport type ToastContainerContextValue = {\n close: () => void;\n intent: ToastIntent | undefined;\n bodyId: string;\n titleId: string;\n};\n\nconst toastContainerContextDefaultValue: ToastContainerContextValue = {\n close: () => null,\n intent: undefined,\n bodyId: '',\n titleId: '',\n};\n\nconst ToastContainerContext = React.createContext<ToastContainerContextValue | undefined>(undefined);\n\nexport const ToastContainerContextProvider = ToastContainerContext.Provider;\nexport const useToastContainerContext = () =>\n React.useContext(ToastContainerContext) ?? toastContainerContextDefaultValue;\n"],"names":["React","toastContainerContextDefaultValue","close","intent","undefined","bodyId","titleId","ToastContainerContext","createContext","ToastContainerContextProvider","Provider","useToastContainerContext","useContext"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAU/B,MAAMC,oCAAgE;IACpEC,OAAO,IAAM;IACbC,QAAQC;IACRC,QAAQ;IACRC,SAAS;AACX;AAEA,MAAMC,sCAAwBP,MAAMQ,aAAa,CAAyCJ;AAE1F,OAAO,MAAMK,gCAAgCF,sBAAsBG,QAAQ,CAAC;AAC5E,OAAO,MAAMC,2BAA2B;QACtCX;WAAAA,CAAAA,oBAAAA,MAAMY,UAAU,CAACL,oCAAjBP,+BAAAA,oBAA2CC;AAAgC,EAAE"}
|