Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Runtime

    How the kit's scripts load and what they share.

    Scripts live next to their primitives (src/primitives/<name>/<name>.ts) and share a small runtime in src/base/. They are written in TypeScript and emitted in place as readable .js ES modules, so a page can load them without a bundler: index.js imports every primitive's script.

    <script type="module" src="./zazz/index.js"></script>

    One bare specifier reaches the page through the import map buildHead() writes: signal-polyfill (the TC39 Signals polyfill). The single-file build dist/zazz.js keeps the same bare specifier, so the import map stays.

    Principles

    • HTML drives configuration. A script reads data-<primitive>-* attributes on its root (data-carousel-loop="true", data-command-hotkey="mod+k"); it never takes options from JavaScript.
    • Light DOM, progressive. Every scripted primitive is a light-DOM custom element that augments markup already styled by CSS. Without JavaScript the markup still renders and native elements still work; you lose only the enhancement (filtering, keyboard navigation, animation).
    • Scripts write state, not style. A script writes data-<primitive>-state on the elements it manages, data-theme on <html> (the head's theme script), and data-ui-stuck (the scroll-state polyfill); the toaster and multiselect also write data-ui on elements they create. Read state tokens in selectors; never author them.

    Modules

    ModuleExportsPage
    base/zazz-element.jsZazzElement, defineZazzElement, registerRefresh, refreshAllCustom elements
    base/signals.jsstate, computed, effect (also window.Signals)Signals
    base/utils.jsUtils.parseValue, Utils.parseDataAttributes (also window.Utils)Utils
    base/hotkeys.jsbindHotkey, parseHotkey, matchesHotkey, isEditableTarget, isBareKeyHotkeys
    base/dialog-lifecycle.jsdispatches zazz:dialog-open / zazz:dialog-closeEvents
    base/navigation.jsswapBody; side effects behind data-ui-navigation="swap"Navigation
    base/typeahead.js, base/command-score.jsthe filter-as-you-type engine behind autocomplete, combobox, and commandcommand
    base/carousel.jsCarousel (also window.Carousel): the scroll-snap carousel behind carousel and lightbox, with its engine in base/carousel-scroll.jscarousel
    base/reveal.jsReveal (also window.Reveal)reveal

    Each scripted primitive documents its own attributes and events under Behavior on its page.

    API