From 2052c1b45cd6bedcd478b26da531b28f6011c775 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Wed, 15 Sep 2021 16:52:55 +1200 Subject: [PATCH] Fix type issues following rebase --- packages/components/src/menu-item/types.ts | 4 +++ .../src/tools-panel/tools-panel/hook.ts | 5 ++-- packages/components/src/tools-panel/types.ts | 27 ++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/components/src/menu-item/types.ts b/packages/components/src/menu-item/types.ts index 16ee90524dad52..7c98489d348833 100644 --- a/packages/components/src/menu-item/types.ts +++ b/packages/components/src/menu-item/types.ts @@ -35,4 +35,8 @@ export type Props = { * Handler for click events. */ onClick?: () => void; + /** + * Flag to indicate if the menu item is disabled. + */ + disabled?: boolean; }; diff --git a/packages/components/src/tools-panel/tools-panel/hook.ts b/packages/components/src/tools-panel/tools-panel/hook.ts index b4f62f3f129b73..ddf15a44bc1402 100644 --- a/packages/components/src/tools-panel/tools-panel/hook.ts +++ b/packages/components/src/tools-panel/tools-panel/hook.ts @@ -57,7 +57,7 @@ export function useToolsPanel( // Panels need to deregister on unmount to avoid orphans in menu state. // This is an issue when panel items are being injected via SlotFills. - const deregisterPanelItem = ( label ) => { + const deregisterPanelItem = ( label: string ) => { // When switching selections between components injecting matching // controls, e.g. both panels have a "padding" control, the // deregistration of the first panel doesn't occur until after the @@ -73,7 +73,7 @@ export function useToolsPanel( // This is intended for use with default panel items. They are displayed // separately to optional items and have different display states, //.we need to update that when their value is customized. - const flagItemCustomization = ( label, group = 'default' ) => { + const flagItemCustomization = ( label: string, group = 'default' ) => { setMenuItems( { ...menuItems, [ group ]: { @@ -94,7 +94,6 @@ export function useToolsPanel( filters.push( item.resetAllFilter ); } } ); - return filters; }; diff --git a/packages/components/src/tools-panel/types.ts b/packages/components/src/tools-panel/types.ts index 67a2d0133bca62..45a9a19e66e081 100644 --- a/packages/components/src/tools-panel/types.ts +++ b/packages/components/src/tools-panel/types.ts @@ -4,36 +4,49 @@ // eslint-disable-next-line no-restricted-imports import type { ReactNode } from 'react'; +type ResetAll = ( filters?: any[] ) => void; +type PanelId = string; +type ResetAllFilter = () => void; +type Label = string; + export interface ToolsPanelProps { - label: string; + panelId: PanelId; + label: Label; header: string; children: ReactNode; - resetAll: () => void; + resetAll: ResetAll; className?: string; } export interface ToolsPanelHeaderProps { - menuLabel: string; - header: string; - resetAll: () => void; + label: Label; + resetAll: ResetAll; toggleItem: ( label: string ) => void; - className?: string; } export interface ToolsPanelItem { hasValue: () => boolean; isShownByDefault: boolean; - label: string; + label: Label; + resetAllFilter: ResetAllFilter; + panelId: PanelId; } export interface ToolsPanelItemProps extends ToolsPanelItem { + panelId: PanelId; children?: ReactNode; onDeselect?: () => void; onSelect?: () => void; className?: string; + resetAllFilter: ResetAllFilter; } export interface TPContext { + panelId?: PanelId; menuItems?: { [ key: string ]: boolean }; + hasMenuItems?: number; registerPanelItem?: ( item: ToolsPanelItem ) => void; + deregisterPanelItem?: ( label: Label ) => void; + flagItemCustomization?: ( label: Label ) => void; + isResetting?: boolean; }