import { ViewType } from '@oinone/kunlun-meta'; import type { OioTreeNode } from '@oinone/kunlun-shared'; import { SPI } from '@oinone/kunlun-spi'; import { BaseElementWidget } from '../../basic'; import type { CardCascaderItemData } from '../../typing'; import { AbstractCardCascaderElementWidget } from './AbstractCardCascaderElementWidget'; @SPI.ClassFactory( BaseElementWidget.Token({ viewType: ViewType.Table, widget: ['card-cascader', 'cardCascader', 'CardCascader'] }) ) export class TableSearchCardCascaderWidget extends AbstractCardCascaderElementWidget { protected async onNodeSelected(node: OioTreeNode) { await this.onClickLoadData(node); } protected async onNodeUnselected(node: OioTreeNode) { await this.onUnselected(); } protected async onClearSearch() { await this.onUnselected(); } public async onClickLoadData(node: OioTreeNode) { const { rootNodes } = this; const childMetadata = node.value.metadata?.child; if (!rootNodes) { return; } if (childMetadata) { await this.fetchNodeData(node, childMetadata); } this.showContent = await this.onSelectedForSearch(node); } protected async refreshProcess() { await this.resetRootNode(); await this.onUnselected(); } }