Wardic instances

A Wardic instance is a w made for a fixed list of Features. Its elements bring those Features wherever they render, and take their props alone: a prop of a Feature the list lacks is a type error that names the Feature.

// src/lib/wardic.ts
import { domAnimation, layout } from "@wardic/solid"
import { elements, makeWard } from "@wardic/solid/hooks"

export const { w } = makeWard({ features: [domAnimation, layout], elements })

<w.li layout whileHover={{ scale: 1.05 }} />

With that instance, <w.li drag /> fails to compile: Type 'boolean' is not assignable to type 'NeedsFeature<"drag">'.

Making one

On Solid 2, makeWard({ features, elements }) makes one, beside the hooks that bring the same Features. On Solid 1, createWardic(features) does. Call it once, in a module of its own, and import its w where you'd import the binding's.

It takesWhat happens
A Feature, a preset or a list of them, nestedEach is given at once: built in a provider the first time one of the instance's elements needs it.
A load, () => import("./drag-feature").then((m) => m.drag)It starts on the client the first time one of the instance's elements or wards is made, or one of its hooks is called, once whichever provider asks; if it fails, the next provider to ask loads it again. Its Features take effect as they arrive; nothing before is replayed. A server render loads nothing.

The instance's elements also have the Features their WardicProvider and, on Solid 1, any LazyWardic above them give, and render under a strict one. The module that makes an instance ships the Features it's given at once to every page that imports it, so a page that drags can have an instance of its own.

// src/lib/wardic-room.ts: hover at once, drag when the room first renders
export const { w } = makeWard({ features: [domAnimation, () => import("./drag-feature").then((m) => m.drag)], elements })
// Solid 1: createWardic([domAnimation, () => import("./drag-feature").then((m) => m.drag)])

WardicInstance

WardicInstance<F> is an instance of Features F: what Solid 1's createWardic(features) returns, and on Solid 2 what makeWard returns beside its hooks. A preset counts as its Features, a nested list as its own, and a load (() => import(…)) as what it resolves to.

MemberWhat it is
wEvery form of w, typed to F: w.<tag>, w.create, and w.ward on Solid 2 or w.createWard on Solid 1. Solid 1's use:w takes every prop: Solid types a directive by its name, whatever instance it comes from.
useAnimateLayout, createInstantLayoutTransition, createResetProjectionOnly when F has layout, given at once or loaded: the layout hooks, typed as the ones the binding exports.

On Solid 2, a ward from the instance's w.ward(), or the one its element hands to wardRef, is a Ward<C, F>: it hears settled and its Features' events alone. On an instance without drag, card.next("dragEnd") is a type error that names drag.

WardConfigOf

WardConfigOf<F> is the motion props of an instance with Features F: the base props and its Features'. A component that hands its motion props on takes them, and can pass them to the instance's elements or to any with more Features, a plain w.* included.

const Card = (props: WardConfigOf<typeof domAnimation> & { title: string }) => <w.article {...props}>{props.title}</w.article>

A prop of another Feature isn't one of them, so <Card drag /> is a type error, though not one that names drag. With every Feature, WardConfigOf<typeof domMax> is the whole of the motion props.