2025-12-16 16:15:34 +01:00
|
|
|
import {
|
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
|
Component,
|
|
|
|
|
TemplateRef,
|
|
|
|
|
input,
|
|
|
|
|
output,
|
|
|
|
|
viewChild,
|
|
|
|
|
} from "@angular/core";
|
2023-04-13 20:48:29 +02:00
|
|
|
import { QueryParamsHandling } from "@angular/router";
|
2023-01-09 18:59:19 +01:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* Individual breadcrumb item used within the `bit-breadcrumbs` component.
|
|
|
|
|
* Represents a single navigation step in the breadcrumb trail.
|
|
|
|
|
*
|
|
|
|
|
* This component should be used as a child of `bit-breadcrumbs` and supports both
|
|
|
|
|
* router navigation and custom click handlers.
|
|
|
|
|
*/
|
2023-01-09 18:59:19 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: "bit-breadcrumb",
|
|
|
|
|
templateUrl: "./breadcrumb.component.html",
|
2025-12-16 16:15:34 +01:00
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
2023-01-09 18:59:19 +01:00
|
|
|
})
|
|
|
|
|
export class BreadcrumbComponent {
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* Optional icon to display before the breadcrumb text.
|
|
|
|
|
*/
|
2025-07-16 08:39:37 -04:00
|
|
|
readonly icon = input<string>();
|
2023-01-09 18:59:19 +01:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* Router link for the breadcrumb. Can be a string or an array of route segments.
|
|
|
|
|
*/
|
2025-07-16 08:39:37 -04:00
|
|
|
readonly route = input<string | any[]>();
|
2023-01-09 18:59:19 +01:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* Query parameters to include in the router link.
|
|
|
|
|
*/
|
2025-07-16 08:39:37 -04:00
|
|
|
readonly queryParams = input<Record<string, string>>({});
|
2023-01-09 18:59:19 +01:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* How to handle query parameters when navigating. Options include 'merge' or 'preserve'.
|
|
|
|
|
*/
|
2025-07-16 08:39:37 -04:00
|
|
|
readonly queryParamsHandling = input<QueryParamsHandling>();
|
2023-04-13 20:48:29 +02:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/**
|
|
|
|
|
* Emitted when the breadcrumb is clicked.
|
|
|
|
|
*/
|
|
|
|
|
readonly click = output<unknown>();
|
2023-01-09 18:59:19 +01:00
|
|
|
|
2025-12-16 16:15:34 +01:00
|
|
|
/** Used by the BreadcrumbsComponent to access the breadcrumb content */
|
2025-08-18 15:36:45 -04:00
|
|
|
readonly content = viewChild(TemplateRef);
|
2023-01-09 18:59:19 +01:00
|
|
|
|
|
|
|
|
onClick(args: unknown) {
|
2025-12-16 16:15:34 +01:00
|
|
|
this.click.emit(args);
|
2023-01-09 18:59:19 +01:00
|
|
|
}
|
|
|
|
|
}
|