z-idx
z-index DAG builder converting declarative stacking rules into stable numeric layers for shared UI libraries.
Install
npm i z-idx
Usage
import { index } from 'z-idx'
const base = index((z) => z('overlay', 'modal', 'tooltip'))
// base.overlay = 1024, base.modal = 2048, base.tooltip = 3072
// Extend without breaking existing values
const next = base((z) => z('modal', 'dialog', 'tooltip'))
// base.overlay === next.overlay (stable)
Features
Declare ordering relationships instead of assigning magic numbers. z-idx uses Kahn's topological sort over a directed acyclic graph to compute stable numeric ranks with consistent spacing. Extensions preserve all previously seeded values while inserting new nodes between existing ones. Full TypeScript type inference surfaces every key as autocomplete in your editor. Zero dependencies.
Links
GitHub · npm ·
@tseijp
Enable JavaScript for interactive documentation with live code examples and DAG visualizations.