/********************************************************************************** * Copyright (c) 2025 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the MIT License as outlined in the LICENSE file. **********************************************************************************/ import React from 'react'; import { classNames } from '../../../base'; import { CDTTreeItem, CDTTreeItemResource } from '../../common'; export interface RenderExpandIconProps { expanded: boolean; record: RecordType; expandable: boolean; onExpand: TriggerEventHandler; } export type TriggerEventHandler = (record: RecordType, event: React.MouseEvent) => void; export function ExpandIcon({ expanded, onExpand, record, expandable }: RenderExpandIconProps>): React.ReactElement { if (!expandable) { // simulate spacing to the left that we gain through expand icon so that leaf items look correctly intended return ; } const doExpand = (event: React.MouseEvent) => { event.stopPropagation(); onExpand(record, event); }; const iconClass = expanded ? 'codicon-chevron-down' : 'codicon-chevron-right'; return (
{ if (event.key === 'Enter' || event.key === ' ') doExpand(event as unknown as React.MouseEvent); }} >
); }