@box/blueprint-web 9.16.4 → 9.16.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.
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Viewport } from '@radix-ui/react-toast';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
4
|
+
import { forwardRef, useEffect } from 'react';
|
|
5
5
|
import { useNotification } from './notification-provider.js';
|
|
6
6
|
import styles from './notification.module.js';
|
|
7
7
|
import { PrivateNotificationElement } from './private-notification-element.js';
|
|
8
8
|
|
|
9
|
+
const VIEWPORT_DEFAULT_HOTKEY = ['F8'];
|
|
9
10
|
/**
|
|
10
11
|
* Renders container with Notifications.
|
|
11
12
|
*
|
|
@@ -14,15 +15,33 @@ import { PrivateNotificationElement } from './private-notification-element.js';
|
|
|
14
15
|
const NotificationViewport = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
15
16
|
const {
|
|
16
17
|
className,
|
|
18
|
+
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
17
19
|
...rest
|
|
18
20
|
} = props;
|
|
19
21
|
const {
|
|
20
22
|
notifications
|
|
21
23
|
} = useNotification();
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const handleKeyDown = event => {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const isHotkeyPressed = hotkey.every(key => event[key] || event.code === key);
|
|
28
|
+
// check `isComposing` to fix issue with japanese input, see:
|
|
29
|
+
// https://github.com/radix-ui/primitives/pull/2558
|
|
30
|
+
if (isHotkeyPressed && event.isComposing) {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
document.addEventListener('keydown', handleKeyDown, {
|
|
35
|
+
capture: true,
|
|
36
|
+
passive: true
|
|
37
|
+
});
|
|
38
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
39
|
+
}, [hotkey]);
|
|
22
40
|
return jsx(Viewport, {
|
|
23
41
|
...rest,
|
|
24
42
|
ref: forwardedRef,
|
|
25
43
|
className: clsx(styles.viewport, className),
|
|
44
|
+
hotkey: hotkey,
|
|
26
45
|
children: Array.from(notifications.values()).map(({
|
|
27
46
|
key,
|
|
28
47
|
...notificationProps
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "9.16.
|
|
3
|
+
"version": "9.16.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"react-stately": "^3.31.1",
|
|
63
63
|
"tsx": "^4.16.5"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "dd2e399ce63c71557eaf5ec841ae62ce0a7d18a2",
|
|
66
66
|
"module": "lib-esm/index.js",
|
|
67
67
|
"main": "lib-esm/index.js",
|
|
68
68
|
"types": "lib-esm/index.d.ts",
|