Files
HMDesign/packages/org-chart/src/components.ts
T

25 lines
1.3 KiB
TypeScript

import { createOrgChartView } from './core/index.js';
import type { OrgChartHandle, OrgChartOptions } from './core/types.js';
/** Standalone summaries share the same source, validation, update/reload and
* dispose contract as OrgChart. Only the independent core CSS is required. */
export interface OrgChartSummaryComponentOptions extends Pick<OrgChartOptions, 'container' | 'dataSource' | 'aggregationPolicy' | 'onStateChange'> {
stylesheetUrl: string;
}
function summaryOptions(options: OrgChartSummaryComponentOptions): OrgChartOptions {
return { ...options, stylesheetUrls: { core: options.stylesheetUrl, engine: '' } };
}
export function createPositionSummary(options: OrgChartSummaryComponentOptions): OrgChartHandle {
return createOrgChartView(summaryOptions(options), 'positionSummary');
}
export function createAffiliationSummary(options: OrgChartSummaryComponentOptions): OrgChartHandle {
return createOrgChartView(summaryOptions(options), 'affiliationSummary');
}
export function createStatusSummary(options: OrgChartSummaryComponentOptions): OrgChartHandle {
return createOrgChartView(summaryOptions(options), 'statusSummary');
}
/** Tree-only component: no title, leader composition, hub or summary modules. */
export function createOrgChartTree(options: OrgChartOptions): OrgChartHandle {
return createOrgChartView(options, 'tree');
}