@box/blueprint-web 19.5.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 +14 -6
- package/dist/lib-esm/accordion/accordion.module.js +1 -1
- package/dist/lib-esm/accordion/types.d.ts +1 -1
- package/dist/lib-esm/blueprint-configuration-context/consts.d.ts +1 -1
- package/dist/lib-esm/blueprint-configuration-context/consts.js +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/components.css +400 -280
- 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/index.css +400 -280
- 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/small-list-item/small-list.js +8 -0
- 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/util-components/base-grid-list-item/base-grid-list-item.module.js +1 -1
- package/dist/lib-esm/utils/TooltipWrapper.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,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Space4, Space2 } 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, Children, isValidElement } from 'react';
|
|
5
|
+
import { Portal, Content } 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';
|
|
@@ -58,9 +58,9 @@ const DropdownMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
58
58
|
Header,
|
|
59
59
|
OtherChildren
|
|
60
60
|
} = sortMenuChildren(children);
|
|
61
|
-
return jsx(
|
|
61
|
+
return jsx(Portal, {
|
|
62
62
|
container: container,
|
|
63
|
-
children: jsxs(
|
|
63
|
+
children: jsxs(Content, {
|
|
64
64
|
...rest,
|
|
65
65
|
ref: ref,
|
|
66
66
|
className: clsx(styles.content, className),
|
|
@@ -74,9 +74,9 @@ const DropdownMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
74
74
|
}
|
|
75
75
|
return (
|
|
76
76
|
// TODO(DSYS-440): Unify all Portals (Tooltip, Select, DropdownMenu, etc...), Expose a Provider which would tell where to mount (body? other elem?)
|
|
77
|
-
jsx(
|
|
77
|
+
jsx(Portal, {
|
|
78
78
|
container: container,
|
|
79
|
-
children: jsx(
|
|
79
|
+
children: jsx(Content, {
|
|
80
80
|
...rest,
|
|
81
81
|
ref: ref,
|
|
82
82
|
className: clsx(styles.content, className),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuGroupProps = DropdownMenuPrimitive.DropdownMenuGroupProps;
|
|
3
3
|
/**
|
|
4
4
|
* Based on Radix-UI Group
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#group
|
|
6
6
|
*/
|
|
7
|
-
export declare const DropdownMenuGroup: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const DropdownMenuGroup: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { Group } from '../../utils/radix-compat/dropdown-menu.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Based on Radix-UI Group
|
|
7
7
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#group
|
|
8
8
|
*/
|
|
9
9
|
const DropdownMenuGroup = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
10
|
-
return jsx(
|
|
10
|
+
return jsx(Group, {
|
|
11
11
|
...props,
|
|
12
12
|
ref: forwardedRef
|
|
13
13
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
2
1
|
import { type ForwardRefExoticComponent, type RefAttributes, type SVGProps } from 'react';
|
|
3
2
|
import { type RequireExactlyOne } from 'type-fest';
|
|
3
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
4
4
|
export type DropdownMenuItemVariant = 'destructive';
|
|
5
5
|
export type DropdownMenuItemProps = DropdownMenuPrimitive.DropdownMenuItemProps & {
|
|
6
6
|
/** The visual style of the menu item. */
|
|
@@ -34,7 +34,7 @@ export type MenuItemEndElementProps = React.ComponentProps<'div'>;
|
|
|
34
34
|
* End element of an Item, dedicated for additional text and icons.
|
|
35
35
|
*/
|
|
36
36
|
export declare const MenuItemEndElement: ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
37
|
-
export declare const DropdownMenuItem: ForwardRefExoticComponent<
|
|
37
|
+
export declare const DropdownMenuItem: ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuItemProps & {
|
|
38
38
|
/** The visual style of the menu item. */
|
|
39
39
|
variant?: DropdownMenuItemVariant;
|
|
40
40
|
} & RefAttributes<HTMLDivElement>> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Size8, Size4, bpTextTextDestructiveOnLight, bpIconIconOnLightSecondary } from '@box/blueprint-web-assets/tokens/tokens';
|
|
3
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
3
|
import clsx from 'clsx';
|
|
5
4
|
import { forwardRef, useCallback, useContext, createElement, createContext } from 'react';
|
|
5
|
+
import { Item } 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';
|
|
@@ -35,7 +35,7 @@ const DropdownMenuItemBase = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
35
35
|
const preventDefault = useCallback(event => event.preventDefault(), []);
|
|
36
36
|
return jsx(ItemVariantContext.Provider, {
|
|
37
37
|
value: variant,
|
|
38
|
-
children: jsx(
|
|
38
|
+
children: jsx(Item, {
|
|
39
39
|
...rest,
|
|
40
40
|
ref: forwardedRef,
|
|
41
41
|
"data-bp-animated": animatedDataAttribute ?? (isAnimationEnabled ? 'true' : 'false'),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuRadioGroupProps = DropdownMenuPrimitive.DropdownMenuRadioGroupProps;
|
|
3
3
|
/**
|
|
4
4
|
* Based on Radix-UI RadioGroup
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#radiogroup
|
|
6
6
|
*/
|
|
7
|
-
export declare const DropdownMenuRadioGroup: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const DropdownMenuRadioGroup: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuRadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { RadioGroup } from '../../utils/radix-compat/dropdown-menu.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Based on Radix-UI RadioGroup
|
|
7
7
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#radiogroup
|
|
8
8
|
*/
|
|
9
9
|
const DropdownMenuRadioGroup = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
10
|
-
return jsx(
|
|
10
|
+
return jsx(RadioGroup, {
|
|
11
11
|
...props,
|
|
12
12
|
ref: forwardedRef
|
|
13
13
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
export type DropdownMenuRadioSelectItemProps = DropdownMenuPrimitive.DropdownMenuRadioItemProps;
|
|
3
3
|
/**
|
|
4
4
|
* Based on Radix-UI RadioItem
|
|
5
5
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#radioitem
|
|
6
6
|
*/
|
|
7
|
-
export declare const DropdownMenuRadioSelectItem: import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const DropdownMenuRadioSelectItem: import("react").ForwardRefExoticComponent<import("../../utils/radix-compat/menu").MenuRadioItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Checkmark } from '@box/blueprint-web-assets/icons/Medium';
|
|
3
3
|
import { bpSize050, bpIconIconOnLight } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
4
|
import clsx from 'clsx';
|
|
6
5
|
import { forwardRef, useCallback } from 'react';
|
|
6
|
+
import { RadioItem, ItemIndicator } from '../../utils/radix-compat/dropdown-menu.js';
|
|
7
7
|
import '../../blueprint-configuration-context/blueprint-configuration-context.js';
|
|
8
8
|
import '../../blueprint-configuration-context/consts.js';
|
|
9
9
|
import { useBlueprintConfiguration } from '../../blueprint-configuration-context/useBlueprintConfiguration.js';
|
|
@@ -30,7 +30,7 @@ const DropdownMenuRadioSelectItem = /*#__PURE__*/forwardRef((props, forwardedRef
|
|
|
30
30
|
} = useBlueprintConfiguration();
|
|
31
31
|
const isAnimationEnabled = componentsWithAnimationEnabled.includes('DropdownMenuItem');
|
|
32
32
|
const isSizeSmall = internalSize === 'small';
|
|
33
|
-
return jsxs(
|
|
33
|
+
return jsxs(RadioItem, {
|
|
34
34
|
...rest,
|
|
35
35
|
ref: forwardedRef,
|
|
36
36
|
"data-bp-animated": isAnimationEnabled ? 'true' : 'false',
|
|
@@ -44,7 +44,7 @@ const DropdownMenuRadioSelectItem = /*#__PURE__*/forwardRef((props, forwardedRef
|
|
|
44
44
|
[styles.radioItemMediumSpacing]: !isSizeSmall
|
|
45
45
|
}),
|
|
46
46
|
children: children ?? value
|
|
47
|
-
}), jsx(
|
|
47
|
+
}), jsx(ItemIndicator, {
|
|
48
48
|
className: clsx(styles.checkmark, {
|
|
49
49
|
[styles.mediumSpacing]: !isSizeSmall
|
|
50
50
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '
|
|
1
|
+
import * as DropdownMenuPrimitive from '../../utils/radix-compat/dropdown-menu';
|
|
2
2
|
import { type Size } from './menu-item-variant-context';
|
|
3
3
|
export type DropdownMenuRootProps = DropdownMenuPrimitive.DropdownMenuProps & {
|
|
4
4
|
isFullScreenEnabled?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import { Root } from '../../utils/radix-compat/dropdown-menu.js';
|
|
3
3
|
import { useControllableState } from '../../utils/useControllableState.js';
|
|
4
4
|
import { FullScreenMenuProvider } from '../menu-utils/responsiveness/FullScreenDropdownMenuContext.js';
|
|
5
5
|
import { MenuItemVariantProvider } from './menu-item-variant-context.js';
|
|
@@ -28,7 +28,7 @@ const DropdownMenuRoot = props => {
|
|
|
28
28
|
isFullScreenEnabled: isFullScreenEnabled,
|
|
29
29
|
isMenuOpen: isMenuOpen,
|
|
30
30
|
setIsMenuOpen: setIsMenuOpen,
|
|
31
|
-
children: jsx(
|
|
31
|
+
children: jsx(Root, {
|
|
32
32
|
...rest,
|
|
33
33
|
onOpenChange: setIsMenuOpen,
|
|
34
34
|
open: isMenuOpen,
|
|
@@ -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(({
|