1
0

itemFoundation.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import BaseFoundation, { DefaultAdapter } from '../base/foundation';
  2. export interface BreadcrumbItemInfo {
  3. name?: any; // maybe reactNode, string, number
  4. href?: string;
  5. icon?: any;
  6. path?: string;
  7. }
  8. export interface Route {
  9. [x: string]: any;
  10. path?: string;
  11. href?: string;
  12. name?: string;
  13. icon?: any;
  14. }
  15. export interface BreadcrumbItemAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
  16. notifyClick: (item: BreadcrumbItemInfo, e: any) => void;
  17. notifyParent: (item: BreadcrumbItemInfo, e: any) => void;
  18. }
  19. export default class BreadcrumbItemFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<BreadcrumbItemAdapter<P, S>, P, S> {
  20. constructor(adapter: BreadcrumbItemAdapter<P, S>) {
  21. super({ ...adapter });
  22. }
  23. handleClick(item: BreadcrumbItemInfo, e: any) {
  24. // Trigger its own onClick first, then trigger the parent
  25. this._adapter.notifyClick(item, e);
  26. this._adapter.notifyParent(item, e);
  27. }
  28. }