|
| 1 | +import { TemplateRef } from '@angular/core'; |
| 2 | + |
| 3 | +/* 基础数据类型 */ |
| 4 | +type AccordionMenuItemLinkType = 'routerLink' | 'hrefLink' | string; |
| 5 | +export interface AccordionBase { |
| 6 | + title: string; |
| 7 | + disabled?: boolean; |
| 8 | + [prop: string]: any; |
| 9 | +} |
| 10 | +interface IAccordionActiveable { |
| 11 | + active?: boolean; |
| 12 | +} |
| 13 | +interface IAccordionFoldable<T> { |
| 14 | + open?: boolean; |
| 15 | + loading?: boolean; |
| 16 | + children?: Array<T>; |
| 17 | +} |
| 18 | + |
| 19 | +interface IAccordionLinkable { |
| 20 | + link?: string; |
| 21 | + target?: boolean; |
| 22 | + linkType?: AccordionMenuItemLinkType; |
| 23 | +} |
| 24 | +export interface AccordionBaseItem |
| 25 | + extends AccordionBase, |
| 26 | + IAccordionActiveable { |
| 27 | +} |
| 28 | +export interface AccordionBaseMenu<T> |
| 29 | + extends AccordionBase, |
| 30 | + IAccordionFoldable<T> { |
| 31 | +} |
| 32 | + |
| 33 | +export interface AccordionLinkableItem |
| 34 | + extends AccordionBase, |
| 35 | + IAccordionActiveable, |
| 36 | + IAccordionLinkable { |
| 37 | +} |
| 38 | +export interface AccordionMenuItem |
| 39 | + extends AccordionBase, |
| 40 | + IAccordionActiveable, |
| 41 | + IAccordionFoldable<AccordionMenuItem>, |
| 42 | + IAccordionLinkable { |
| 43 | +} |
| 44 | + |
| 45 | +export type AccordionMenuType = Array<AccordionMenuItem>; |
| 46 | + |
| 47 | +/* 基础事件类型 */ |
| 48 | +export interface AccordionMenuToggleEvent { |
| 49 | + item: any; |
| 50 | + open: boolean; |
| 51 | + parent: any; |
| 52 | + event: MouseEvent; |
| 53 | +} |
| 54 | +export interface AccordionItemClickEvent { |
| 55 | + item: any; |
| 56 | + prevActiveItem?: any; |
| 57 | + parent: any; |
| 58 | + event: MouseEvent; |
| 59 | +} |
| 60 | + |
| 61 | +/* 通用公共配置数据类型 */ |
| 62 | +interface AccordionMenuKeyGroup { |
| 63 | + titleKey?: string; |
| 64 | + activeKey?: string; |
| 65 | + disabledKey?: string; |
| 66 | + openKey?: string; |
| 67 | + loadingKey?: string; |
| 68 | + childrenKey?: string; |
| 69 | + linkKey?: string; |
| 70 | + linkTargetKey?: string; |
| 71 | + linkTypeKey?: string; |
| 72 | +} |
| 73 | + |
| 74 | +type AccordionTemplateRefArray = 'itemTemplate' | 'menuItemTemplate' | 'noContentTemplate' | 'loadingTemplate' | 'innerListTemplate'; |
| 75 | +type AccordionTemplateRefGroup = { |
| 76 | + [p in AccordionTemplateRefArray]: TemplateRef<any> |
| 77 | +}; |
| 78 | +interface AccordionConfigOptions { |
| 79 | + restrictOneOpen?: boolean; |
| 80 | + autoOpenActiveMenu?: boolean; |
| 81 | + showNoContent?: boolean; |
| 82 | + linkDefaultTarget?: string; |
| 83 | + i18nCommonText?: any; |
| 84 | + i18nText?: any; |
| 85 | + linkType: 'routerLink' | 'hrefLink' | 'dependOnLinkTypeKey' | '' | string; |
| 86 | +} |
| 87 | +export interface AccordionOptions |
| 88 | + extends AccordionConfigOptions, |
| 89 | + AccordionMenuKeyGroup, |
| 90 | + AccordionTemplateRefGroup { |
| 91 | +} |
| 92 | + |
| 93 | +/* 废弃接口 */ |
| 94 | +/** @deprecated merge into `AccordionMenuItem`*/ |
| 95 | +export interface AccordionSubMenuItem { |
| 96 | + title: string; |
| 97 | + active?: boolean; |
| 98 | + disabled?: boolean; |
| 99 | + [prop: string]: any; |
| 100 | +} |
| 101 | +/** @deprecated use `AccordionLinkableItem` instead*/ |
| 102 | +export interface AccordionSubMenuItemHrefLink { |
| 103 | + title: string; |
| 104 | + link: string; |
| 105 | + target?: string; |
| 106 | + active?: boolean; |
| 107 | + disabled?: boolean; |
| 108 | + [prop: string]: any; |
| 109 | +} |
| 110 | +/** @deprecated use `AccordionLinkableItem` instead*/ |
| 111 | +export interface AccordionSubMenuItemRouterLink { |
| 112 | + title: string; |
| 113 | + link: string; |
| 114 | + target?: string; |
| 115 | + active?: boolean; |
| 116 | + disabled?: boolean; |
| 117 | + [prop: string]: any; |
| 118 | +} |
| 119 | +/** @deprecated use `AccordionLinkableItem` instead*/ |
| 120 | +export interface AccordionSubMenuItemDynamicLink { |
| 121 | + title: string; |
| 122 | + link: string; |
| 123 | + linkType: 'routerLink' | 'hrefLink' | string; |
| 124 | + target?: string; |
| 125 | + active?: boolean; |
| 126 | + disabled?: boolean; |
| 127 | + [prop: string]: any; |
| 128 | +} |
0 commit comments