Search the documentation

Type to search page titles, component names and descriptions.

    Develop

    The data-ui contract

    Hooks an application may rely on, and the checks that keep ownership clear.

    Every element a component renders carries a data-ui value. That value is public: tests, application behaviour and other tools may select it, and it does not change without a changelog entry. What is not public is the look of that element.

    import { HOOKS, OWNERS } from 'faifo-design/contract'
    
    HOOKS.includes('badge') // true: every hook, sorted
    Object.keys(OWNERS) // the owning component groups, each with the hooks it renders

    Each component page ends with the hooks its components render.

    #Hook ownership ratchet

    A data-ui hook listed in HOOKS (from faifo-design/contract) is the component's: its look is decided in the design system, never a second time in a host stylesheet. designSystemHookRestyles(css, HOOKS) reports every rule outside the design system whose subject is such a hook and that declares anything on it; custom properties (tokens the component reads) and rules whose subject is the application's own element ([data-ui="x"] .mine, .row:has([data-ui="x"])) are not counted.

    Existing restyles are frozen in a baseline, one sorted hook list per stylesheet, and hookRestyleRatchet + formatHookRatchet fail on both directions: a (file, hook) pair the baseline does not list, and a baseline entry the file no longer restyles. The baseline only shrinks. When the check fails on a new pair, change the component here (its styles, a variant or a prop) instead of adding the pair. A host helper whose markup carries a design-system hook (data-ui="stack", "inline", "code", "count-badge", the spinner of a loading action) renders the public component instead of markup of its own with the same name; two owners for one hook is what produces the restyle. A helper gap without a matching size maps to the nearest token (the backend kit's compact stack is tight). A change that adds the same pair to a stylesheet and to the baseline passes that check, so on a pull request to develop the design-system-layout workflow also runs hookBaselineGrowth + formatHookBaselineGrowth against the merge base with the target branch (HOOK_BASELINE_BASE_REF), and any entry the merge base's baseline does not list fails. Until the target branch has a baseline, the reference is the fixed copy at the commit that introduced it (BOOTSTRAP_COMMIT in both tests), never the baseline the change itself brings; a missing reference fails instead of passing. Merge that commit with a merge commit so it stays reachable.

    A hook is selected by any attribute form that matches it: [data-ui="x"], the i flag, ~=, |=, ^=, $=, *= and a bare [data-ui] (every hook). The conditions of one compound hold at once, so [data-ui][data-ui="app-widget"] selects only the application's app-widget. The arguments of :is(), :where() and the of list of :nth-child()/:nth-last-child() count through their own subject, so :is([data-ui="x"] .mine) styles .mine, not x. Rules inside @starting-style count like any other.

    In this workspace, test/design-system-hook-ratchet.test.ts scans every tracked stylesheet under packages/ against test/design-system-hook-baseline.json. Two packages are excluded by owner decision (26-11-2026): flow-ui and flow-client keep their own stylesheet for the open-core Flow kit. An application runs the same functions over its own stylesheets with its own baseline.

    Client compositions of createRelationSelectView can call getSelectedValues() to obtain an isolated array of selected opaque IDs, including IDs containing commas. Use this method for JSON commands instead of parsing the legacy native CSV value. Native form reset restores the configured initial selection, including forms inserted after mounting the picker. The disposable runtime removes its form listener.

    #Layout audit

    faifo-design-layout-audit reads stylesheets and reports three kinds of violation of the layout rules: owned-hook (restyling a design-system element, L8), hand-made-frame (a second boundary around content, L2) and revert-layer (L8).

    npx faifo-design-layout-audit --config design-system-layout.json
    npx faifo-design-layout-audit src/screens/orders.css

    It exits with 0 when clean, 1 on a violation or a configuration problem and 2 on a usage error. Adopt it area by area: list the stylesheets that already comply under enforce in the configuration, and grow that list as areas migrate. The audit does not prove that the right component was chosen, and it cannot see every indirect override.

    auditLayoutCss from faifo-design/contract is the same check as a function.