/* argus-disable unPkgSensitiveInfo */ import BaseFoundation, { DefaultAdapter } from '../base/foundation'; export interface ItemProps { text?: any; itemKey?: any; icon?: any; toggleIcon?: string; indent?: boolean | number; isCollapsed?: boolean; isSubNav?: boolean; link?: string; linkOptions?: Record; disabled?: boolean; children?: any; } export interface SelectedItemProps { itemKey: string | number; text?: any; selectedKeys?: string | number[]; selectedItems?: Props[]; domEvent?: any; } export interface ItemAdapter

, S = Record> extends DefaultAdapter { cloneDeep(value: any, customizer?: (value: any) => void): any; updateTooltipShow(showTooltip: boolean): void; updateSelected(selected: boolean): void; updateGlobalSelectedKeys(keys: string[]): void; getSelectedKeys(): string[]; getSelectedKeysIsControlled(): boolean; notifyGlobalOnSelect(item: SelectedItemProps): void; notifyGlobalOnClick(item: SelectedItemProps): void; notifyClick(item: SelectedItemProps): void; notifyMouseEnter(e: any): void; notifyMouseLeave(e: any): void; getIsCollapsed(): boolean; getSelected(): boolean; } export default class ItemFoundation

, S = Record> extends BaseFoundation, P, S> { _timer: number; _mounted: boolean; constructor(adapter: ItemAdapter) { super({ ...adapter }); } init() { this._timer = null; this._mounted = true; } destroy() { this._mounted = false; } isValidKey(itemKey: string) { // eslint-disable-next-line eqeqeq return itemKey != null && (typeof itemKey === 'string' || typeof itemKey === 'number'); } handleClick(e: any) { const { isSubNav, itemKey, text, disabled } = this.getProps(); if (disabled) { return; } if ( !isSubNav && this.isValidKey(itemKey) && !this._adapter.getSelectedKeysIsControlled() && !this._adapter.getSelected() ) { this._adapter.updateSelected(true); } const selectedKeys = [itemKey]; // If the current item is subNav, there is no need to trigger the global onSelect/onClick event, instead, the SubNav component will trigger the click event if (!isSubNav) { if (!this._adapter.getSelected()) { // internal-issues:51 const selectedItems = [this._adapter.cloneDeep(this.getProps())]; this._adapter.notifyGlobalOnSelect({ itemKey, selectedKeys, selectedItems, domEvent: e }); } this._adapter.notifyGlobalOnClick({ itemKey, text, domEvent: e }); } this._adapter.notifyClick({ itemKey, text, domEvent: e }); } }