carbon-react 153.5.2 → 153.7.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/esm/__internal__/utils/createStrictContext.d.ts +31 -0
- package/esm/__internal__/utils/createStrictContext.js +36 -0
- package/esm/__internal__/utils/logger/index.d.ts +7 -0
- package/esm/__internal__/utils/logger/index.js +11 -9
- package/esm/components/icon/fonts/carbon-icons-webfont.woff +0 -0
- package/esm/components/icon/fonts/carbon-icons-webfont.woff2 +0 -0
- package/esm/components/icon/icon-config.js +1 -1
- package/esm/components/icon/icon-type.d.ts +1 -1
- package/esm/components/icon/icon-unicodes.d.ts +15 -0
- package/esm/components/icon/icon-unicodes.js +16 -1
- package/esm/components/menu/__internal__/menu.context.d.ts +3 -12
- package/esm/components/menu/__internal__/menu.context.js +3 -5
- package/esm/components/menu/__internal__/strict-menu.context.d.ts +14 -0
- package/esm/components/menu/__internal__/strict-menu.context.js +11 -0
- package/esm/components/menu/__internal__/submenu/submenu.component.js +3 -4
- package/esm/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
- package/esm/components/menu/index.d.ts +1 -1
- package/esm/components/menu/menu-divider/menu-divider.component.js +6 -4
- package/esm/components/menu/menu-divider/menu-divider.style.d.ts +1 -1
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +4 -5
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.d.ts +1 -1
- package/esm/components/menu/menu-item/menu-item.component.js +4 -4
- package/esm/components/menu/menu-item/menu-item.style.d.ts +1 -1
- package/esm/components/menu/menu-segment-title/menu-segment-title.component.js +10 -7
- package/esm/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -1
- package/esm/components/menu/menu.component.d.ts +1 -9
- package/esm/components/menu/menu.component.js +9 -5
- package/esm/components/menu/menu.style.d.ts +1 -1
- package/esm/components/menu/menu.types.d.ts +10 -0
- package/esm/components/menu/menu.types.js +1 -0
- package/esm/components/menu/scrollable-block/scrollable-block.component.js +3 -3
- package/esm/components/menu/scrollable-block/scrollable-block.style.d.ts +1 -1
- package/esm/components/vertical-divider/vertical-divider.component.js +1 -1
- package/esm/style/assets/carbon-icons-webfont.woff +0 -0
- package/esm/style/assets/carbon-icons-webfont.woff2 +0 -0
- package/lib/__internal__/utils/createStrictContext.d.ts +31 -0
- package/lib/__internal__/utils/createStrictContext.js +43 -0
- package/lib/__internal__/utils/logger/index.d.ts +7 -0
- package/lib/__internal__/utils/logger/index.js +11 -9
- package/lib/components/icon/fonts/carbon-icons-webfont.woff +0 -0
- package/lib/components/icon/fonts/carbon-icons-webfont.woff2 +0 -0
- package/lib/components/icon/icon-config.js +1 -1
- package/lib/components/icon/icon-type.d.ts +1 -1
- package/lib/components/icon/icon-unicodes.d.ts +15 -0
- package/lib/components/icon/icon-unicodes.js +16 -1
- package/lib/components/menu/__internal__/menu.context.d.ts +3 -12
- package/lib/components/menu/__internal__/menu.context.js +3 -6
- package/lib/components/menu/__internal__/strict-menu.context.d.ts +14 -0
- package/lib/components/menu/__internal__/strict-menu.context.js +19 -0
- package/lib/components/menu/__internal__/submenu/submenu.component.js +3 -4
- package/lib/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
- package/lib/components/menu/index.d.ts +1 -1
- package/lib/components/menu/menu-divider/menu-divider.component.js +8 -8
- package/lib/components/menu/menu-divider/menu-divider.style.d.ts +1 -1
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +3 -4
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.d.ts +1 -1
- package/lib/components/menu/menu-item/menu-item.component.js +7 -7
- package/lib/components/menu/menu-item/menu-item.style.d.ts +1 -1
- package/lib/components/menu/menu-segment-title/menu-segment-title.component.js +12 -9
- package/lib/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -1
- package/lib/components/menu/menu.component.d.ts +1 -9
- package/lib/components/menu/menu.component.js +9 -5
- package/lib/components/menu/menu.style.d.ts +1 -1
- package/lib/components/menu/menu.types.d.ts +10 -0
- package/lib/components/menu/menu.types.js +5 -0
- package/lib/components/menu/scrollable-block/scrollable-block.component.js +3 -5
- package/lib/components/menu/scrollable-block/scrollable-block.style.d.ts +1 -1
- package/lib/components/vertical-divider/vertical-divider.component.js +1 -1
- package/lib/style/assets/carbon-icons-webfont.woff +0 -0
- package/lib/style/assets/carbon-icons-webfont.woff2 +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type CreateStrictContextArgs<ContextType> = {
|
|
3
|
+
/** The display name of the context. */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Error message to log if context is accessed outside its provider. */
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
/** Default value to return if context is accessed outside its provider. */
|
|
8
|
+
defaultValue: ContextType;
|
|
9
|
+
};
|
|
10
|
+
type CreateStrictContextReturn<ContextType> = readonly [
|
|
11
|
+
React.Provider<ContextType | null>,
|
|
12
|
+
() => ContextType
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Creates a React context with a provider and a hook for accessing the context.
|
|
16
|
+
* Logs an error and returns a default value if the hook is used outside of the provider.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const [ListProvider, useList] = createStrictContext<{ size: number }>({
|
|
22
|
+
* name: "ListContext",
|
|
23
|
+
* errorMessage: "ListContext is undefined. Make sure to wrap your component with <ListProvider />",
|
|
24
|
+
* defaultValue: {
|
|
25
|
+
* size: 0,
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function createStrictContext<ContextType>({ name, errorMessage, defaultValue, }: CreateStrictContextArgs<ContextType>): CreateStrictContextReturn<ContextType>;
|
|
31
|
+
export default createStrictContext;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Logger from "./logger";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a React context with a provider and a hook for accessing the context.
|
|
5
|
+
* Logs an error and returns a default value if the hook is used outside of the provider.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const [ListProvider, useList] = createStrictContext<{ size: number }>({
|
|
11
|
+
* name: "ListContext",
|
|
12
|
+
* errorMessage: "ListContext is undefined. Make sure to wrap your component with <ListProvider />",
|
|
13
|
+
* defaultValue: {
|
|
14
|
+
* size: 0,
|
|
15
|
+
* },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function createStrictContext({
|
|
20
|
+
name,
|
|
21
|
+
errorMessage,
|
|
22
|
+
defaultValue
|
|
23
|
+
}) {
|
|
24
|
+
const Context = /*#__PURE__*/React.createContext(null);
|
|
25
|
+
Context.displayName = name;
|
|
26
|
+
function useContext() {
|
|
27
|
+
const context = React.useContext(Context);
|
|
28
|
+
if (!context) {
|
|
29
|
+
Logger.error(`${errorMessage}\nThis logged warning will become a thrown error in a future major release.`);
|
|
30
|
+
return defaultValue;
|
|
31
|
+
}
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
return [Context.Provider, useContext];
|
|
35
|
+
}
|
|
36
|
+
export default createStrictContext;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for dispatching messages to the browser console.
|
|
3
|
+
* By default, logging is disabled in production mode.
|
|
4
|
+
*/
|
|
1
5
|
declare const Logger: {
|
|
2
6
|
setEnabledState: (newState: boolean) => void;
|
|
7
|
+
/** Logs warning-level message to browser console with [Deprecation] prefix */
|
|
3
8
|
deprecate: (message: string) => void;
|
|
9
|
+
/** Logs error-level message to browser console. Includes stack trace. */
|
|
10
|
+
error: (message: string) => void;
|
|
4
11
|
};
|
|
5
12
|
export default Logger;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
|
|
2
3
|
// Globally enable the logger
|
|
3
4
|
let enabled = process.env.NODE_ENV !== "production";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Logger function will only output when enabled. By default this
|
|
9
|
-
* enabled state is set when your NODE_ENV !== 'production'
|
|
10
|
-
*
|
|
11
|
-
* Methods
|
|
12
|
-
* deprecate - console.warn which prepends the message with [Deprecation]
|
|
13
|
-
*
|
|
6
|
+
/**
|
|
7
|
+
* Utility for dispatching messages to the browser console.
|
|
8
|
+
* By default, logging is disabled in production mode.
|
|
14
9
|
*/
|
|
15
10
|
const Logger = {
|
|
16
11
|
setEnabledState: newState => {
|
|
17
12
|
enabled = newState;
|
|
18
13
|
},
|
|
14
|
+
/** Logs warning-level message to browser console with [Deprecation] prefix */
|
|
19
15
|
deprecate: message => {
|
|
20
16
|
if (enabled) {
|
|
21
17
|
console.warn(`[Deprecation] ${message}`);
|
|
22
18
|
}
|
|
19
|
+
},
|
|
20
|
+
/** Logs error-level message to browser console. Includes stack trace. */
|
|
21
|
+
error: message => {
|
|
22
|
+
if (enabled) {
|
|
23
|
+
console.error(message);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
export default Logger;
|
|
Binary file
|
|
Binary file
|
|
@@ -22,5 +22,5 @@ export const ICON_TOOLTIP_POSITIONS = ["bottom", "left", "right", "top"];
|
|
|
22
22
|
export const ICON_SHAPES = ["circle", "rounded-rect", "square"];
|
|
23
23
|
export const ICON_SIZES = ["small", "medium", "large", "extra-large"];
|
|
24
24
|
export const ICON_FONT_SIZES = ["small", "medium", "large", "extra-large"];
|
|
25
|
-
export const ICONS = ["accessibility_web", "add", "admin", "alert", "alert_on", "analysis", "app_facebook", "app_instagram", "app_tiktok", "app_twitter", "app_youtube", "apps", "arrow", "arrow_bottom_right_circle", "arrow_down", "arrow_left", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_right", "arrow_right_small", "arrow_top_left_circle", "arrow_up", "arrows_left_right", "attach", "bank", "bank_with_card", "basket", "basket_with_squares", "bed", "bill_paid", "bill_unpaid", "bin", "biometric", "blocked", "blocked_square", "block_arrow_right", "bold", "box_arrow_left", "box_arrow_right", "boxed_shapes", "bulk_destroy", "bullet_list", "bullet_list_dotted", "bullet_list_numbers", "business", "calendar", "calendar_today", "call", "calendar_pay_date", "camera", "car_lock", "car_money", "car_repair", "card_view", "card_wallet", "caret_down", "caret_left", "caret_right", "caret_up", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "cart", "cash", "chat", "chart_bar", "chart_line", "chart_pie", "chat_notes", "check_all", "check_none", "chevron_down", "chevron_left", "chevron_right", "chevron_up", "chevron_down_thick", "chevron_left_thick", "chevron_right_thick", "chevron_up_thick", "circle_with_dots", "circles_connection", "clock", "close", "cloud_co2", "coins", "collaborate", "computer_clock", "connect", "connect_off", "construction", "contacts", "contact_card", "copy", "create", "credit_card", "credit_card_slash", "cross", "cross_circle", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "drag", "drag_vertical", "draft", "drill", "dropdown", "duplicate", "edit", "edited", "email", "email_switch", "entry", "ellipsis_horizontal", "ellipsis_vertical", "envelope_dollar", "envelope_euro", "error", "error_square", "euro", "expand", "export", "factory", "favourite", "favourite_lined", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter", "filter_new", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "heart_pulse", "help", "hide", "hand_cash_coins", "hand_cash_note", "home", "image", "import", "in_progress", "in_transit", "individual", "info", "intranet", "italic", "job_seeked", "key", "laptop", "leaf", "ledger", "ledger_arrow_left", "ledger_arrow_right", "lightbulb_off", "lightbulb_on", "like", "like_no", "link", "link_cloud", "link_on", "list_view", "locked", "location", "logout", "lookup", "marker", "message", "microphone", "minimise", "minus", "minus_large", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause", "pause_circle", "petrol_pump", "pdf", "pin", "people", "people_switch", "percentage_boxed", "person", "person_info", "person_tick", "phone", "piggy_bank", "plane", "play", "play_circle", "plus", "plus_large", "pound", "print", "progress", "progressed", "protect", "question", "question_hollow", "question_mark", "recruiting", "refresh", "refresh_clock", "remove", "sage_coin", "save", "scan", "search", "send", "services", "settings", "settings_old", "share", "shield_with_tick", "shield_with_tick_outline", "shop", "sort_down", "sort_up", "spanner", "split", "split_container", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "stop", "stop_circle", "submitted", "support_online", "sync", "tag", "talk", "target", "target_man", "theatre_masks", "three_boxes", "tick", "tick_circle", "tick_thick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "volunteering", "warning", "website", "welfare", "worldwide_location"];
|
|
25
|
+
export const ICONS = ["accessibility_web", "add", "admin", "airplay", "alert", "alert_on", "analysis", "app_facebook", "app_instagram", "app_tiktok", "app_twitter", "app_youtube", "apps", "arrow", "arrow_bottom_right_circle", "arrow_down", "arrow_left", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_right", "arrow_right_small", "arrow_top_left_circle", "arrow_up", "arrows_left_right", "attach", "bank", "bank_with_card", "basket", "basket_with_squares", "batch", "bed", "bill_paid", "bill_unpaid", "bin", "biometric", "blocked", "blocked_square", "block_arrow_right", "bold", "box_arrow_left", "box_arrow_right", "boxed_shapes", "bulk_destroy", "bullet_list", "bullet_list_dotted", "bullet_list_numbers", "business", "calendar", "calendar_today", "call", "calendar_pay_date", "camera", "car_lock", "car_money", "car_repair", "card_view", "card_wallet", "caret_down", "caret_left", "caret_right", "caret_up", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "cart", "cash", "chat", "chart_bar", "chart_line", "chart_pie", "chat_notes", "check_all", "check_none", "chevron_down", "chevron_left", "chevron_right", "chevron_up", "chevron_down_thick", "chevron_left_thick", "chevron_right_thick", "chevron_up_thick", "chromecast", "circle_with_dots", "circles_connection", "clock", "close", "cloud_co2", "coins", "collaborate", "computer_clock", "connect", "connect_off", "construction", "contacts", "contact_card", "copy", "create", "credit_card", "credit_card_slash", "cross", "cross_circle", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "drag", "drag_vertical", "draft", "drill", "dropdown", "duplicate", "edit", "edited", "email", "email_switch", "entry", "ellipsis_horizontal", "ellipsis_vertical", "envelope_dollar", "envelope_euro", "error", "error_square", "euro", "expand", "export", "factory", "favourite", "favourite_lined", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter", "filter_new", "fit_height", "fit_width", "flag", "folder", "form_refresh", "framerate", "fullscreen", "gift", "go", "graduation_hat", "graph", "grid", "heart_pulse", "help", "hide", "hand_cash_coins", "hand_cash_note", "home", "image", "import", "in_progress", "in_transit", "individual", "info", "intranet", "italic", "job_seeked", "key", "laptop", "leaf", "ledger", "ledger_arrow_left", "ledger_arrow_right", "lightbulb_off", "lightbulb_on", "like", "like_no", "link", "link_cloud", "link_on", "list_view", "locked", "location", "logout", "lookup", "marker", "message", "microphone", "minimise", "minus", "minus_large", "mobile", "money_bag", "mute", "none", "normalscreen", "old_warning", "page", "palm_tree", "pause", "pause_circle", "petrol_pump", "pdf", "pin", "people", "people_switch", "percentage_boxed", "person", "person_info", "person_tick", "phone", "picture_in_picture", "piggy_bank", "plane", "play", "play_circle", "plus", "plus_large", "pound", "print", "progress", "progressed", "protect", "question", "question_hollow", "question_mark", "recruiting", "refresh", "refresh_clock", "remove", "replay", "sage_coin", "save", "scan", "search", "send", "services", "settings", "settings_old", "share", "shield_with_tick", "shield_with_tick_outline", "shop", "sort_down", "sort_up", "spanner", "speaker", "split", "split_container", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "stop", "stop_circle", "submitted", "subtitles", "support_online", "sync", "tag", "talk", "target", "target_man", "theatre_masks", "three_boxes", "tick", "tick_circle", "tick_thick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "volume_high", "volume_low", "volume_medium", "volunteering", "warning", "website", "welfare", "worldwide_location"];
|
|
26
26
|
export default dlsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type IconType = "accessibility_web" | "add" | "admin" | "alert" | "alert_on" | "analysis" | "app_facebook" | "app_instagram" | "app_tiktok" | "app_twitter" | "app_youtube" | "apps" | "arrow" | "arrow_bottom_right_circle" | "arrow_down" | "arrow_left" | "arrow_left_boxed" | "arrow_left_right_small" | "arrow_left_small" | "arrow_right" | "arrow_right_small" | "arrow_top_left_circle" | "arrow_up" | "arrows_left_right" | "attach" | "bank" | "bank_with_card" | "basket" | "basket_with_squares" | "bed" | "bill_paid" | "bill_unpaid" | "bin" | "biometric" | "blocked" | "blocked_square" | "block_arrow_right" | "bold" | "box_arrow_left" | "box_arrow_right" | "boxed_shapes" | "bulk_destroy" | "bullet_list" | "bullet_list_dotted" | "bullet_list_numbers" | "business" | "calendar" | "calendar_pay_date" | "calendar_today" | "call" | "camera" | "car_lock" | "car_money" | "car_repair" | "card_wallet" | "card_view" | "caret_down" | "caret_left" | "caret_right" | "caret_up" | "caret_large_down" | "caret_large_left" | "caret_large_right" | "caret_large_up" | "cart" | "cash" | "chat" | "chart_bar" | "chart_line" | "chart_pie" | "chat_notes" | "check_all" | "check_none" | "chevron_down" | "chevron_left" | "chevron_right" | "chevron_up" | "chevron_down_thick" | "chevron_left_thick" | "chevron_right_thick" | "chevron_up_thick" | "circle_with_dots" | "circles_connection" | "clock" | "close" | "cloud_co2" | "coins" | "collaborate" | "computer_clock" | "connect" | "connect_off" | "construction" | "contacts" | "contact_card" | "copy" | "create" | "credit_card" | "credit_card_slash" | "cross" | "cross_circle" | "csv" | "dashboard" | "delete" | "delivery" | "disputed" | "disconnect" | "document_right_align" | "document_tick" | "document_vertical_lines" | "download" | "drag" | "drag_vertical" | "draft" | "drill" | "dropdown" | "duplicate" | "edit" | "edited" | "email" | "email_switch" | "entry" | "envelope_dollar" | "envelope_euro" | "ellipsis_horizontal" | "ellipsis_vertical" | "error" | "error_square" | "euro" | "expand" | "export" | "factory" | "favourite" | "favourite_lined" | "fax" | "feedback" | "file_excel" | "file_generic" | "file_image" | "file_pdf" | "file_word" | "files_leaning" | "filter" | "filter_new" | "fit_height" | "fit_width" | "flag" | "folder" | "form_refresh" | "gift" | "go" | "graduation_hat" | "graph" | "grid" | "hand_cash_coins" | "hand_cash_note" | "heart_pulse" | "help" | "hide" | "home" | "image" | "import" | "in_progress" | "in_transit" | "individual" | "info" | "intranet" | "italic" | "job_seeked" | "key" | "laptop" | "leaf" | "ledger" | "ledger_arrow_left" | "ledger_arrow_right" | "like" | "like_no" | "link" | "lightbulb_off" | "lightbulb_on" | "link_cloud" | "link_on" | "list_view" | "locked" | "location" | "logout" | "lookup" | "marker" | "message" | "microphone" | "minimise" | "minus" | "minus_large" | "mobile" | "money_bag" | "none" | "old_warning" | "palm_tree" | "pause" | "pause_circle" | "pdf" | "pin" | "people" | "people_switch" | "percentage_boxed" | "person" | "person_info" | "person_tick" | "petrol_pump" | "phone" | "piggy_bank" | "plane" | "play" | "play_circle" | "plus" | "plus_large" | "pound" | "print" | "progress" | "progressed" | "protect" | "question" | "question_hollow" | "question_mark" | "recruiting" | "refresh" | "refresh_clock" | "remove" | "sage_coin" | "save" | "scan" | "send" | "search" | "services" | "settings" | "settings_old" | "share" | "shield_with_tick" | "shield_with_tick_outline" | "shop" | "sort_down" | "sort_up" | "spanner" | "split" | "split_container" | "square_dot" | "squares_nine" | "stacked_boxes" | "stacked_squares" | "stop" | "stop_circle" | "support_online" | "submitted" | "sync" | "tag" | "talk" | "target" | "target_man" | "theatre_masks" | "three_boxes" | "tick" | "tick_circle" | "tick_thick" | "true_tick" | "u_turn_left" | "u_turn_right" | "undo" | "unlocked" | "upload" | "uploaded" | "video" | "view" | "volunteering" | "warning" | "website" | "welfare" | "worldwide_location";
|
|
1
|
+
export type IconType = "accessibility_web" | "add" | "admin" | "airplay" | "alert" | "alert_on" | "analysis" | "app_facebook" | "app_instagram" | "app_tiktok" | "app_twitter" | "app_youtube" | "apps" | "arrow" | "arrow_bottom_right_circle" | "arrow_down" | "arrow_left" | "arrow_left_boxed" | "arrow_left_right_small" | "arrow_left_small" | "arrow_right" | "arrow_right_small" | "arrow_top_left_circle" | "arrow_up" | "arrows_left_right" | "attach" | "bank" | "bank_with_card" | "basket" | "basket_with_squares" | "batch" | "bed" | "bill_paid" | "bill_unpaid" | "bin" | "biometric" | "blocked" | "blocked_square" | "block_arrow_right" | "bold" | "box_arrow_left" | "box_arrow_right" | "boxed_shapes" | "bulk_destroy" | "bullet_list" | "bullet_list_dotted" | "bullet_list_numbers" | "business" | "calendar" | "calendar_pay_date" | "calendar_today" | "call" | "camera" | "car_lock" | "car_money" | "car_repair" | "card_wallet" | "card_view" | "caret_down" | "caret_left" | "caret_right" | "caret_up" | "caret_large_down" | "caret_large_left" | "caret_large_right" | "caret_large_up" | "cart" | "cash" | "chat" | "chart_bar" | "chart_line" | "chart_pie" | "chat_notes" | "check_all" | "check_none" | "chevron_down" | "chevron_left" | "chevron_right" | "chevron_up" | "chevron_down_thick" | "chevron_left_thick" | "chevron_right_thick" | "chevron_up_thick" | "chromecast" | "circle_with_dots" | "circles_connection" | "clock" | "close" | "cloud_co2" | "coins" | "collaborate" | "computer_clock" | "connect" | "connect_off" | "construction" | "contacts" | "contact_card" | "copy" | "create" | "credit_card" | "credit_card_slash" | "cross" | "cross_circle" | "csv" | "dashboard" | "delete" | "delivery" | "disputed" | "disconnect" | "document_right_align" | "document_tick" | "document_vertical_lines" | "download" | "drag" | "drag_vertical" | "draft" | "drill" | "dropdown" | "duplicate" | "edit" | "edited" | "email" | "email_switch" | "entry" | "envelope_dollar" | "envelope_euro" | "ellipsis_horizontal" | "ellipsis_vertical" | "error" | "error_square" | "euro" | "expand" | "export" | "factory" | "favourite" | "favourite_lined" | "fax" | "feedback" | "file_excel" | "file_generic" | "file_image" | "file_pdf" | "file_word" | "files_leaning" | "filter" | "filter_new" | "fit_height" | "fit_width" | "flag" | "folder" | "form_refresh" | "framerate" | "fullscreen" | "gift" | "go" | "graduation_hat" | "graph" | "grid" | "hand_cash_coins" | "hand_cash_note" | "heart_pulse" | "help" | "hide" | "home" | "image" | "import" | "in_progress" | "in_transit" | "individual" | "info" | "intranet" | "italic" | "job_seeked" | "key" | "laptop" | "leaf" | "ledger" | "ledger_arrow_left" | "ledger_arrow_right" | "like" | "like_no" | "link" | "lightbulb_off" | "lightbulb_on" | "link_cloud" | "link_on" | "list_view" | "locked" | "location" | "logout" | "lookup" | "marker" | "message" | "microphone" | "minimise" | "minus" | "minus_large" | "mobile" | "money_bag" | "mute" | "none" | "normalscreen" | "old_warning" | "page" | "palm_tree" | "pause" | "pause_circle" | "pdf" | "pin" | "people" | "people_switch" | "percentage_boxed" | "person" | "person_info" | "person_tick" | "petrol_pump" | "phone" | "picture_in_picture" | "piggy_bank" | "plane" | "play" | "play_circle" | "plus" | "plus_large" | "pound" | "print" | "progress" | "progressed" | "protect" | "question" | "question_hollow" | "question_mark" | "recruiting" | "refresh" | "refresh_clock" | "remove" | "replay" | "sage_coin" | "save" | "scan" | "send" | "search" | "services" | "settings" | "settings_old" | "share" | "shield_with_tick" | "shield_with_tick_outline" | "shop" | "sort_down" | "sort_up" | "spanner" | "speaker" | "split" | "split_container" | "square_dot" | "squares_nine" | "stacked_boxes" | "stacked_squares" | "stop" | "stop_circle" | "subtitles" | "support_online" | "submitted" | "sync" | "tag" | "talk" | "target" | "target_man" | "theatre_masks" | "three_boxes" | "tick" | "tick_circle" | "tick_thick" | "true_tick" | "u_turn_left" | "u_turn_right" | "undo" | "unlocked" | "upload" | "uploaded" | "video" | "view" | "volume_high" | "volume_low" | "volume_medium" | "volunteering" | "warning" | "website" | "welfare" | "worldwide_location";
|
|
@@ -159,6 +159,21 @@ declare namespace iconUnicodes {
|
|
|
159
159
|
export let stop: string;
|
|
160
160
|
export let stop_circle: string;
|
|
161
161
|
export let worldwide_location: string;
|
|
162
|
+
export let airplay: string;
|
|
163
|
+
export let batch: string;
|
|
164
|
+
export let chromecast: string;
|
|
165
|
+
export let framerate: string;
|
|
166
|
+
export let fullscreen: string;
|
|
167
|
+
export let mute: string;
|
|
168
|
+
export let normalscreen: string;
|
|
169
|
+
export let page: string;
|
|
170
|
+
export let picture_in_picture: string;
|
|
171
|
+
export let replay: string;
|
|
172
|
+
export let speaker: string;
|
|
173
|
+
export let subtitles: string;
|
|
174
|
+
export let volume_high: string;
|
|
175
|
+
export let volume_low: string;
|
|
176
|
+
export let volume_medium: string;
|
|
162
177
|
export let error: string;
|
|
163
178
|
export let warning: string;
|
|
164
179
|
export let tick: string;
|
|
@@ -257,7 +257,22 @@ const misc = {
|
|
|
257
257
|
shield_with_tick_outline: "\\f071",
|
|
258
258
|
stop: "\\f068",
|
|
259
259
|
stop_circle: "\\f069",
|
|
260
|
-
worldwide_location: "\\f072"
|
|
260
|
+
worldwide_location: "\\f072",
|
|
261
|
+
airplay: "\\f073",
|
|
262
|
+
batch: "\\f074",
|
|
263
|
+
chromecast: "\\f075",
|
|
264
|
+
framerate: "\\f076",
|
|
265
|
+
fullscreen: "\\f077",
|
|
266
|
+
mute: "\\f078",
|
|
267
|
+
normalscreen: "\\f079",
|
|
268
|
+
page: "\\f080",
|
|
269
|
+
picture_in_picture: "\\f081",
|
|
270
|
+
replay: "\\f082",
|
|
271
|
+
speaker: "\\f083",
|
|
272
|
+
subtitles: "\\f084",
|
|
273
|
+
volume_high: "\\f087",
|
|
274
|
+
volume_low: "\\f085",
|
|
275
|
+
volume_medium: "\\f086"
|
|
261
276
|
};
|
|
262
277
|
const legacyNames = {
|
|
263
278
|
add: actions.plus,
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface MenuContextProps {
|
|
4
|
-
menuType: MenuType;
|
|
5
|
-
openSubmenuId: string | null;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface MenuContextType {
|
|
6
3
|
inMenu?: boolean;
|
|
7
|
-
inFullscreenView?: boolean;
|
|
8
|
-
setOpenSubmenuId: (id: string | null) => void;
|
|
9
|
-
registerItem?: (id: string) => void;
|
|
10
|
-
unregisterItem?: (id: string) => void;
|
|
11
|
-
focusId?: string;
|
|
12
|
-
updateFocusId?: (id: string) => void;
|
|
13
4
|
}
|
|
14
|
-
declare const _default:
|
|
5
|
+
declare const _default: import("react").Context<MenuContextType>;
|
|
15
6
|
export default _default;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default /*#__PURE__*/
|
|
3
|
-
|
|
4
|
-
openSubmenuId: null,
|
|
5
|
-
setOpenSubmenuId: /* istanbul ignore next */() => {}
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
export default /*#__PURE__*/createContext({
|
|
3
|
+
inMenu: false
|
|
6
4
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { MenuType } from "../menu.types";
|
|
3
|
+
export interface StrictMenuContextType {
|
|
4
|
+
menuType: MenuType;
|
|
5
|
+
openSubmenuId: string | null;
|
|
6
|
+
inFullscreenView?: boolean;
|
|
7
|
+
setOpenSubmenuId: (id: string | null) => void;
|
|
8
|
+
registerItem?: (id: string) => void;
|
|
9
|
+
unregisterItem?: (id: string) => void;
|
|
10
|
+
focusId?: string;
|
|
11
|
+
updateFocusId?: (id: string) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const StrictMenuProvider: import("react").Provider<StrictMenuContextType | null>, useStrictMenuContext: () => StrictMenuContextType;
|
|
14
|
+
export { StrictMenuProvider, useStrictMenuContext };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import createStrictContext from "../../../__internal__/utils/createStrictContext";
|
|
2
|
+
const [StrictMenuProvider, useStrictMenuContext] = createStrictContext({
|
|
3
|
+
name: "MenuContext",
|
|
4
|
+
errorMessage: "Carbon Menu: Context not found. Have you wrapped your Carbon subcomponents properly? See stack trace for more details.",
|
|
5
|
+
defaultValue: {
|
|
6
|
+
menuType: "light",
|
|
7
|
+
openSubmenuId: null,
|
|
8
|
+
setOpenSubmenuId: /* istanbul ignore next */() => {}
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { StrictMenuProvider, useStrictMenuContext };
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useContext, useMemo, useRef, useState }
|
|
|
3
3
|
import StyledMenuItemWrapper from "../../menu-item/menu-item.style";
|
|
4
4
|
import { StyledSubmenu, StyledSubmenuWrapper } from "./submenu.style";
|
|
5
5
|
import Events from "../../../../__internal__/utils/helpers/events";
|
|
6
|
-
import
|
|
6
|
+
import { useStrictMenuContext } from "../strict-menu.context";
|
|
7
7
|
import { characterNavigation } from "../keyboard-navigation";
|
|
8
8
|
import SubmenuContext from "./submenu.context";
|
|
9
9
|
import guid from "../../../../__internal__/utils/helpers/guid";
|
|
@@ -33,13 +33,12 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
33
33
|
}, ref) => {
|
|
34
34
|
const [submenuRef, setSubmenuRef] = useState(null);
|
|
35
35
|
const submenuId = useRef(guid());
|
|
36
|
-
const menuContext = useContext(MenuContext);
|
|
37
36
|
const {
|
|
38
37
|
inFullscreenView,
|
|
39
38
|
openSubmenuId,
|
|
40
39
|
setOpenSubmenuId,
|
|
41
40
|
menuType
|
|
42
|
-
} =
|
|
41
|
+
} = useStrictMenuContext();
|
|
43
42
|
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
44
43
|
const [submenuFocusId, setSubmenuFocusId] = useState(null);
|
|
45
44
|
const [submenuItemIds, setSubmenuItemIds] = useState([]);
|
|
@@ -265,7 +264,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
265
264
|
"data-component": "submenu-wrapper",
|
|
266
265
|
inFullscreenView: inFullscreenView,
|
|
267
266
|
asPassiveItem: asPassiveItem,
|
|
268
|
-
menuType:
|
|
267
|
+
menuType: menuType
|
|
269
268
|
}, /*#__PURE__*/React.createElement(StyledMenuItemWrapper, _extends({}, rest, {
|
|
270
269
|
onClick: asPassiveItem ? undefined : onClick,
|
|
271
270
|
className: className,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as Menu } from "./menu.component";
|
|
2
|
-
export type { MenuProps } from "./menu.
|
|
2
|
+
export type { MenuProps } from "./menu.types";
|
|
3
3
|
export { default as MenuItem } from "./menu-item";
|
|
4
4
|
export type { MenuWithIcon, MenuWithChildren } from "./menu-item";
|
|
5
5
|
export { default as MenuDivider } from "./menu-divider";
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
import StyledDivider from "./menu-divider.style";
|
|
4
|
-
import
|
|
4
|
+
import { useStrictMenuContext } from "../__internal__/strict-menu.context";
|
|
5
5
|
import { StyledMenuItem } from "../menu.style";
|
|
6
6
|
import tagComponent from "../../../__internal__/utils/helpers/tags";
|
|
7
7
|
const MenuDivider = /*#__PURE__*/React.forwardRef(({
|
|
8
8
|
size = "default",
|
|
9
9
|
...rest
|
|
10
10
|
}, ref) => {
|
|
11
|
-
const
|
|
11
|
+
const {
|
|
12
|
+
menuType
|
|
13
|
+
} = useStrictMenuContext();
|
|
12
14
|
return /*#__PURE__*/React.createElement(StyledMenuItem, {
|
|
13
15
|
inSubmenu: true
|
|
14
16
|
}, /*#__PURE__*/React.createElement(StyledDivider, _extends({
|
|
15
17
|
size: size
|
|
16
18
|
}, tagComponent("menu-divider", rest), {
|
|
17
|
-
menuType:
|
|
19
|
+
menuType: menuType,
|
|
18
20
|
ref: ref
|
|
19
21
|
})));
|
|
20
22
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuDividerProps } from "./menu-divider.component";
|
|
2
|
-
import { MenuType } from "../
|
|
2
|
+
import type { MenuType } from "../menu.types";
|
|
3
3
|
declare const StyledDivider: import("styled-components").StyledComponent<"div", any, MenuDividerProps & {
|
|
4
4
|
menuType: MenuType;
|
|
5
5
|
}, never>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useRef } from "react";
|
|
2
2
|
import { CSSTransition } from "react-transition-group";
|
|
3
3
|
import { StyledMenuFullscreen, StyledMenuModal, StyledMenuFullscreenHeader } from "./menu-full-screen.style";
|
|
4
4
|
import { StyledMenuWrapper } from "../menu.style";
|
|
5
|
-
import
|
|
5
|
+
import { useStrictMenuContext, StrictMenuProvider } from "../__internal__/strict-menu.context";
|
|
6
6
|
import Events from "../../../__internal__/utils/helpers/events";
|
|
7
7
|
import Box from "../../box";
|
|
8
8
|
import IconButton from "../../icon-button";
|
|
@@ -30,7 +30,7 @@ export const MenuFullscreen = ({
|
|
|
30
30
|
const isTopModal = useModalAria(modalRef);
|
|
31
31
|
const {
|
|
32
32
|
menuType
|
|
33
|
-
} =
|
|
33
|
+
} = useStrictMenuContext();
|
|
34
34
|
const isDarkVariant = ["dark", "black"].includes(menuType);
|
|
35
35
|
const transitionDuration = 200;
|
|
36
36
|
const locale = useLocale();
|
|
@@ -101,11 +101,10 @@ export const MenuFullscreen = ({
|
|
|
101
101
|
flexDirection: "column",
|
|
102
102
|
role: "list",
|
|
103
103
|
inFullscreenView: true
|
|
104
|
-
}, /*#__PURE__*/React.createElement(
|
|
104
|
+
}, /*#__PURE__*/React.createElement(StrictMenuProvider, {
|
|
105
105
|
value: {
|
|
106
106
|
inFullscreenView: true,
|
|
107
107
|
menuType,
|
|
108
|
-
inMenu: true,
|
|
109
108
|
openSubmenuId: null,
|
|
110
109
|
setOpenSubmenuId: /* istanbul ignore next */() => {}
|
|
111
110
|
}
|
|
@@ -5,7 +5,7 @@ import { defaultFocusableSelectors as focusableSelectors } from "../../../__inte
|
|
|
5
5
|
import { filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
6
6
|
import StyledMenuItemWrapper from "./menu-item.style";
|
|
7
7
|
import Events from "../../../__internal__/utils/helpers/events";
|
|
8
|
-
import
|
|
8
|
+
import { useStrictMenuContext } from "../__internal__/strict-menu.context";
|
|
9
9
|
import Submenu from "../__internal__/submenu/submenu.component";
|
|
10
10
|
import SubmenuContext from "../__internal__/submenu/submenu.context";
|
|
11
11
|
import MenuSegmentContext from "../menu-segment-title/menu-segment-title.context";
|
|
@@ -52,7 +52,7 @@ export const MenuItem = ({
|
|
|
52
52
|
focusId,
|
|
53
53
|
updateFocusId,
|
|
54
54
|
menuType
|
|
55
|
-
} =
|
|
55
|
+
} = useStrictMenuContext();
|
|
56
56
|
const submenuContext = useContext(SubmenuContext);
|
|
57
57
|
const isInSubmenu = Object.keys(submenuContext).length > 0;
|
|
58
58
|
const {
|
|
@@ -70,7 +70,7 @@ export const MenuItem = ({
|
|
|
70
70
|
if (firstFocusable !== firstFocusableChild) {
|
|
71
71
|
setFirstFocusableChild(firstFocusable);
|
|
72
72
|
}
|
|
73
|
-
}, [ref]);
|
|
73
|
+
}, [firstFocusableChild, ref]);
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
const id = menuItemId.current;
|
|
76
76
|
|
|
@@ -93,7 +93,7 @@ export const MenuItem = ({
|
|
|
93
93
|
}
|
|
94
94
|
ref?.focus();
|
|
95
95
|
}
|
|
96
|
-
}, [firstFocusableChild, focusFromMenu, focusFromSubmenu]);
|
|
96
|
+
}, [firstFocusableChild, focusFromMenu, focusFromSubmenu, ref]);
|
|
97
97
|
const handleFocus = event => {
|
|
98
98
|
if (isInSubmenu) {
|
|
99
99
|
event.stopPropagation();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PaddingProps } from "styled-system";
|
|
3
|
-
import { MenuType } from "../__internal__/menu.context";
|
|
4
3
|
import { MenuWithChildren } from "./menu-item.component";
|
|
4
|
+
import type { MenuType } from "../menu.types";
|
|
5
5
|
interface StyledMenuItemWrapperProps extends Pick<MenuWithChildren, "href" | "showDropdownArrow" | "overrideColor" | "clickToOpen" | "maxWidth">, PaddingProps {
|
|
6
6
|
menuType: MenuType;
|
|
7
7
|
selected?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useContext, useMemo } from "react";
|
|
3
3
|
import { StyledTitle, StyledSegmentChildren } from "./menu-segment-title.style";
|
|
4
|
-
import
|
|
4
|
+
import { useStrictMenuContext } from "../__internal__/strict-menu.context";
|
|
5
5
|
import { StyledMenuItem } from "../menu.style";
|
|
6
6
|
import tagComponent from "../../../__internal__/utils/helpers/tags";
|
|
7
7
|
import SubmenuContext from "../__internal__/submenu/submenu.context";
|
|
@@ -14,26 +14,29 @@ const MenuSegmentTitle = /*#__PURE__*/React.forwardRef(({
|
|
|
14
14
|
as = "h2",
|
|
15
15
|
...rest
|
|
16
16
|
}, ref) => {
|
|
17
|
-
const
|
|
17
|
+
const {
|
|
18
|
+
menuType,
|
|
19
|
+
inFullscreenView
|
|
20
|
+
} = useStrictMenuContext();
|
|
18
21
|
const {
|
|
19
22
|
submenuHasMaxWidth
|
|
20
23
|
} = useContext(SubmenuContext);
|
|
21
|
-
const isChildOfFullscreenMenu =
|
|
24
|
+
const isChildOfFullscreenMenu = !!inFullscreenView;
|
|
22
25
|
const overriddenVariant = useMemo(() => {
|
|
23
|
-
return isChildOfFullscreenMenu && variant === "alternate" && ["white", "black"].includes(
|
|
24
|
-
}, [isChildOfFullscreenMenu,
|
|
26
|
+
return isChildOfFullscreenMenu && variant === "alternate" && ["white", "black"].includes(menuType) ? "default" : variant;
|
|
27
|
+
}, [isChildOfFullscreenMenu, menuType, variant]);
|
|
25
28
|
return /*#__PURE__*/React.createElement(StyledMenuItem, {
|
|
26
29
|
inSubmenu: true
|
|
27
30
|
}, /*#__PURE__*/React.createElement(StyledTitle, _extends({
|
|
28
31
|
as: AS_VALUES.includes(as) ? as : /* istanbul ignore next */"h2"
|
|
29
32
|
}, tagComponent("menu-segment-title", rest), {
|
|
30
|
-
menuType:
|
|
33
|
+
menuType: menuType,
|
|
31
34
|
ref: ref,
|
|
32
35
|
variant: overriddenVariant,
|
|
33
36
|
shouldWrap: submenuHasMaxWidth
|
|
34
37
|
}), text), children && /*#__PURE__*/React.createElement(StyledSegmentChildren, {
|
|
35
38
|
"data-role": "menu-segment-children",
|
|
36
|
-
menuType:
|
|
39
|
+
menuType: menuType,
|
|
37
40
|
variant: overriddenVariant
|
|
38
41
|
}, /*#__PURE__*/React.createElement(MenuSegmentContext.Provider, {
|
|
39
42
|
value: {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
import { MenuType } from "./__internal__/menu.context";
|
|
5
|
-
export interface MenuProps extends TagProps, Pick<LayoutProps, "width" | "minWidth" | "maxWidth" | "overflow" | "overflowX" | "verticalAlign">, FlexboxProps {
|
|
6
|
-
/** Children elements */
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
/** Defines the color scheme of the component */
|
|
9
|
-
menuType?: MenuType;
|
|
10
|
-
}
|
|
2
|
+
import type { MenuProps } from "./menu.types";
|
|
11
3
|
export declare const Menu: ({ menuType, children, ...rest }: MenuProps) => React.JSX.Element;
|
|
12
4
|
export default Menu;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useCallback, useState, useRef } from "react";
|
|
3
|
-
import { StyledMenuWrapper } from "./menu.style";
|
|
4
3
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
|
-
import
|
|
4
|
+
import { StyledMenuWrapper } from "./menu.style";
|
|
5
|
+
import { StrictMenuProvider } from "./__internal__/strict-menu.context";
|
|
6
|
+
import MenuContext from "../menu/__internal__/menu.context";
|
|
6
7
|
import { menuKeyboardNavigation } from "./__internal__/keyboard-navigation";
|
|
7
8
|
import { MENU_ITEM_CHILDREN_LOCATOR } from "./__internal__/locators";
|
|
8
9
|
export const Menu = ({
|
|
@@ -46,10 +47,9 @@ export const Menu = ({
|
|
|
46
47
|
ref: ref,
|
|
47
48
|
role: "list",
|
|
48
49
|
onKeyDown: handleKeyDown
|
|
49
|
-
}), /*#__PURE__*/React.createElement(
|
|
50
|
+
}), /*#__PURE__*/React.createElement(StrictMenuProvider, {
|
|
50
51
|
value: {
|
|
51
52
|
menuType,
|
|
52
|
-
inMenu: true,
|
|
53
53
|
openSubmenuId,
|
|
54
54
|
setOpenSubmenuId,
|
|
55
55
|
focusId,
|
|
@@ -57,6 +57,10 @@ export const Menu = ({
|
|
|
57
57
|
registerItem,
|
|
58
58
|
unregisterItem
|
|
59
59
|
}
|
|
60
|
-
},
|
|
60
|
+
}, /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
61
|
+
value: {
|
|
62
|
+
inMenu: true
|
|
63
|
+
}
|
|
64
|
+
}, children)));
|
|
61
65
|
};
|
|
62
66
|
export default Menu;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlexboxProps, LayoutProps, PaddingProps } from "styled-system";
|
|
2
|
-
import { MenuProps } from "./menu.
|
|
2
|
+
import type { MenuProps } from "./menu.types";
|
|
3
3
|
interface StyledMenuProps extends Pick<MenuProps, "menuType">, FlexboxProps, LayoutProps {
|
|
4
4
|
inFullscreenView?: boolean;
|
|
5
5
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FlexboxProps, LayoutProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
+
export type MenuType = "light" | "dark" | "white" | "black";
|
|
5
|
+
export interface MenuProps extends TagProps, Pick<LayoutProps, "width" | "minWidth" | "maxWidth" | "overflow" | "overflowX" | "verticalAlign">, FlexboxProps {
|
|
6
|
+
/** Children elements */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Defines the color scheme of the component */
|
|
9
|
+
menuType?: MenuType;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React
|
|
3
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useStrictMenuContext } from "../__internal__/strict-menu.context";
|
|
4
4
|
import MenuItem from "../menu-item";
|
|
5
5
|
import StyledScrollableBlock from "./scrollable-block.style";
|
|
6
6
|
import Box from "../../box";
|
|
@@ -15,7 +15,7 @@ export const ScrollableBlock = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const {
|
|
17
17
|
menuType
|
|
18
|
-
} =
|
|
18
|
+
} = useStrictMenuContext();
|
|
19
19
|
const scrollVariants = {
|
|
20
20
|
light: "light",
|
|
21
21
|
dark: "dark",
|