@box/blueprint-web 9.4.0 → 9.5.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/lib-esm/accordion/accordion.module.js +1 -1
- package/lib-esm/avatar/avatar.module.js +1 -1
- package/lib-esm/badge/base-badge.module.js +1 -1
- package/lib-esm/card/card.module.js +1 -1
- package/lib-esm/card-tooltip/card-tooltip.module.js +1 -1
- package/lib-esm/checkbox/checkbox.module.js +1 -1
- package/lib-esm/collapsible/collapsible-section.module.js +1 -1
- package/lib-esm/combobox/combobox.module.js +1 -1
- package/lib-esm/combobox-group/combobox-group.module.js +1 -1
- package/lib-esm/content-card/content-card.module.js +1 -1
- package/lib-esm/data-table/cell/sticky-cell.module.js +1 -1
- package/lib-esm/data-table/data-table.module.js +1 -1
- package/lib-esm/date-picker/date-picker.module.js +1 -1
- package/lib-esm/divider/divider.module.js +1 -1
- package/lib-esm/empty-state/empty-state.module.js +1 -1
- package/lib-esm/ghost/ghost.module.js +1 -1
- package/lib-esm/guided-tooltip/guided-tooltip.module.js +1 -1
- package/lib-esm/icon-dual-state-button/icon-dual-state-button.module.js +1 -1
- package/lib-esm/icon-toggle-button/icon-toggle-button.module.js +1 -1
- package/lib-esm/index.css +1044 -1000
- package/lib-esm/loading-indicator/loading-indicator.module.js +1 -1
- package/lib-esm/modal/modal.module.js +1 -1
- package/lib-esm/navigation-menu/navigation-menu.module.js +1 -1
- package/lib-esm/page/page.module.js +1 -1
- package/lib-esm/page-section/page-section.module.js +1 -1
- package/lib-esm/password-input/password-input.module.js +1 -1
- package/lib-esm/primitives/base-button/base-button.module.js +1 -1
- package/lib-esm/primitives/base-inline-notice/base-inline-notice.module.js +1 -1
- package/lib-esm/primitives/base-text-input/base-text-input.module.js +1 -1
- package/lib-esm/primitives/calendar/calendar.module.js +1 -1
- package/lib-esm/primitives/chips/chip.module.js +1 -1
- package/lib-esm/primitives/chips/filter-chip/filter-combo-chip.d.ts +2 -0
- package/lib-esm/primitives/chips/filter-chip/index.d.ts +2 -0
- package/lib-esm/primitives/context-menu/context-menu.module.js +1 -1
- package/lib-esm/primitives/dropdown-menu/FullScreenMenuContext.d.ts +16 -0
- package/lib-esm/primitives/dropdown-menu/FullScreenMenuContext.js +36 -0
- package/lib-esm/primitives/dropdown-menu/SubMenuContext.d.ts +13 -0
- package/lib-esm/primitives/dropdown-menu/SubMenuContext.js +27 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-content.d.ts +5 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-content.js +43 -3
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-header.d.ts +15 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-header.js +93 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-item.js +4 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-root.d.ts +3 -1
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-root.js +21 -3
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-content.js +30 -2
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.d.ts +6 -0
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.js +32 -4
- package/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-trigger.js +22 -2
- package/lib-esm/primitives/dropdown-menu/dropdown-menu.module.js +1 -1
- package/lib-esm/primitives/dropdown-menu/index.d.ts +8 -0
- package/lib-esm/primitives/dropdown-menu/index.js +3 -1
- package/lib-esm/primitives/icon-button/icon-button.module.js +1 -1
- package/lib-esm/primitives/inline-error/inline-error.module.js +1 -1
- package/lib-esm/primitives/link/link.module.js +1 -1
- package/lib-esm/primitives/notification/notification.module.js +1 -1
- package/lib-esm/primitives/page-header/page-header.module.js +1 -1
- package/lib-esm/primitives/popover/popover.module.js +1 -1
- package/lib-esm/primitives/select-menu-grid/select-menu-grid-option.module.js +1 -1
- package/lib-esm/primitives/tabs/tabs.module.js +1 -1
- package/lib-esm/radio-group/radio-group.module.js +1 -1
- package/lib-esm/radio-tiles/radio-tiles-option.module.js +1 -1
- package/lib-esm/radio-tiles/radio-tiles.module.js +1 -1
- package/lib-esm/search-input/search.module.js +1 -1
- package/lib-esm/select/select.module.js +1 -1
- package/lib-esm/side-panel/side-panel.module.js +1 -1
- package/lib-esm/slider/slider-incrementer.module.js +1 -1
- package/lib-esm/slider/slider-range.module.js +1 -1
- package/lib-esm/slider/slider.module.js +1 -1
- package/lib-esm/status/status.module.js +1 -1
- package/lib-esm/switch/switch.module.js +1 -1
- package/lib-esm/text/text.module.js +1 -1
- package/lib-esm/text-area/text-area-autosize/text-area-autosize.module.js +1 -1
- package/lib-esm/text-area/text-area.module.js +1 -1
- package/lib-esm/text-button/text-button.module.js +1 -1
- package/lib-esm/text-input/text-input.module.js +1 -1
- package/lib-esm/text-toggle-button/text-toggle-button.module.js +1 -1
- package/lib-esm/toolbar/toolbar.module.js +1 -1
- package/lib-esm/tooltip/tooltip.module.js +1 -1
- package/lib-esm/util-components/base-grid-list-item/base-grid-list-item.module.js +1 -1
- package/lib-esm/util-components/interactive-icon/interactive-icon.module.js +1 -1
- package/lib-esm/util-components/legend/legend.module.js +1 -1
- package/lib-esm/util-components/menu-item-sections/menu-item-sections.module.js +1 -1
- package/lib-esm/util-components/search-term-string/search-term-string.module.js +1 -1
- package/lib-esm/util-components/text-with-info-badge/text-with-info-badge.module.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"crawler":"bp_loading_indicator_module_crawler--
|
|
2
|
+
var styles = {"crawler":"bp_loading_indicator_module_crawler--075b2","segment":"bp_loading_indicator_module_segment--075b2","small":"bp_loading_indicator_module_small--075b2","large":"bp_loading_indicator_module_large--075b2","x-large":"bp_loading_indicator_module_x-large--075b2","default":"bp_loading_indicator_module_default--075b2","segment-transform":"bp_loading_indicator_module_segment-transform--075b2","segment-default":"bp_loading_indicator_module_segment-default--075b2","dark":"bp_loading_indicator_module_dark--075b2","segment-dark":"bp_loading_indicator_module_segment-dark--075b2","light":"bp_loading_indicator_module_light--075b2","segment-light":"bp_loading_indicator_module_segment-light--075b2"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"overlay":"bp_modal_module_overlay--
|
|
2
|
+
var styles = {"overlay":"bp_modal_module_overlay--9727e","content":"bp_modal_module_content--9727e","popup_bounce_in":"bp_modal_module_popup_bounce_in--9727e","smallSizeModal":"bp_modal_module_smallSizeModal--9727e","mediumSizeModal":"bp_modal_module_mediumSizeModal--9727e","largeSizeModal":"bp_modal_module_largeSizeModal--9727e","xlargeSizeModal":"bp_modal_module_xlargeSizeModal--9727e","close":"bp_modal_module_close--9727e","onColor":"bp_modal_module_onColor--9727e","backButton":"bp_modal_module_backButton--9727e","modalHeader":"bp_modal_module_modalHeader--9727e","modalTitle":"bp_modal_module_modalTitle--9727e","body":"bp_modal_module_body--9727e","scrollableContainer":"bp_modal_module_scrollableContainer--9727e","headerDividerLine":"bp_modal_module_headerDividerLine--9727e","footerDividerLine":"bp_modal_module_footerDividerLine--9727e","footer":"bp_modal_module_footer--9727e","footerButton":"bp_modal_module_footerButton--9727e"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"link":"bp_navigation_menu_module_link--
|
|
2
|
+
var styles = {"link":"bp_navigation_menu_module_link--d3a3d","ellipsis":"bp_navigation_menu_module_ellipsis--d3a3d","navigationMenuSeparator":"bp_navigation_menu_module_navigationMenuSeparator--d3a3d"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"page":"bp_page_module_page--
|
|
2
|
+
var styles = {"page":"bp_page_module_page--6eccb","globalHeader":"bp_page_module_globalHeader--6eccb","sideContentContainer":"bp_page_module_sideContentContainer--6eccb","searchContainer":"bp_page_module_searchContainer--6eccb","pageMain":"bp_page_module_pageMain--6eccb","topSection":"bp_page_module_topSection--6eccb","mainSection":"bp_page_module_mainSection--6eccb","content":"bp_page_module_content--6eccb","sidebar":"bp_page_module_sidebar--6eccb","navigationPortal":"bp_page_module_navigationPortal--6eccb","navigationContent":"bp_page_module_navigationContent--6eccb","navigationPortalLargeCollapsed":"bp_page_module_navigationPortalLargeCollapsed--6eccb","navigationPortalLargeExpanded":"bp_page_module_navigationPortalLargeExpanded--6eccb","hide":"bp_page_module_hide--6eccb","pageMediumOrLessViewport":"bp_page_module_pageMediumOrLessViewport--6eccb","search":"bp_page_module_search--6eccb","navigationPortalOverlayCollapsed":"bp_page_module_navigationPortalOverlayCollapsed--6eccb","navigationPortalOverlayExpanded":"bp_page_module_navigationPortalOverlayExpanded--6eccb","pageNavigationXXLargeCollapsed":"bp_page_module_pageNavigationXXLargeCollapsed--6eccb","pageNavigationXXLargeExpanded":"bp_page_module_pageNavigationXXLargeExpanded--6eccb","portalEntry":"bp_page_module_portalEntry--6eccb"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"pageSectionContainer":"bp_page_section_module_pageSectionContainer--
|
|
2
|
+
var styles = {"pageSectionContainer":"bp_page_section_module_pageSectionContainer--1bd1e","pageSection":"bp_page_section_module_pageSection--1bd1e","pageSectionHeader":"bp_page_section_module_pageSectionHeader--1bd1e","pageSectionContent":"bp_page_section_module_pageSectionContent--1bd1e","pageSectionDivider":"bp_page_section_module_pageSectionDivider--1bd1e"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"passwordInput":"bp_password_input_module_passwordInput--
|
|
2
|
+
var styles = {"passwordInput":"bp_password_input_module_passwordInput--d517b","iconButton":"bp_password_input_module_iconButton--d517b"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"button":"bp_base_button_module_button--
|
|
2
|
+
var styles = {"button":"bp_base_button_module_button--78e93","icon":"bp_base_button_module_icon--78e93","primary":"bp_base_button_module_primary--78e93","secondary":"bp_base_button_module_secondary--78e93","tertiary":"bp_base_button_module_tertiary--78e93","outline":"bp_base_button_module_outline--78e93","small":"bp_base_button_module_small--78e93","isIconButton":"bp_base_button_module_isIconButton--78e93","large":"bp_base_button_module_large--78e93","hide":"bp_base_button_module_hide--78e93"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"noticeWrapper":"bp_base_inline_notice_module_noticeWrapper--
|
|
2
|
+
var styles = {"noticeWrapper":"bp_base_inline_notice_module_noticeWrapper--dd55c","actions":"bp_base_inline_notice_module_actions--dd55c","backgroundYellow":"bp_base_inline_notice_module_backgroundYellow--dd55c","backgroundBlue":"bp_base_inline_notice_module_backgroundBlue--dd55c","backgroundRed":"bp_base_inline_notice_module_backgroundRed--dd55c","backgroundGreen":"bp_base_inline_notice_module_backgroundGreen--dd55c","backgroundPurple":"bp_base_inline_notice_module_backgroundPurple--dd55c","actionButtonTertiary":"bp_base_inline_notice_module_actionButtonTertiary--dd55c","actionButtonPrimary":"bp_base_inline_notice_module_actionButtonPrimary--dd55c","contentContainer":"bp_base_inline_notice_module_contentContainer--dd55c","content":"bp_base_inline_notice_module_content--dd55c","title":"bp_base_inline_notice_module_title--dd55c"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"textInputContainer":"bp_base_text_input_module_textInputContainer--
|
|
2
|
+
var styles = {"textInputContainer":"bp_base_text_input_module_textInputContainer--1717c","label":"bp_base_text_input_module_label--1717c","hidden":"bp_base_text_input_module_hidden--1717c","textInput":"bp_base_text_input_module_textInput--1717c","error":"bp_base_text_input_module_error--1717c","iconShared":"bp_base_text_input_module_iconShared--1717c","disabled":"bp_base_text_input_module_disabled--1717c","inlineError":"bp_base_text_input_module_inlineError--1717c"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"calendar":"bp_calendar_module_calendar--
|
|
2
|
+
var styles = {"calendar":"bp_calendar_module_calendar--38bc5","calendarGrid":"bp_calendar_module_calendarGrid--38bc5","calendarHeaderCell":"bp_calendar_module_calendarHeaderCell--38bc5","calendarHeader":"bp_calendar_module_calendarHeader--38bc5","calendarHeaderHeading":"bp_calendar_module_calendarHeaderHeading--38bc5","calendarHeaderButton":"bp_calendar_module_calendarHeaderButton--38bc5","calendarCell":"bp_calendar_module_calendarCell--38bc5","today":"bp_calendar_module_today--38bc5"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"chip":"bp_chip_module_chip--
|
|
2
|
+
var styles = {"chip":"bp_chip_module_chip--22398","labelText":"bp_chip_module_labelText--22398","chipStatus":"bp_chip_module_chipStatus--22398","chipButton":"bp_chip_module_chipButton--22398","singleSelectChip":"bp_chip_module_singleSelectChip--22398","multiSelectChip":"bp_chip_module_multiSelectChip--22398","chipsGroup":"bp_chip_module_chipsGroup--22398"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -20,6 +20,8 @@ export type FilterComboChipProps = DropdownMenuRootProps & {
|
|
|
20
20
|
children: React.ReactNode;
|
|
21
21
|
};
|
|
22
22
|
export declare const FilterComboChip: React.ForwardRefExoticComponent<import("@radix-ui/react-dropdown-menu").DropdownMenuProps & {
|
|
23
|
+
isFullScreenEnabled?: boolean;
|
|
24
|
+
} & {
|
|
23
25
|
/** FilterChip.Chip component used as Dropdown menu trigger. Trigger chip value is ignored from selection */
|
|
24
26
|
chip: React.ReactElement;
|
|
25
27
|
/** List of FilterChip.ComboOption elements displayed in the dropdown menu */
|
|
@@ -7,6 +7,8 @@ export declare const FilterChip: {
|
|
|
7
7
|
Status: import("react").ForwardRefExoticComponent<Omit<import("../types").ChipStatusProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
8
|
DropdownIndicator: import("react").ForwardRefExoticComponent<import("react").RefAttributes<SVGSVGElement>>;
|
|
9
9
|
ComboChip: import("react").ForwardRefExoticComponent<import("@radix-ui/react-dropdown-menu").DropdownMenuProps & {
|
|
10
|
+
isFullScreenEnabled?: boolean;
|
|
11
|
+
} & {
|
|
10
12
|
chip: React.ReactElement;
|
|
11
13
|
children: React.ReactNode;
|
|
12
14
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"menuBlock":"bp_context_menu_module_menuBlock--
|
|
2
|
+
var styles = {"menuBlock":"bp_context_menu_module_menuBlock--b67f6","menuItemsSeparator":"bp_context_menu_module_menuItemsSeparator--b67f6","menuItem":"bp_context_menu_module_menuItem--b67f6"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
interface FullScreenMenuContextProps {
|
|
3
|
+
isMenuFullScreenEnabled: boolean;
|
|
4
|
+
setIsMenuFullScreenEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
5
|
+
isMenuOpen: boolean;
|
|
6
|
+
setIsMenuOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
7
|
+
}
|
|
8
|
+
interface FullScreenProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
isFullScreenEnabled?: boolean;
|
|
11
|
+
isMenuOpen: boolean;
|
|
12
|
+
setIsMenuOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
13
|
+
}
|
|
14
|
+
export declare const FullScreenMenuProvider: ({ children, isFullScreenEnabled, isMenuOpen, setIsMenuOpen, }: FullScreenProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const useFullScreenMenu: () => FullScreenMenuContextProps;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, createContext, useState, useEffect, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const FullScreenMenuContext = /*#__PURE__*/createContext(null);
|
|
5
|
+
const FullScreenMenuProvider = ({
|
|
6
|
+
children,
|
|
7
|
+
isFullScreenEnabled,
|
|
8
|
+
isMenuOpen,
|
|
9
|
+
setIsMenuOpen
|
|
10
|
+
}) => {
|
|
11
|
+
const [isMenuFullScreenEnabled, setIsMenuFullScreenEnabled] = useState(isFullScreenEnabled || false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (isFullScreenEnabled !== undefined) {
|
|
14
|
+
setIsMenuFullScreenEnabled(isFullScreenEnabled);
|
|
15
|
+
}
|
|
16
|
+
}, [isFullScreenEnabled]);
|
|
17
|
+
const value = useMemo(() => ({
|
|
18
|
+
isMenuFullScreenEnabled,
|
|
19
|
+
setIsMenuFullScreenEnabled,
|
|
20
|
+
isMenuOpen,
|
|
21
|
+
setIsMenuOpen
|
|
22
|
+
}), [isMenuFullScreenEnabled, setIsMenuFullScreenEnabled, isMenuOpen, setIsMenuOpen]);
|
|
23
|
+
return jsx(FullScreenMenuContext.Provider, {
|
|
24
|
+
value: value,
|
|
25
|
+
children: children
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const useFullScreenMenu = () => {
|
|
29
|
+
const context = useContext(FullScreenMenuContext);
|
|
30
|
+
if (context === null) {
|
|
31
|
+
throw new Error('useFullScreenMenu must be used within a DropdownMenu.Root');
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { FullScreenMenuProvider, useFullScreenMenu };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
interface SubMenuContextProps {
|
|
3
|
+
isSubMenuOpen: boolean;
|
|
4
|
+
setIsSubMenuOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
5
|
+
}
|
|
6
|
+
interface SubMenuProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
isSubMenuOpen: boolean;
|
|
9
|
+
setIsSubMenuOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SubMenuMenuProvider: ({ children, isSubMenuOpen, setIsSubMenuOpen }: SubMenuProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const useSubMenu: () => SubMenuContextProps;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, createContext, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const SubMenuContext = /*#__PURE__*/createContext(null);
|
|
5
|
+
const SubMenuMenuProvider = ({
|
|
6
|
+
children,
|
|
7
|
+
isSubMenuOpen,
|
|
8
|
+
setIsSubMenuOpen
|
|
9
|
+
}) => {
|
|
10
|
+
const value = useMemo(() => ({
|
|
11
|
+
isSubMenuOpen,
|
|
12
|
+
setIsSubMenuOpen
|
|
13
|
+
}), [isSubMenuOpen, setIsSubMenuOpen]);
|
|
14
|
+
return jsx(SubMenuContext.Provider, {
|
|
15
|
+
value: value,
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const useSubMenu = () => {
|
|
20
|
+
const context = useContext(SubMenuContext);
|
|
21
|
+
if (context === null) {
|
|
22
|
+
throw new Error('useSubMenu must be used within a DropdownMenu.Root');
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { SubMenuMenuProvider, useSubMenu };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
2
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
export declare const sortMenuChildren: (children: ReactNode) => {
|
|
4
|
+
Header: ReactElement | null;
|
|
5
|
+
OtherChildren: Array<ReactElement>;
|
|
6
|
+
};
|
|
2
7
|
export interface DropdownMenuContentProps extends DropdownMenuPrimitive.DropdownMenuContentProps {
|
|
3
8
|
/** Specify a container element to portal the content into. */
|
|
4
9
|
/** @default document.body */
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
4
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
5
|
+
import { DropdownMenuHeader } from './dropdown-menu-header.js';
|
|
5
6
|
import styles from './dropdown-menu.module.js';
|
|
7
|
+
import { useFullScreenMenu } from './FullScreenMenuContext.js';
|
|
6
8
|
|
|
9
|
+
const sortMenuChildren = children => {
|
|
10
|
+
return Children.toArray(children).reduce((acc, child) => {
|
|
11
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
12
|
+
return acc;
|
|
13
|
+
}
|
|
14
|
+
if (child.type === DropdownMenuHeader) {
|
|
15
|
+
acc.Header = child;
|
|
16
|
+
} else {
|
|
17
|
+
acc.OtherChildren.push(child);
|
|
18
|
+
}
|
|
19
|
+
return acc;
|
|
20
|
+
}, {
|
|
21
|
+
Header: null,
|
|
22
|
+
OtherChildren: []
|
|
23
|
+
});
|
|
24
|
+
};
|
|
7
25
|
/**
|
|
8
26
|
* Based on Radix-UI Content
|
|
9
27
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#content
|
|
@@ -15,6 +33,28 @@ const DropdownMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
15
33
|
className,
|
|
16
34
|
...rest
|
|
17
35
|
} = props;
|
|
36
|
+
const {
|
|
37
|
+
isMenuFullScreenEnabled
|
|
38
|
+
} = useFullScreenMenu();
|
|
39
|
+
if (isMenuFullScreenEnabled) {
|
|
40
|
+
const {
|
|
41
|
+
Header,
|
|
42
|
+
OtherChildren
|
|
43
|
+
} = sortMenuChildren(children);
|
|
44
|
+
return jsx(DropdownMenuPrimitive.Portal, {
|
|
45
|
+
container: container,
|
|
46
|
+
children: jsxs(DropdownMenuPrimitive.Content, {
|
|
47
|
+
...rest,
|
|
48
|
+
ref: forwardedRef,
|
|
49
|
+
className: clsx(styles.content, className),
|
|
50
|
+
"data-menu-fullscreen": true,
|
|
51
|
+
children: [Header, jsx("div", {
|
|
52
|
+
className: styles.fullScreenContent,
|
|
53
|
+
children: OtherChildren
|
|
54
|
+
})]
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
18
58
|
return (
|
|
19
59
|
// TODO(DSYS-440): Unify all Portals (Tooltip, Select, DropdownMenu, etc...), Expose a Provider which would tell where to mount (body? other elem?)
|
|
20
60
|
jsx(DropdownMenuPrimitive.Portal, {
|
|
@@ -32,4 +72,4 @@ const DropdownMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
32
72
|
});
|
|
33
73
|
DropdownMenuContent.displayName = 'DropdownMenuContent';
|
|
34
74
|
|
|
35
|
-
export { DropdownMenuContent };
|
|
75
|
+
export { DropdownMenuContent, sortMenuChildren };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { type IconButtonProps } from '../icon-button';
|
|
3
|
+
export type MenuCloseButtonProps = Omit<IconButtonProps, 'icon' | 'variant' | 'size'>;
|
|
4
|
+
export type TextContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const DropdownMenuHeader: (({ children, className, ...rest }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element) & {
|
|
9
|
+
MenuCloseButton: import("react").ForwardRefExoticComponent<Omit<MenuCloseButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
SubMenuBackButton: import("react").ForwardRefExoticComponent<Omit<MenuCloseButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
TextContent: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
12
|
+
title: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { XMark, PointerChevronLeft } from '@box/blueprint-web-assets/icons/Fill';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { forwardRef, useCallback } from 'react';
|
|
5
|
+
import { Text } from '../../text/text.js';
|
|
6
|
+
import { composeEventHandlers } from '../../utils/composeEventHandlers.js';
|
|
7
|
+
import { IconButton } from '../icon-button/icon-button.js';
|
|
8
|
+
import styles from './dropdown-menu.module.js';
|
|
9
|
+
import { useFullScreenMenu } from './FullScreenMenuContext.js';
|
|
10
|
+
import { useSubMenu } from './SubMenuContext.js';
|
|
11
|
+
|
|
12
|
+
const MenuCloseButton = /*#__PURE__*/forwardRef(({
|
|
13
|
+
onClick,
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
}, ref) => {
|
|
17
|
+
const {
|
|
18
|
+
setIsMenuOpen
|
|
19
|
+
} = useFullScreenMenu();
|
|
20
|
+
const handleCloseClick = useCallback(() => {
|
|
21
|
+
setIsMenuOpen(false);
|
|
22
|
+
}, [setIsMenuOpen]);
|
|
23
|
+
return jsx(IconButton, {
|
|
24
|
+
ref: ref,
|
|
25
|
+
...rest,
|
|
26
|
+
className: clsx(styles.menuCloseButton, className),
|
|
27
|
+
icon: XMark,
|
|
28
|
+
onClick: composeEventHandlers(handleCloseClick, onClick),
|
|
29
|
+
variant: "small-utility"
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const SubMenuBackButton = /*#__PURE__*/forwardRef(({
|
|
33
|
+
onClick,
|
|
34
|
+
className,
|
|
35
|
+
...rest
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const {
|
|
38
|
+
setIsSubMenuOpen
|
|
39
|
+
} = useSubMenu();
|
|
40
|
+
const handleCloseClick = useCallback(() => {
|
|
41
|
+
setIsSubMenuOpen(false);
|
|
42
|
+
}, [setIsSubMenuOpen]);
|
|
43
|
+
return jsx(IconButton, {
|
|
44
|
+
ref: ref,
|
|
45
|
+
...rest,
|
|
46
|
+
className: clsx(styles.submenuCloseButton, className),
|
|
47
|
+
icon: PointerChevronLeft,
|
|
48
|
+
onClick: composeEventHandlers(handleCloseClick, onClick)
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const MenuHeaderPrimitive = ({
|
|
52
|
+
children,
|
|
53
|
+
className,
|
|
54
|
+
...rest
|
|
55
|
+
}) => {
|
|
56
|
+
return jsx("div", {
|
|
57
|
+
...rest,
|
|
58
|
+
className: clsx(styles.menuHeader, className),
|
|
59
|
+
role: "presentation",
|
|
60
|
+
children: children
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const TextContent = /*#__PURE__*/forwardRef(({
|
|
64
|
+
title,
|
|
65
|
+
subtitle,
|
|
66
|
+
className,
|
|
67
|
+
...rest
|
|
68
|
+
}, ref) => {
|
|
69
|
+
return jsxs("div", {
|
|
70
|
+
ref: ref,
|
|
71
|
+
...rest,
|
|
72
|
+
className: clsx(className, styles.headerTextContent),
|
|
73
|
+
children: [jsx(Text, {
|
|
74
|
+
as: "span",
|
|
75
|
+
className: styles.ellipsis,
|
|
76
|
+
variant: "bodyLargeBold",
|
|
77
|
+
children: title
|
|
78
|
+
}), subtitle && jsx(Text, {
|
|
79
|
+
as: "span",
|
|
80
|
+
className: styles.ellipsis,
|
|
81
|
+
color: "textOnLightSecondary",
|
|
82
|
+
variant: "caption",
|
|
83
|
+
children: subtitle
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
const DropdownMenuHeader = Object.assign(MenuHeaderPrimitive, {
|
|
88
|
+
MenuCloseButton,
|
|
89
|
+
SubMenuBackButton,
|
|
90
|
+
TextContent
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export { DropdownMenuHeader };
|
|
@@ -18,6 +18,10 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
18
18
|
className: styles.item,
|
|
19
19
|
onPointerLeave: preventDefault,
|
|
20
20
|
onPointerMove: preventDefault,
|
|
21
|
+
// If click starts at trigger button, and ends on the item, it should not trigger the item.
|
|
22
|
+
// Note: this also has a side effect of not allowing to start click and end on a different time.
|
|
23
|
+
// TODO: see if possible to make https://github.com/radix-ui/primitives/blob/b32a93318cdfce383c2eec095710d35ffbd33a1c/packages/react/menu/src/Menu.tsx#L646
|
|
24
|
+
onPointerUp: preventDefault,
|
|
21
25
|
children: jsx("span", {
|
|
22
26
|
className: styles.ellipsis,
|
|
23
27
|
children: children
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
2
|
-
export type DropdownMenuRootProps = DropdownMenuPrimitive.DropdownMenuProps
|
|
2
|
+
export type DropdownMenuRootProps = DropdownMenuPrimitive.DropdownMenuProps & {
|
|
3
|
+
isFullScreenEnabled?: boolean;
|
|
4
|
+
};
|
|
3
5
|
/**
|
|
4
6
|
* The Dropdown-menu component displays a menu to the user, such as a set of actions or functions—triggered by a button.
|
|
5
7
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import { useControllableState } from '../../utils/useControllableState.js';
|
|
4
|
+
import { FullScreenMenuProvider } from './FullScreenMenuContext.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* The Dropdown-menu component displays a menu to the user, such as a set of actions or functions—triggered by a button.
|
|
@@ -7,11 +9,27 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
|
7
9
|
const DropdownMenuRoot = props => {
|
|
8
10
|
const {
|
|
9
11
|
children,
|
|
12
|
+
isFullScreenEnabled,
|
|
13
|
+
open,
|
|
14
|
+
onOpenChange,
|
|
15
|
+
defaultOpen,
|
|
10
16
|
...rest
|
|
11
17
|
} = props;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const [isMenuOpen = false, setIsMenuOpen] = useControllableState({
|
|
19
|
+
prop: open,
|
|
20
|
+
onChange: onOpenChange,
|
|
21
|
+
defaultProp: defaultOpen
|
|
22
|
+
});
|
|
23
|
+
return jsx(FullScreenMenuProvider, {
|
|
24
|
+
isFullScreenEnabled: isFullScreenEnabled,
|
|
25
|
+
isMenuOpen: isMenuOpen,
|
|
26
|
+
setIsMenuOpen: setIsMenuOpen,
|
|
27
|
+
children: jsx(DropdownMenuPrimitive.Root, {
|
|
28
|
+
...rest,
|
|
29
|
+
onOpenChange: setIsMenuOpen,
|
|
30
|
+
open: isMenuOpen,
|
|
31
|
+
children: children
|
|
32
|
+
})
|
|
15
33
|
});
|
|
16
34
|
};
|
|
17
35
|
DropdownMenuRoot.displayName = 'DropdownMenuRoot';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
4
|
+
import { forwardRef, useCallback } from 'react';
|
|
5
|
+
import { sortMenuChildren } from './dropdown-menu-content.js';
|
|
5
6
|
import styles from './dropdown-menu.module.js';
|
|
7
|
+
import { useFullScreenMenu } from './FullScreenMenuContext.js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Based on Radix-UI Sub Content
|
|
@@ -15,6 +17,32 @@ const DropdownMenuSubMenuContent = /*#__PURE__*/forwardRef((props, forwardedRef)
|
|
|
15
17
|
className,
|
|
16
18
|
...rest
|
|
17
19
|
} = props;
|
|
20
|
+
const {
|
|
21
|
+
isMenuFullScreenEnabled
|
|
22
|
+
} = useFullScreenMenu();
|
|
23
|
+
const preventDefault = useCallback(event => event.preventDefault(), []);
|
|
24
|
+
if (isMenuFullScreenEnabled) {
|
|
25
|
+
const {
|
|
26
|
+
Header,
|
|
27
|
+
OtherChildren
|
|
28
|
+
} = sortMenuChildren(children);
|
|
29
|
+
return jsx(DropdownMenuPrimitive.Portal, {
|
|
30
|
+
container: container,
|
|
31
|
+
children: jsxs(DropdownMenuPrimitive.SubContent, {
|
|
32
|
+
...rest,
|
|
33
|
+
ref: forwardedRef,
|
|
34
|
+
className: clsx(styles.content, className),
|
|
35
|
+
"data-menu-fullscreen": true,
|
|
36
|
+
// Prevents submenu from closing, when detects focus outside submenu in fullscreen mode,
|
|
37
|
+
// while mouse is moving over submenu.
|
|
38
|
+
onFocusOutside: preventDefault,
|
|
39
|
+
children: [Header, jsx("div", {
|
|
40
|
+
className: styles.fullScreenContent,
|
|
41
|
+
children: OtherChildren
|
|
42
|
+
})]
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
18
46
|
return (
|
|
19
47
|
// TODO(DSYS-440): Unify all Portals (Tooltip, Select, DropdownMenu, etc...), Expose a Provider which would tell where to mount (body? other elem?)
|
|
20
48
|
jsx(DropdownMenuPrimitive.Portal, {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
2
2
|
export type DropdownMenuSubMenuRootProps = DropdownMenuPrimitive.DropdownMenuSubProps;
|
|
3
|
+
interface ResponsiveSubmenuContextValue {
|
|
4
|
+
open: boolean;
|
|
5
|
+
setOpen: (open: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const useResponsiveSubmenuContext: () => ResponsiveSubmenuContextValue;
|
|
3
8
|
/**
|
|
4
9
|
* Based on Radix-UI Sub
|
|
5
10
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#sub
|
|
@@ -8,3 +13,4 @@ export declare const DropdownMenuSubMenuRoot: {
|
|
|
8
13
|
(props: DropdownMenuSubMenuRootProps): import("react/jsx-runtime").JSX.Element;
|
|
9
14
|
displayName: string;
|
|
10
15
|
};
|
|
16
|
+
export {};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import noop from 'lodash/noop';
|
|
4
|
+
import { useContext, useCallback, createContext } from 'react';
|
|
5
|
+
import { useControllableState } from '../../utils/useControllableState.js';
|
|
6
|
+
import { SubMenuMenuProvider } from './SubMenuContext.js';
|
|
3
7
|
|
|
8
|
+
const ResponsiveSubmenuContext = /*#__PURE__*/createContext({
|
|
9
|
+
open: false,
|
|
10
|
+
setOpen: noop
|
|
11
|
+
});
|
|
12
|
+
const useResponsiveSubmenuContext = () => {
|
|
13
|
+
return useContext(ResponsiveSubmenuContext);
|
|
14
|
+
};
|
|
4
15
|
/**
|
|
5
16
|
* Based on Radix-UI Sub
|
|
6
17
|
* @see https://www.radix-ui.com/docs/primitives/components/dropdown-menu#sub
|
|
@@ -8,13 +19,30 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
|
8
19
|
const DropdownMenuSubMenuRoot = props => {
|
|
9
20
|
const {
|
|
10
21
|
children,
|
|
22
|
+
defaultOpen,
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange,
|
|
11
25
|
...rest
|
|
12
26
|
} = props;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
const [isSubMenuOpen = false, setIsSubMenuOpen] = useControllableState({
|
|
28
|
+
prop: open,
|
|
29
|
+
onChange: onOpenChange,
|
|
30
|
+
defaultProp: defaultOpen
|
|
31
|
+
});
|
|
32
|
+
const handleOpenChange = useCallback(value => {
|
|
33
|
+
setIsSubMenuOpen(value);
|
|
34
|
+
}, [setIsSubMenuOpen]);
|
|
35
|
+
return jsx(SubMenuMenuProvider, {
|
|
36
|
+
isSubMenuOpen: isSubMenuOpen,
|
|
37
|
+
setIsSubMenuOpen: setIsSubMenuOpen,
|
|
38
|
+
children: jsx(DropdownMenuPrimitive.Sub, {
|
|
39
|
+
...rest,
|
|
40
|
+
onOpenChange: handleOpenChange,
|
|
41
|
+
open: isSubMenuOpen,
|
|
42
|
+
children: children
|
|
43
|
+
})
|
|
16
44
|
});
|
|
17
45
|
};
|
|
18
46
|
DropdownMenuSubMenuRoot.displayName = 'DropdownMenuSubMenuRoot';
|
|
19
47
|
|
|
20
|
-
export { DropdownMenuSubMenuRoot };
|
|
48
|
+
export { DropdownMenuSubMenuRoot, useResponsiveSubmenuContext };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useEffect, useCallback } from 'react';
|
|
4
4
|
import { MenuItemSideContent, MenuItemMainContent } from '../../util-components/menu-item-sections/menu-item-sections.js';
|
|
5
5
|
import { useForkRef } from '../../utils/useForkRef.js';
|
|
6
6
|
import { useSubMenuFocus } from '../../utils/useSubMenuFocus.hook.js';
|
|
7
|
+
import { useResponsiveSubmenuContext } from './dropdown-menu-sub-menu-root.js';
|
|
7
8
|
import styles from './dropdown-menu.module.js';
|
|
9
|
+
import { useFullScreenMenu } from './FullScreenMenuContext.js';
|
|
8
10
|
|
|
9
11
|
const DropdownMenuSubMenuTriggerRoot = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
10
12
|
const {
|
|
@@ -12,11 +14,29 @@ const DropdownMenuSubMenuTriggerRoot = /*#__PURE__*/forwardRef((props, forwarded
|
|
|
12
14
|
...rest
|
|
13
15
|
} = props;
|
|
14
16
|
const [localRef, setRefFocusNoop] = useSubMenuFocus();
|
|
17
|
+
const {
|
|
18
|
+
open
|
|
19
|
+
} = useResponsiveSubmenuContext();
|
|
20
|
+
const {
|
|
21
|
+
isMenuFullScreenEnabled
|
|
22
|
+
} = useFullScreenMenu();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!open) {
|
|
25
|
+
localRef.current?.focus();
|
|
26
|
+
}
|
|
27
|
+
}, [localRef, open]);
|
|
28
|
+
const handleOnPointerMove = useCallback(e => {
|
|
29
|
+
setRefFocusNoop();
|
|
30
|
+
// we should call prevent default so hover doesn't trigger submenu, which is confusing on full screen.
|
|
31
|
+
if (isMenuFullScreenEnabled) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
}
|
|
34
|
+
}, [isMenuFullScreenEnabled, setRefFocusNoop]);
|
|
15
35
|
return jsx(DropdownMenuPrimitive.SubTrigger, {
|
|
16
36
|
...rest,
|
|
17
37
|
ref: useForkRef(localRef, forwardedRef),
|
|
18
38
|
className: styles.item,
|
|
19
|
-
onPointerMove:
|
|
39
|
+
onPointerMove: handleOnPointerMove,
|
|
20
40
|
children: children
|
|
21
41
|
});
|
|
22
42
|
});
|