import { KbqSplitterModule } from '@koobiq/components/splitter';Splits an area into panels the user can resize by dragging the separators between them.
Panels must be direct children of the splitter — a wrapper element around them hides them from the group.
<kbq-splitter>
<kbq-splitter-panel [minSize]="100">…</kbq-splitter-panel>
<kbq-splitter-panel>…</kbq-splitter-panel>
</kbq-splitter>@Component({ selector: 'kbq-splitter', exportAs: 'kbqSplitter' })
class KbqSplitter implements KbqSplitterGroup {
readonly orientation = input<KbqSplitterOrientation>('horizontal');
readonly appearance = input<KbqSplitterAppearance>(
this.options.appearance
);
readonly disabled = input<boolean>(false);
readonly layout = model<number[] | null>(null);
}orientationKbqSplitterOrientation Direction the panels are laid out in.
appearanceKbqSplitterAppearance How the separators are drawn. Defaults to the app-wide KBQ_SPLITTER_OPTIONS.
disabledboolean Whether the panels can be resized at all.
layoutnumber[] | null Sizes of the panels as percentages of the splitter, in panel order.
Two-way and, while null, derived from what the panels declare — so a host reads it to persist a
layout, writes it to restore one, and shares the same signal between two splitters to keep their panels
the same width. Setting it back to null returns the panels to their declared sizes.
A resizable region of a KbqSplitter.
Every panel but the last renders the separator that follows it, so the separator sits between the two panels it resizes in the tab order as well as on screen.
@Component({ selector: 'kbq-splitter-panel', exportAs: 'kbqSplitterPanel' })
class KbqSplitterPanel implements KbqSplitterPanelRef {
readonly id = input<string>(
inject(_IdGenerator).getId('kbq-splitter-panel-')
);
readonly size = input<KbqSplitterSize | undefined>();
readonly minSize = input<KbqSplitterSize | undefined>();
readonly maxSize = input<KbqSplitterSize | undefined>();
readonly snapSizes = input<readonly KbqSplitterSize[]>([]);
readonly snapTolerance = input<number>(this.options.snapTolerance);
readonly collapsible = input<boolean>(false);
readonly collapsedSize = input<KbqSplitterSize>(0);
readonly collapsed = model<boolean>(false);
readonly separatorAriaLabel = input<string | undefined>();
}idstring Identifies the panel to the aria-controls of its own separator, and gives a host something to point
aria-labelledby or a fragment link at. Generated when omitted.
sizeKbqSplitterSize | undefined Size the panel starts at, in pixels (240, '240px'), as a share of the splitter ('30%') or as a share
of the viewport ('30vw', '30vh'). Panels that leave it unset share whatever the sized ones did not claim.
minSizeKbqSplitterSize | undefined Smallest size the panel may be dragged to. Defaults to 0.
maxSizeKbqSplitterSize | undefined Largest size the panel may be dragged to. Unbounded when omitted.
snapSizesreadonly KbqSplitterSize[] Sizes a drag is pulled onto when it is released near one. minSize and maxSize become snap points too
as soon as either panel around a separator declares any snap size.
The layout the panels start at settles onto them as well, so a splitter is never handed to the user sitting between two of its own snap points.
snapTolerancenumber How close to one of this panel's snapSizes a drag has to be released for it to be pulled in, in
pixels. Raise it to make the snap points reach further — past half the gap between two of them the panel
can only ever land on a snap size.
Defaults to the app-wide KBQ_SPLITTER_OPTIONS.
collapsibleboolean Whether dragging the panel past half of its minSize collapses it to collapsedSize instead of
stopping at the minimum.
collapsedSizeKbqSplitterSize Size the panel takes while collapsed. 0 — the default — hides it completely.
collapsedboolean Whether the panel is collapsed. Two-way, so a host can collapse and restore the panel itself — which is
the only way back for a panel whose collapsedSize is 0 and which therefore has no separator to grab.
separatorAriaLabelstring | undefined Accessible name of the separator that follows the panel; falls back to the localized default.
Overrides the default splitter options within the given injector scope — the whole application from
bootstrapApplication, or one subtree from the providers of a component or a route.
function kbqSplitterOptionsProvider(
options: Partial<KbqSplitterOptions>
): Provider;Moves the boundary that follows index by delta pixels and returns the new sizes.
The panels on one side of the boundary take the delta and the ones on the other side give it up, each walking outwards from the boundary: a panel sitting at its limit hands the remainder to the next one instead of stopping the drag. Walking outwards on the taking side too is what keeps a boundary reachable when the panel right beside it is pinned — otherwise a neighbour at its maximum would freeze a boundary that the panels further out could still move, and the drag would do nothing at all.
function resizeSplitterSizesAt(
sizes: readonly number[],
index: number,
delta: number,
min: readonly number[],
max: readonly number[]
): number[];How a splitter draws its separators.
divider — a line between the panels, the default.transparent — nothing until the pointer reaches the separator, which then gives itself away by the cursor.handle — a grip centred on the boundary.type KbqSplitterAppearance = 'divider' | 'transparent' | 'handle';Settings a whole application shares, rather than something a single splitter decides.
Only what a product picks once belongs here: how its separators look, and how far a snap size reaches. The sizes and limits of the panels are a property of one layout and stay on the panels themselves.
type KbqSplitterOptions = {
appearance: KbqSplitterAppearance;
snapTolerance: number;
};appearanceKbqSplitterAppearance How the separators are drawn.
snapTolerancenumber How close to a snap size a drag has to be released for it to be pulled in, in pixels.
Direction the panels of a splitter are laid out in.
type KbqSplitterOrientation = 'horizontal' | 'vertical';Size of a splitter panel: a number of pixels, a <number>px string, a <number>% share of the splitter's own
size along the resize axis, or a <number>vw / <number>vh share of the viewport's width / height. A size in
any other unit is ignored.
type KbqSplitterSize = number | string;A size a drag is pulled onto, with the distance the release has to be within for the pull to happen.
type KbqSplitterSnapPoint = {
size: number;
tolerance: number;
};Injection token holding the current KbqSplitterOptions.
const KBQ_SPLITTER_OPTIONS: InjectionToken<KbqSplitterOptions>;