@box/blueprint-web 19.6.0 → 20.0.0
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/THIRD_PARTY_LICENSES +119 -0
- package/dist/lib-esm/accordion/accordion.js +6 -6
- package/dist/lib-esm/accordion/types.d.ts +1 -1
- package/dist/lib-esm/checkbox/checkbox-item.js +3 -3
- package/dist/lib-esm/checkbox/types.d.ts +1 -1
- package/dist/lib-esm/collapsible/collapsible-section.js +5 -5
- package/dist/lib-esm/collapsible/types.d.ts +1 -1
- package/dist/lib-esm/combobox-group/combobox-group-combobox.js +1 -1
- package/dist/lib-esm/date-picker/date-picker.js +8 -7
- package/dist/lib-esm/guided-tooltip/guided-tooltip.js +7 -7
- package/dist/lib-esm/guided-tooltip/types.d.ts +1 -1
- package/dist/lib-esm/modal/alert-modal.types.d.ts +1 -1
- package/dist/lib-esm/modal/modal-close.js +2 -2
- package/dist/lib-esm/modal/modal-content.d.ts +1 -1
- package/dist/lib-esm/modal/modal-content.js +4 -4
- package/dist/lib-esm/modal/modal-description.js +2 -2
- package/dist/lib-esm/modal/modal-title.js +2 -2
- package/dist/lib-esm/modal/modal-trigger.js +2 -2
- package/dist/lib-esm/modal/modal.d.ts +1 -1
- package/dist/lib-esm/modal/modal.js +1 -1
- package/dist/lib-esm/modal/types.d.ts +1 -1
- package/dist/lib-esm/navigation-menu/index.d.ts +4 -2
- package/dist/lib-esm/navigation-menu/navigation-menu-item.d.ts +1 -1
- package/dist/lib-esm/navigation-menu/navigation-menu-trigger.d.ts +3 -1
- package/dist/lib-esm/primitives/chips/chip.d.ts +1 -1
- package/dist/lib-esm/primitives/chips/chip.js +2 -2
- package/dist/lib-esm/primitives/chips/chips-group.js +2 -2
- package/dist/lib-esm/primitives/chips/filter-chip/filter-chip-button.d.ts +1 -1
- package/dist/lib-esm/primitives/chips/filter-chip/filter-chip.d.ts +1 -1
- package/dist/lib-esm/primitives/chips/filter-chip/filter-combo-chip.d.ts +2 -2
- package/dist/lib-esm/primitives/chips/filter-chip/filter-trigger-chip.d.ts +1 -1
- package/dist/lib-esm/primitives/chips/filter-chip/index.d.ts +5 -5
- package/dist/lib-esm/primitives/chips/types.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-item.d.ts +2 -2
- package/dist/lib-esm/primitives/context-menu/context-menu-item.js +2 -2
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-content.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-content.js +5 -5
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-header.js +3 -10
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-root.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-root.js +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-trigger.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-menu-trigger.js +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-content.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-content.js +5 -5
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-root.d.ts +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-root.js +1 -1
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-trigger.d.ts +2 -2
- package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-trigger.js +1 -1
- package/dist/lib-esm/primitives/context-menu/index.d.ts +3 -3
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-checkbox-item.d.ts +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-checkbox-item.js +3 -3
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-content.d.ts +1 -1
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-content.js +5 -5
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-group.d.ts +4 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-group.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-item.d.ts +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-item.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-group.d.ts +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-group.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-select-item.d.ts +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-select-item.js +3 -3
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-root.d.ts +1 -1
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-root.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-header.d.ts +4 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-header.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-content.d.ts +1 -1
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-content.js +5 -5
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.d.ts +1 -1
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-trigger.d.ts +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-trigger.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-trigger.d.ts +4 -2
- package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-trigger.js +2 -2
- package/dist/lib-esm/primitives/dropdown-menu/index.d.ts +14 -8
- package/dist/lib-esm/primitives/notification/hooks/use-notification-layer.d.ts +15 -0
- package/dist/lib-esm/primitives/notification/hooks/use-notification-layer.js +49 -0
- package/dist/lib-esm/primitives/notification/notification-provider.js +2 -2
- package/dist/lib-esm/primitives/notification/notification.viewport-animated.js +12 -8
- package/dist/lib-esm/primitives/notification/notification.viewport.js +5 -1
- package/dist/lib-esm/primitives/notification/private-notification-element-animated.js +44 -6
- package/dist/lib-esm/primitives/notification/private-notification-element.js +34 -4
- package/dist/lib-esm/primitives/popover/index.d.ts +11 -5
- package/dist/lib-esm/primitives/popover/popover-anchor.d.ts +4 -2
- package/dist/lib-esm/primitives/popover/popover-anchor.js +2 -2
- package/dist/lib-esm/primitives/popover/popover-close.d.ts +4 -2
- package/dist/lib-esm/primitives/popover/popover-close.js +2 -2
- package/dist/lib-esm/primitives/popover/popover-content-container.d.ts +1 -1
- package/dist/lib-esm/primitives/popover/popover-content-container.js +3 -3
- package/dist/lib-esm/primitives/popover/popover-footer.d.ts +1 -1
- package/dist/lib-esm/primitives/popover/popover-main-content.d.ts +1 -1
- package/dist/lib-esm/primitives/popover/popover-root.d.ts +1 -1
- package/dist/lib-esm/primitives/popover/popover-root.js +2 -2
- package/dist/lib-esm/primitives/popover/popover-trigger.d.ts +4 -2
- package/dist/lib-esm/primitives/popover/popover-trigger.js +2 -2
- package/dist/lib-esm/radio-group/index.d.ts +1 -1
- package/dist/lib-esm/radio-group/radio-group.d.ts +1 -1
- package/dist/lib-esm/radio-group/radio-group.js +2 -2
- package/dist/lib-esm/radio-group/radio-item.js +3 -3
- package/dist/lib-esm/radio-group/types.d.ts +1 -1
- package/dist/lib-esm/select/select.js +12 -12
- package/dist/lib-esm/select/types.d.ts +1 -1
- package/dist/lib-esm/select/utils/use-select-exit-animation.d.ts +3 -3
- package/dist/lib-esm/select/utils/use-select-exit-animation.js +3 -3
- package/dist/lib-esm/side-panel/side-panel-close.js +2 -2
- package/dist/lib-esm/side-panel/side-panel-content.js +3 -3
- package/dist/lib-esm/side-panel/side-panel-header.js +2 -2
- package/dist/lib-esm/side-panel/side-panel-overlay.js +3 -3
- package/dist/lib-esm/side-panel/side-panel-trigger.js +2 -2
- package/dist/lib-esm/side-panel/side-panel.js +1 -1
- package/dist/lib-esm/side-panel/types.d.ts +1 -1
- package/dist/lib-esm/switch/switch-item.js +3 -3
- package/dist/lib-esm/switch/types.d.ts +1 -1
- package/dist/lib-esm/toolbar/index.d.ts +2 -2
- package/dist/lib-esm/toolbar/toolbar-button.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-input.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-link.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-root.js +3 -3
- package/dist/lib-esm/toolbar/toolbar-separator.d.ts +1 -1
- package/dist/lib-esm/toolbar/toolbar-separator.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-text-toggle-item.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-toggle-group.d.ts +1 -2
- package/dist/lib-esm/toolbar/toolbar-toggle-group.js +2 -2
- package/dist/lib-esm/toolbar/toolbar-toggle-item.js +2 -2
- package/dist/lib-esm/toolbar/types.d.ts +1 -1
- package/dist/lib-esm/tooltip/tooltip.d.ts +1 -1
- package/dist/lib-esm/tooltip/tooltip.js +6 -6
- package/dist/lib-esm/tooltip/types.d.ts +1 -1
- package/dist/lib-esm/utils/radix-compat/accordion.d.ts +45 -0
- package/dist/lib-esm/utils/radix-compat/accordion.js +299 -0
- package/dist/lib-esm/utils/radix-compat/allow-auto-focus.d.ts +9 -0
- package/dist/lib-esm/utils/radix-compat/allow-auto-focus.js +16 -0
- package/dist/lib-esm/utils/radix-compat/bubble-input.d.ts +14 -0
- package/dist/lib-esm/utils/radix-compat/bubble-input.js +70 -0
- package/dist/lib-esm/utils/radix-compat/button-controls.d.ts +9 -0
- package/dist/lib-esm/utils/radix-compat/button-controls.js +6 -0
- package/dist/lib-esm/utils/radix-compat/checkbox.d.ts +18 -0
- package/dist/lib-esm/utils/radix-compat/checkbox.js +131 -0
- package/dist/lib-esm/utils/radix-compat/collapsible.d.ts +33 -0
- package/dist/lib-esm/utils/radix-compat/collapsible.js +133 -0
- package/dist/lib-esm/utils/radix-compat/collection.d.ts +21 -0
- package/dist/lib-esm/utils/radix-compat/collection.js +82 -0
- package/dist/lib-esm/utils/radix-compat/compose-refs.d.ts +8 -0
- package/dist/lib-esm/utils/radix-compat/compose-refs.js +44 -0
- package/dist/lib-esm/utils/radix-compat/content-size.d.ts +15 -0
- package/dist/lib-esm/utils/radix-compat/content-size.js +61 -0
- package/dist/lib-esm/utils/radix-compat/context-menu.d.ts +56 -0
- package/dist/lib-esm/utils/radix-compat/context-menu.js +191 -0
- package/dist/lib-esm/utils/radix-compat/dialog.d.ts +50 -0
- package/dist/lib-esm/utils/radix-compat/dialog.js +367 -0
- package/dist/lib-esm/utils/radix-compat/dismiss-marker.d.ts +5 -0
- package/dist/lib-esm/utils/radix-compat/dismiss-marker.js +12 -0
- package/dist/lib-esm/utils/radix-compat/dismissable.d.ts +34 -0
- package/dist/lib-esm/utils/radix-compat/dismissable.js +205 -0
- package/dist/lib-esm/utils/radix-compat/dropdown-menu.d.ts +57 -0
- package/dist/lib-esm/utils/radix-compat/dropdown-menu.js +187 -0
- package/dist/lib-esm/utils/radix-compat/focus-scope-component.d.ts +16 -0
- package/dist/lib-esm/utils/radix-compat/focus-scope-component.js +41 -0
- package/dist/lib-esm/utils/radix-compat/focus-scope.d.ts +37 -0
- package/dist/lib-esm/utils/radix-compat/focus-scope.js +288 -0
- package/dist/lib-esm/utils/radix-compat/hide-others.d.ts +6 -0
- package/dist/lib-esm/utils/radix-compat/hide-others.js +18 -0
- package/dist/lib-esm/utils/radix-compat/index.d.ts +14 -0
- package/dist/lib-esm/utils/radix-compat/layers.d.ts +25 -0
- package/dist/lib-esm/utils/radix-compat/layers.js +61 -0
- package/dist/lib-esm/utils/radix-compat/menu.d.ts +98 -0
- package/dist/lib-esm/utils/radix-compat/menu.js +1041 -0
- package/dist/lib-esm/utils/radix-compat/popover.d.ts +44 -0
- package/dist/lib-esm/utils/radix-compat/popover.js +386 -0
- package/dist/lib-esm/utils/radix-compat/popper.d.ts +60 -0
- package/dist/lib-esm/utils/radix-compat/popper.js +416 -0
- package/dist/lib-esm/utils/radix-compat/portal.d.ts +11 -0
- package/dist/lib-esm/utils/radix-compat/portal.js +20 -0
- package/dist/lib-esm/utils/radix-compat/presence.d.ts +20 -0
- package/dist/lib-esm/utils/radix-compat/presence.js +110 -0
- package/dist/lib-esm/utils/radix-compat/radio-group.d.ts +27 -0
- package/dist/lib-esm/utils/radix-compat/radio-group.js +189 -0
- package/dist/lib-esm/utils/radix-compat/roving-focus.d.ts +35 -0
- package/dist/lib-esm/utils/radix-compat/roving-focus.js +237 -0
- package/dist/lib-esm/utils/radix-compat/select.d.ts +82 -0
- package/dist/lib-esm/utils/radix-compat/select.js +901 -0
- package/dist/lib-esm/utils/radix-compat/slot.d.ts +31 -0
- package/dist/lib-esm/utils/radix-compat/slot.js +119 -0
- package/dist/lib-esm/utils/radix-compat/store-options.d.ts +8 -0
- package/dist/lib-esm/utils/radix-compat/store-options.js +10 -0
- package/dist/lib-esm/utils/radix-compat/switch.d.ts +16 -0
- package/dist/lib-esm/utils/radix-compat/switch.js +97 -0
- package/dist/lib-esm/utils/radix-compat/toggle-group.d.ts +41 -0
- package/dist/lib-esm/utils/radix-compat/toggle-group.js +195 -0
- package/dist/lib-esm/utils/radix-compat/toolbar.d.ts +32 -0
- package/dist/lib-esm/utils/radix-compat/toolbar.js +136 -0
- package/dist/lib-esm/utils/radix-compat/tooltip.d.ts +59 -0
- package/dist/lib-esm/utils/radix-compat/tooltip.js +636 -0
- package/dist/lib-esm/utils/radix-compat/typeahead.d.ts +22 -0
- package/dist/lib-esm/utils/radix-compat/typeahead.js +64 -0
- package/dist/lib-esm/utils/radix-compat/types.d.ts +53 -0
- package/dist/lib-esm/utils/radix-compat/viewport-height.d.ts +5 -0
- package/dist/lib-esm/utils/radix-compat/viewport-height.js +28 -0
- package/dist/lib-esm/utils/radix-compat/visually-hidden.d.ts +2 -0
- package/dist/lib-esm/utils/radix-compat/visually-hidden.js +24 -0
- package/package.json +8 -19
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuSubheaderProps = DropdownMenuPrimitive.DropdownMenuLabelProps;
|
|
3
|
-
export declare const DropdownMenuSubHeader: import("react").ForwardRefExoticComponent<
|
|
3
|
+
export declare const DropdownMenuSubHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
2
|
import { forwardRef } from 'react';
|
|
4
3
|
import clsx from 'clsx';
|
|
4
|
+
import { Label } from '../../utils/radix-compat/dropdown-menu.js';
|
|
5
5
|
import { Text } from '../../text/text.js';
|
|
6
6
|
import styles from './dropdown-menu.module.js';
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ const DropdownMenuSubHeader = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
className,
|
|
12
12
|
...rest
|
|
13
13
|
} = props;
|
|
14
|
-
return jsx(
|
|
14
|
+
return jsx(Label, {
|
|
15
15
|
...rest,
|
|
16
16
|
ref: forwardedRef,
|
|
17
17
|
children: jsx(Text, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export interface DropdownMenuSubMenuContentProps extends DropdownMenuPrimitive.DropdownMenuSubContentProps {
|
|
3
3
|
/** Specify a container element to portal the content into. */
|
|
4
4
|
/** @default document.body */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Space4, Space3 } from '@box/blueprint-web-assets/tokens/px-tokens';
|
|
3
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
3
|
import clsx from 'clsx';
|
|
5
4
|
import { forwardRef, useCallback } from 'react';
|
|
5
|
+
import { Portal, SubContent } from '../../utils/radix-compat/dropdown-menu.js';
|
|
6
6
|
import '../../blueprint-configuration-context/blueprint-configuration-context.js';
|
|
7
7
|
import '../../blueprint-configuration-context/consts.js';
|
|
8
8
|
import { useBlueprintConfiguration } from '../../blueprint-configuration-context/useBlueprintConfiguration.js';
|
|
@@ -41,9 +41,9 @@ const DropdownMenuSubMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef)
|
|
|
41
41
|
Header,
|
|
42
42
|
OtherChildren
|
|
43
43
|
} = sortMenuChildren(children);
|
|
44
|
-
return jsx(
|
|
44
|
+
return jsx(Portal, {
|
|
45
45
|
container: container,
|
|
46
|
-
children: jsxs(
|
|
46
|
+
children: jsxs(SubContent, {
|
|
47
47
|
...rest,
|
|
48
48
|
ref: ref,
|
|
49
49
|
className: clsx(styles.content, className),
|
|
@@ -60,9 +60,9 @@ const DropdownMenuSubMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef)
|
|
|
60
60
|
}
|
|
61
61
|
return (
|
|
62
62
|
// TODO(DSYS-440): Unify all Portals (Tooltip, Select, DropdownMenu, etc...), Expose a Provider which would tell where to mount (body? other elem?)
|
|
63
|
-
jsx(
|
|
63
|
+
jsx(Portal, {
|
|
64
64
|
container: container,
|
|
65
|
-
children: jsx(
|
|
65
|
+
children: jsx(SubContent, {
|
|
66
66
|
...rest,
|
|
67
67
|
ref: ref,
|
|
68
68
|
className: clsx(styles.content, className),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuSubMenuRootProps = DropdownMenuPrimitive.DropdownMenuSubProps;
|
|
3
3
|
interface ResponsiveSubmenuContextValue {
|
|
4
4
|
open: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
2
|
import { useCallback } from 'react';
|
|
3
|
+
import { Sub } from '../../utils/radix-compat/dropdown-menu.js';
|
|
4
4
|
import { useControllableState } from '../../utils/useControllableState.js';
|
|
5
5
|
import { SubMenuMenuProvider } from '../menu-utils/responsiveness/SubMenuContext.js';
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ const DropdownMenuSubMenuRoot = props => {
|
|
|
27
27
|
return jsx(SubMenuMenuProvider, {
|
|
28
28
|
isSubMenuOpen: isSubMenuOpen,
|
|
29
29
|
setIsSubMenuOpen: setIsSubMenuOpen,
|
|
30
|
-
children: jsx(
|
|
30
|
+
children: jsx(Sub, {
|
|
31
31
|
...rest,
|
|
32
32
|
onOpenChange: handleOpenChange,
|
|
33
33
|
open: isSubMenuOpen,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuSubMenuTriggerProps = DropdownMenuPrimitive.DropdownMenuSubTriggerProps;
|
|
3
3
|
/**
|
|
4
4
|
* Based on Radix-UI Sub Trigger
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#subtrigger
|
|
6
6
|
*/
|
|
7
|
-
export declare const DropdownMenuSubMenuTrigger: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const DropdownMenuSubMenuTrigger: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuItemImplProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
8
8
|
/**
|
|
9
9
|
* Container for side content of sub trigger.
|
|
10
10
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
2
|
import { forwardRef, useCallback } from 'react';
|
|
3
|
+
import { SubTrigger } from '../../utils/radix-compat/dropdown-menu.js';
|
|
4
4
|
import '../../blueprint-configuration-context/blueprint-configuration-context.js';
|
|
5
5
|
import '../../blueprint-configuration-context/consts.js';
|
|
6
6
|
import { useBlueprintConfiguration } from '../../blueprint-configuration-context/useBlueprintConfiguration.js';
|
|
@@ -26,7 +26,7 @@ const DropdownMenuSubMenuTriggerRoot = /*#__PURE__*/forwardRef((props, forwarded
|
|
|
26
26
|
e.preventDefault();
|
|
27
27
|
}
|
|
28
28
|
}, [isMenuFullScreenEnabled]);
|
|
29
|
-
return jsx(
|
|
29
|
+
return jsx(SubTrigger, {
|
|
30
30
|
...rest,
|
|
31
31
|
ref: forwardedRef,
|
|
32
32
|
"data-bp-animated": isAnimationEnabled ? 'true' : 'false',
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuTriggerProps = DropdownMenuPrimitive.DropdownMenuTriggerProps;
|
|
3
3
|
/**
|
|
4
4
|
* DropdownMenuTrigger connects your button to open a modal.
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#trigger
|
|
6
6
|
*/
|
|
7
|
-
export declare const DropdownMenuTrigger: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const DropdownMenuTrigger: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
2
|
import { forwardRef } from 'react';
|
|
3
|
+
import { Trigger } from '../../utils/radix-compat/dropdown-menu.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* DropdownMenuTrigger connects your button to open a modal.
|
|
@@ -11,7 +11,7 @@ const DropdownMenuTrigger = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
children,
|
|
12
12
|
...rest
|
|
13
13
|
} = props;
|
|
14
|
-
return jsx(
|
|
14
|
+
return jsx(Trigger, {
|
|
15
15
|
ref: forwardedRef,
|
|
16
16
|
...rest,
|
|
17
17
|
asChild: true,
|
|
@@ -3,13 +3,17 @@ export declare const DropdownMenu: {
|
|
|
3
3
|
(props: import("./dropdown-menu-root").DropdownMenuRootProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
|
-
Group: import("react").ForwardRefExoticComponent<import("
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Group: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
+
RadioGroup: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuRadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
|
+
Trigger: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
RadioSelectItem: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuRadioItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
CheckboxItem: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuCheckboxItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
15
|
Content: import("react").ForwardRefExoticComponent<import("./dropdown-menu-content").DropdownMenuContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
-
Item: import("react").ForwardRefExoticComponent<import("
|
|
16
|
+
Item: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuItemProps & {
|
|
13
17
|
variant?: import("./dropdown-menu-item").DropdownMenuItemVariant;
|
|
14
18
|
} & import("react").RefAttributes<HTMLDivElement>> & {
|
|
15
19
|
StartElement: import("react").ForwardRefExoticComponent<Omit<import("./dropdown-menu-item").MenuItemStartElementProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -21,7 +25,7 @@ export declare const DropdownMenu: {
|
|
|
21
25
|
(props: import("./dropdown-menu-sub-menu-root").DropdownMenuSubMenuRootProps): import("react/jsx-runtime").JSX.Element;
|
|
22
26
|
displayName: string;
|
|
23
27
|
};
|
|
24
|
-
SubMenuTrigger: import("react").ForwardRefExoticComponent<import("
|
|
28
|
+
SubMenuTrigger: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuItemImplProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
25
29
|
SideContent: ({ children, className, ...rest }: import("../../util-components/menu-item-sections/menu-item-sections").MenuItemSideContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
30
|
MainContent: ({ className, label, description, ...rest }: import("../../util-components/menu-item-sections/menu-item-sections").MenuItemMainContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
31
|
};
|
|
@@ -34,7 +38,9 @@ export declare const DropdownMenu: {
|
|
|
34
38
|
title: string;
|
|
35
39
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
40
|
};
|
|
37
|
-
SubHeader: import("react").ForwardRefExoticComponent<import("
|
|
41
|
+
SubHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
42
|
+
asChild?: boolean;
|
|
43
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
44
|
};
|
|
39
45
|
export { type DropdownMenuContentProps } from './dropdown-menu-content';
|
|
40
46
|
export { type DropdownMenuItemProps, type DropdownMenuItemVariant, type MenuItemEndElementProps, type MenuItemMainContentProps, type MenuItemStartElementProps, } from './dropdown-menu-item';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers an open notification in the Blueprint layer stack, so Escape key presses are arbitrated like when
|
|
3
|
+
* overlays and toasts shared the Radix layer stack: one pressed outside the notifications closes an overlay that
|
|
4
|
+
* opened after this notification, which stays open. Ariakit overlays ignore prevented key presses, so instead of
|
|
5
|
+
* preventing the key press, the close request Radix Toast makes for it is ignored.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useNotificationLayer(open: boolean): {
|
|
8
|
+
leaveEscapeToOverlay: (event: KeyboardEvent) => boolean;
|
|
9
|
+
isCloseLeftToOverlay: () => boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Keeps the notification region, which wraps the viewport and its focus proxies, usable while a modal overlay is
|
|
13
|
+
* open; interactions inside it don't dismiss open overlays either. Returns the ref for the viewport.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useNotificationRegion(): import("react").Dispatch<import("react").SetStateAction<HTMLOListElement | null>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { usePersistentElement, useLayer, isInsidePersistentElement } from '../../../utils/radix-compat/layers.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Registers an open notification in the Blueprint layer stack, so Escape key presses are arbitrated like when
|
|
6
|
+
* overlays and toasts shared the Radix layer stack: one pressed outside the notifications closes an overlay that
|
|
7
|
+
* opened after this notification, which stays open. Ariakit overlays ignore prevented key presses, so instead of
|
|
8
|
+
* preventing the key press, the close request Radix Toast makes for it is ignored.
|
|
9
|
+
*/
|
|
10
|
+
function useNotificationLayer(open) {
|
|
11
|
+
const {
|
|
12
|
+
hasLayerAbove
|
|
13
|
+
} = useLayer('notification', open);
|
|
14
|
+
const overlayEscapeRef = useRef(null);
|
|
15
|
+
/** Returns whether the Escape key press is left to an overlay. */
|
|
16
|
+
const leaveEscapeToOverlay = useCallback(event => {
|
|
17
|
+
if (event.defaultPrevented || isInsidePersistentElement(event.target) || !hasLayerAbove('overlay')) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
overlayEscapeRef.current = event;
|
|
21
|
+
window.setTimeout(() => {
|
|
22
|
+
if (overlayEscapeRef.current === event) {
|
|
23
|
+
overlayEscapeRef.current = null;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return true;
|
|
27
|
+
}, [hasLayerAbove]);
|
|
28
|
+
/** Returns whether a close request comes from an Escape key press left to an overlay, so it must be ignored. */
|
|
29
|
+
const isCloseLeftToOverlay = useCallback(() => {
|
|
30
|
+
const isLeftToOverlay = overlayEscapeRef.current !== null;
|
|
31
|
+
overlayEscapeRef.current = null;
|
|
32
|
+
return isLeftToOverlay;
|
|
33
|
+
}, []);
|
|
34
|
+
return {
|
|
35
|
+
leaveEscapeToOverlay,
|
|
36
|
+
isCloseLeftToOverlay
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Keeps the notification region, which wraps the viewport and its focus proxies, usable while a modal overlay is
|
|
41
|
+
* open; interactions inside it don't dismiss open overlays either. Returns the ref for the viewport.
|
|
42
|
+
*/
|
|
43
|
+
function useNotificationRegion() {
|
|
44
|
+
const [viewport, setViewport] = useState(null);
|
|
45
|
+
usePersistentElement(viewport?.parentElement ?? null);
|
|
46
|
+
return setViewport;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { useNotificationLayer, useNotificationRegion };
|
|
@@ -10,7 +10,7 @@ import { getUniqueId } from '../../utils/useUniqueId.js';
|
|
|
10
10
|
import { truncateNotificationCopy } from './truncate-notification-copy.js';
|
|
11
11
|
|
|
12
12
|
const DEFAULT_NOTIFICATION_DELAY = 5000;
|
|
13
|
-
/** Unreachable swipe distance — Radix
|
|
13
|
+
/** Unreachable swipe distance — Radix Toast has no swipe={false}. */
|
|
14
14
|
const DISABLED_SWIPE_THRESHOLD = Number.POSITIVE_INFINITY;
|
|
15
15
|
/**
|
|
16
16
|
* Stacked motion cannot coexist with Radix swipe. Preserve the caller/Radix
|
|
@@ -121,7 +121,7 @@ const NotificationProvider = props => {
|
|
|
121
121
|
duration: DEFAULT_NOTIFICATION_DELAY,
|
|
122
122
|
// Stacked motion cannot coexist with Radix swipe. Leave the default
|
|
123
123
|
// threshold when Notification animation is off so existing consumers
|
|
124
|
-
// keep swipe-to-dismiss. Radix
|
|
124
|
+
// keep swipe-to-dismiss. Radix Toast has no swipe={false}.
|
|
125
125
|
swipeThreshold: resolveNotificationSwipeThreshold(isAnimationEnabled, swipeThreshold),
|
|
126
126
|
children: jsx(NotificationContext.Provider, {
|
|
127
127
|
value: store,
|
|
@@ -4,6 +4,7 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { forwardRef, useState, useCallback, useEffect } from 'react';
|
|
5
5
|
import { composeEventHandlers } from '../../utils/composeEventHandlers.js';
|
|
6
6
|
import { useHoverFocusExpand } from './hooks/use-hover-focus-expand.js';
|
|
7
|
+
import { useNotificationRegion } from './hooks/use-notification-layer.js';
|
|
7
8
|
import { useStackLayerMetrics } from './hooks/use-stack-layer-metrics.js';
|
|
8
9
|
import { useStaggeredNotificationAdmission } from './hooks/use-staggered-notification-admission.js';
|
|
9
10
|
import { useNotification } from './notification-provider.js';
|
|
@@ -93,6 +94,16 @@ const AnimatedNotificationViewport = /*#__PURE__*/forwardRef((props, forwardedRe
|
|
|
93
94
|
handleFocus,
|
|
94
95
|
handleBlur
|
|
95
96
|
} = useHoverFocusExpand(layoutCount > 1, true);
|
|
97
|
+
const regionRef = useNotificationRegion();
|
|
98
|
+
const viewportRef = useCallback(node => {
|
|
99
|
+
stackRef.current = node;
|
|
100
|
+
regionRef(node);
|
|
101
|
+
if (typeof forwardedRef === 'function') {
|
|
102
|
+
forwardedRef(node);
|
|
103
|
+
} else if (forwardedRef) {
|
|
104
|
+
forwardedRef.current = node;
|
|
105
|
+
}
|
|
106
|
+
}, [forwardedRef, regionRef, stackRef]);
|
|
96
107
|
const stackHeight = isExpanded ? metrics.expandedHeight : metrics.collapsedHeight;
|
|
97
108
|
const stackStyle = {
|
|
98
109
|
...style,
|
|
@@ -103,14 +114,7 @@ const AnimatedNotificationViewport = /*#__PURE__*/forwardRef((props, forwardedRe
|
|
|
103
114
|
// itself is the stack and each toast carries its own layer styles — no wrapper div.
|
|
104
115
|
return jsx(Viewport, {
|
|
105
116
|
...rest,
|
|
106
|
-
ref:
|
|
107
|
-
stackRef.current = node;
|
|
108
|
-
if (typeof forwardedRef === 'function') {
|
|
109
|
-
forwardedRef(node);
|
|
110
|
-
} else if (forwardedRef) {
|
|
111
|
-
forwardedRef.current = node;
|
|
112
|
-
}
|
|
113
|
-
},
|
|
117
|
+
ref: viewportRef,
|
|
114
118
|
className: clsx(styles.viewport, stackStyles.stack, {
|
|
115
119
|
[stackStyles.isExpanded]: isExpanded
|
|
116
120
|
}, className),
|
|
@@ -6,6 +6,8 @@ import '../../blueprint-configuration-context/blueprint-configuration-context.js
|
|
|
6
6
|
import '../../blueprint-configuration-context/consts.js';
|
|
7
7
|
import { useBlueprintConfiguration } from '../../blueprint-configuration-context/useBlueprintConfiguration.js';
|
|
8
8
|
import { isProduction } from '../../utils/isProduction.js';
|
|
9
|
+
import { useForkRef } from '../../utils/useForkRef.js';
|
|
10
|
+
import { useNotificationRegion } from './hooks/use-notification-layer.js';
|
|
9
11
|
import { getLoadedAnimatedNotificationViewport, loadAnimatedNotificationViewport } from './load-animated-notification-viewport.js';
|
|
10
12
|
import { useNotification } from './notification-provider.js';
|
|
11
13
|
import styles from './notification.module.js';
|
|
@@ -37,6 +39,8 @@ const NotificationViewport = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
37
39
|
const isAnimationEnabled = componentsWithAnimationEnabled.includes('Notification');
|
|
38
40
|
const [AnimatedViewport, setAnimatedViewport] = useState(() => isAnimationEnabled ? getLoadedAnimatedNotificationViewport() : null);
|
|
39
41
|
const [hasLoadFailed, setHasLoadFailed] = useState(false);
|
|
42
|
+
const regionRef = useNotificationRegion();
|
|
43
|
+
const viewportRef = useForkRef(forwardedRef, regionRef);
|
|
40
44
|
useEffect(() => {
|
|
41
45
|
const handleKeyDown = event => {
|
|
42
46
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -88,7 +92,7 @@ const NotificationViewport = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
88
92
|
}
|
|
89
93
|
return jsx(Viewport, {
|
|
90
94
|
...rest,
|
|
91
|
-
ref:
|
|
95
|
+
ref: viewportRef,
|
|
92
96
|
className: clsx(styles.viewport, className),
|
|
93
97
|
hotkey: hotkey,
|
|
94
98
|
children: Array.from(notifications.values()).map(({
|
|
@@ -3,16 +3,38 @@ import { XMark } from '@box/blueprint-web-assets/icons/Medium';
|
|
|
3
3
|
import { bpDurationLong } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
4
|
import * as Toast from '@radix-ui/react-toast';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { useMemo, useCallback, useRef, useEffect, useState } from 'react';
|
|
6
|
+
import { useMemo, useCallback, useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
7
7
|
import { composeEventHandlers } from '../../utils/composeEventHandlers.js';
|
|
8
8
|
import { IconButton } from '../icon-button/icon-button.js';
|
|
9
9
|
import { useNotificationExitAnimation, handleNotificationExitTransitionEnd } from './hooks/use-notification-exit-animation.js';
|
|
10
|
+
import { useNotificationLayer } from './hooks/use-notification-layer.js';
|
|
10
11
|
import { isOpenNotification } from './notification-stack-utils.js';
|
|
11
12
|
import stackStyles from './notification-stack.module.js';
|
|
12
13
|
import styles from './notification.module.js';
|
|
13
14
|
import { getIcon } from './private-notification-element.js';
|
|
14
15
|
import { truncateNotificationCopy } from './truncate-notification-copy.js';
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Radix Toast only calls the ref the toast element mounted with, while `layerRef` changes with the depth of the
|
|
19
|
+
* toast. The returned ref passes the element to the current `layerRef`, and moves it over when `layerRef` changes.
|
|
20
|
+
*/
|
|
21
|
+
function useCurrentLayerRef(layerRef) {
|
|
22
|
+
const nodeRef = useRef(null);
|
|
23
|
+
const layerRefRef = useRef(layerRef);
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
const previousLayerRef = layerRefRef.current;
|
|
26
|
+
layerRefRef.current = layerRef;
|
|
27
|
+
if (previousLayerRef === layerRef || !nodeRef.current) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
previousLayerRef?.(null);
|
|
31
|
+
layerRef?.(nodeRef.current);
|
|
32
|
+
}, [layerRef]);
|
|
33
|
+
return useCallback(node => {
|
|
34
|
+
nodeRef.current = node;
|
|
35
|
+
layerRefRef.current?.(node);
|
|
36
|
+
}, []);
|
|
37
|
+
}
|
|
16
38
|
/**
|
|
17
39
|
* Stacked-deck toast. Loaded only from the animated viewport chunk so the flat
|
|
18
40
|
* Notification path stays off the first-paint graph.
|
|
@@ -41,6 +63,7 @@ function AnimatedPrivateNotificationElement(props) {
|
|
|
41
63
|
...rest
|
|
42
64
|
} = props;
|
|
43
65
|
const iconComponent = useMemo(() => getIcon(typeIconAriaLabel, variant), [typeIconAriaLabel, variant]);
|
|
66
|
+
const currentLayerRef = useCurrentLayerRef(layerRef);
|
|
44
67
|
// Radix's own viewport-wide pause-on-hover/focus (`Toast.Provider`'s `toast.viewportPause`/
|
|
45
68
|
// `viewportResume` events) already covers pausing auto-dismiss while the user is interacting
|
|
46
69
|
// with the stack — no bespoke pause context is ported from EndUserApp here.
|
|
@@ -88,12 +111,22 @@ function AnimatedPrivateNotificationElement(props) {
|
|
|
88
111
|
// onEscapeKeyDown (pulled out of `rest` so it isn't clobbered by this one) — it runs
|
|
89
112
|
// first and can call preventDefault() to suppress both Radix's close and this attribution.
|
|
90
113
|
const exitReasonRef = useRef(null);
|
|
114
|
+
const {
|
|
115
|
+
leaveEscapeToOverlay,
|
|
116
|
+
isCloseLeftToOverlay
|
|
117
|
+
} = useNotificationLayer(open !== false);
|
|
91
118
|
const handleEscapeKeyDown = useCallback(event => {
|
|
92
119
|
onEscapeKeyDown?.(event);
|
|
93
|
-
if (!event.defaultPrevented) {
|
|
120
|
+
if (!event.defaultPrevented && !leaveEscapeToOverlay(event)) {
|
|
94
121
|
exitReasonRef.current = 'escape';
|
|
95
122
|
}
|
|
96
|
-
}, [onEscapeKeyDown]);
|
|
123
|
+
}, [leaveEscapeToOverlay, onEscapeKeyDown]);
|
|
124
|
+
const handleToastOpenChange = useCallback(nextOpen => {
|
|
125
|
+
if (!nextOpen && isCloseLeftToOverlay()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
handleOpenChange(nextOpen);
|
|
129
|
+
}, [handleOpenChange, isCloseLeftToOverlay]);
|
|
97
130
|
useEffect(() => {
|
|
98
131
|
if (!hasExitStyles) {
|
|
99
132
|
exitReasonRef.current = null;
|
|
@@ -130,9 +163,14 @@ function AnimatedPrivateNotificationElement(props) {
|
|
|
130
163
|
'--notification-stack-depth': layoutDepth,
|
|
131
164
|
'--notification-stack-expand-offset': `${layoutExpandOffset}px`
|
|
132
165
|
} : undefined;
|
|
133
|
-
return jsx(Toast.Root
|
|
166
|
+
return jsx(Toast.Root
|
|
167
|
+
// A focused toast is read as a status without being announced again.
|
|
168
|
+
, {
|
|
169
|
+
"aria-atomic": true,
|
|
170
|
+
"aria-live": "off",
|
|
171
|
+
role: "status",
|
|
134
172
|
...rest,
|
|
135
|
-
ref:
|
|
173
|
+
ref: currentLayerRef,
|
|
136
174
|
className: clsx(styles.root, styles[variant], {
|
|
137
175
|
[stackStyles.stackLayer]: isAnimationEnabled
|
|
138
176
|
}),
|
|
@@ -149,7 +187,7 @@ function AnimatedPrivateNotificationElement(props) {
|
|
|
149
187
|
"data-entering": isAnimationEnabled && !hasEntered ? 'true' : undefined,
|
|
150
188
|
onEscapeKeyDown: handleEscapeKeyDown,
|
|
151
189
|
onTransitionEnd: handleTransitionEnd,
|
|
152
|
-
onOpenChange:
|
|
190
|
+
onOpenChange: handleToastOpenChange,
|
|
153
191
|
open: radixOpen,
|
|
154
192
|
style: {
|
|
155
193
|
...style,
|
|
@@ -3,8 +3,10 @@ import { XMark, AlertTriangle, InformationCircle, CheckmarkCircle, AlertCircle }
|
|
|
3
3
|
import { bpIconIconOnLight, bpSize050 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
4
|
import * as Toast from '@radix-ui/react-toast';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { useMemo, useCallback } from 'react';
|
|
7
|
+
import { useControllableState } from '../../utils/useControllableState.js';
|
|
7
8
|
import { IconButton } from '../icon-button/icon-button.js';
|
|
9
|
+
import { useNotificationLayer } from './hooks/use-notification-layer.js';
|
|
8
10
|
import styles from './notification.module.js';
|
|
9
11
|
import { truncateNotificationCopy } from './truncate-notification-copy.js';
|
|
10
12
|
|
|
@@ -58,14 +60,42 @@ function PrivateNotificationElement(props) {
|
|
|
58
60
|
closeButtonAriaLabel,
|
|
59
61
|
typeIconAriaLabel,
|
|
60
62
|
children,
|
|
63
|
+
defaultOpen = true,
|
|
64
|
+
onEscapeKeyDown,
|
|
61
65
|
...rest
|
|
62
66
|
} = props;
|
|
63
67
|
const iconComponent = useMemo(() => getIcon(typeIconAriaLabel, variant), [typeIconAriaLabel, variant]);
|
|
64
|
-
|
|
68
|
+
// The toast is controlled, so a close request can be ignored.
|
|
69
|
+
const [isOpen = defaultOpen, setIsOpen] = useControllableState({
|
|
70
|
+
prop: open,
|
|
71
|
+
defaultProp: defaultOpen,
|
|
72
|
+
onChange: onClose
|
|
73
|
+
});
|
|
74
|
+
const {
|
|
75
|
+
leaveEscapeToOverlay,
|
|
76
|
+
isCloseLeftToOverlay
|
|
77
|
+
} = useNotificationLayer(isOpen);
|
|
78
|
+
const handleEscapeKeyDown = useCallback(event => {
|
|
79
|
+
onEscapeKeyDown?.(event);
|
|
80
|
+
leaveEscapeToOverlay(event);
|
|
81
|
+
}, [leaveEscapeToOverlay, onEscapeKeyDown]);
|
|
82
|
+
const handleOpenChange = useCallback(nextOpen => {
|
|
83
|
+
if (!nextOpen && isCloseLeftToOverlay()) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setIsOpen(nextOpen);
|
|
87
|
+
}, [isCloseLeftToOverlay, setIsOpen]);
|
|
88
|
+
return jsx(Toast.Root
|
|
89
|
+
// A focused toast is read as a status without being announced again.
|
|
90
|
+
, {
|
|
91
|
+
"aria-atomic": true,
|
|
92
|
+
"aria-live": "off",
|
|
93
|
+
role: "status",
|
|
65
94
|
...rest,
|
|
66
95
|
className: clsx(styles.root, styles[variant]),
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
|
97
|
+
onOpenChange: handleOpenChange,
|
|
98
|
+
open: isOpen,
|
|
69
99
|
type: sensitivity,
|
|
70
100
|
children: jsxs("div", {
|
|
71
101
|
className: styles.container,
|
|
@@ -3,12 +3,18 @@ export declare const Popover: {
|
|
|
3
3
|
(props: import("./popover-root").PopoverRootProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
|
-
Trigger: import("react").ForwardRefExoticComponent<import("
|
|
7
|
-
|
|
6
|
+
Trigger: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
Anchor: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
12
|
ContentContainer: import("react").ForwardRefExoticComponent<import("./popover-content-container").PopoverContentContainerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
-
MainContent: import("react").ForwardRefExoticComponent<import("
|
|
10
|
-
Footer: import("react").ForwardRefExoticComponent<import("
|
|
11
|
-
Close: import("react").ForwardRefExoticComponent<import("
|
|
13
|
+
MainContent: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/popover").PopoverContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
Footer: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/popover").PopoverContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
Close: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
18
|
};
|
|
13
19
|
export { type PopoverCloseProps } from './popover-close';
|
|
14
20
|
export { type PopoverContentContainerProps } from './popover-content-container';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as PopoverPrimitive from '
|
|
1
|
+
import * as PopoverPrimitive from '../../utils/radix-compat/popover';
|
|
2
2
|
export type PopoverAnchorProps = PopoverPrimitive.PopoverAnchorProps;
|
|
3
3
|
/**
|
|
4
4
|
* An optional element to position the `Popover.Content` against.
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/popover#anchor
|
|
6
6
|
*/
|
|
7
|
-
export declare const PopoverAnchor: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const PopoverAnchor: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as RadixPopover from '@radix-ui/react-popover';
|
|
3
2
|
import { forwardRef } from 'react';
|
|
3
|
+
import { Anchor } from '../../utils/radix-compat/popover.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* An optional element to position the `Popover.Content` against.
|
|
@@ -11,7 +11,7 @@ const PopoverAnchor = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
children,
|
|
12
12
|
...rest
|
|
13
13
|
} = props;
|
|
14
|
-
return jsx(
|
|
14
|
+
return jsx(Anchor, {
|
|
15
15
|
...rest,
|
|
16
16
|
ref: forwardedRef,
|
|
17
17
|
asChild: true,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as PopoverPrimitive from '
|
|
1
|
+
import * as PopoverPrimitive from '../../utils/radix-compat/popover';
|
|
2
2
|
export type PopoverCloseProps = PopoverPrimitive.PopoverCloseProps;
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper for buttons that should close the popover on click
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/popover#close
|
|
6
6
|
*/
|
|
7
|
-
export declare const PopoverClose: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const PopoverClose: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import * as RadixPopover from '@radix-ui/react-popover';
|
|
3
2
|
import { forwardRef } from 'react';
|
|
3
|
+
import { Close } from '../../utils/radix-compat/popover.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Wrapper for buttons that should close the popover on click
|
|
@@ -11,7 +11,7 @@ const PopoverClose = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
children,
|
|
12
12
|
...rest
|
|
13
13
|
} = props;
|
|
14
|
-
return jsx(
|
|
14
|
+
return jsx(Close, {
|
|
15
15
|
...rest,
|
|
16
16
|
ref: forwardedRef,
|
|
17
17
|
asChild: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as PopoverPrimitive from '
|
|
1
|
+
import * as PopoverPrimitive from '../../utils/radix-compat/popover';
|
|
2
2
|
export interface PopoverContentContainerProps extends PopoverPrimitive.PopoverContentProps {
|
|
3
3
|
/** Specify a container element to portal the content into. */
|
|
4
4
|
/** @default document.body */
|