Skip to content

Commit

Permalink
Fix type issues following rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies committed Sep 15, 2021
1 parent ffaf716 commit 2052c1b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/components/src/menu-item/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ export type Props = {
* Handler for click events.
*/
onClick?: () => void;
/**
* Flag to indicate if the menu item is disabled.
*/
disabled?: boolean;
};
5 changes: 2 additions & 3 deletions packages/components/src/tools-panel/tools-panel/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ]: {
Expand All @@ -94,7 +94,6 @@ export function useToolsPanel(
filters.push( item.resetAllFilter );
}
} );

return filters;
};

Expand Down
27 changes: 20 additions & 7 deletions packages/components/src/tools-panel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 2052c1b

Please sign in to comment.