Skip to main content
cngx-src documentation

resolveStepFrom

Functioncore/navv0.1.0

projects/core/nav/step-resolver.ts

Description#

Resolve the next enabled index from current in direction, skipping disabled indices, wrapping under loop, or null when no enabled index is reachable. The shared kernel of every next/prev-with-disabled-skip iterator (active-descendant, roving tabindex, stepper strip, chip-strip roving) - previously four private copies.

Arithmetic contract (ported exactly from the active-descendant strategy, the strictest of the four sites):

  • A negative current enters from the approach edge: -1 when stepping forward (first probe is index 0), count when stepping backward (first probe is count - 1).
  • current >= count is NOT remapped - every probe is bounds-checked, so the first out-of-range probe resolves to null without loop and wraps via modulo with it.
  • At most count probes run; a fully disabled range resolves to null.

Callers with clamp semantics (stop at the boundary, keep the current index) compose the resolver as resolveStepFrom(...) ?? current.

Like resolveInlineStep, this is a pure function, not a DI chokepoint - each strategy owns its isDisabledAt adapter and calls it directly. The direction axis (RTL arrow flip) stays in resolveInlineStep; this kernel owns only the index axis.

Signature#

resolveStepFrom(current: number, direction, scan: CngxStepScan)

Parameters#

@paramcurrentnumber

The index to step from.

@paramdirection

1 steps forward, -1 backward.

@paramscanCngxStepScan

The range description.

Returns#

number | null

The next enabled index, or null when none is reachable.