/** * Slots system for component children. * Supports default and named slots with reactivity. */ /** * Invoke a slot fill and normalise its result to an array — the ONE place a * fill is ever called. The client accessor, the function-children path and the * server's own slot object all route through here, so the two renderers cannot * drift on what a fill receives or on what its result becomes. * * A fill invoked with no scoped props gets `{}`, never `undefined`. A scoped * fill is written as a destructure — `({ active }) => …` — and destructuring * `undefined` throws, so the two idioms `({ active }) => …` and * `slots.default?.()` would otherwise combine into a hard crash. With an empty * object each declared prop reads as `undefined` instead, which is what a prop * the parent didn't pass does everywhere else. The object is allocated per * invocation rather than shared: a fill is handed it, and one that writes to * its props must not be writing into another component's. * * The result is normalised the same way for every provision form: * `null`/`undefined` becomes empty, an array passes through, any other value is * wrapped. The server previously installed a `slots`-prop fill raw and skipped * this, so a fill returning a single vnode handed the component `[vnode]` on * the client and `vnode` on the server. */ export declare function invokeSlotFn(fn: (scopedProps: any) => any, scopedProps?: any, name?: string): any[]; /** * Map a slot's extracted children, invoking any *function* items with the * scoped props (render-prop semantics) and passing element children through * untouched. A function child — `{(p) => …}` — is thereby called * with the same `scopedProps` the `slots` prop form receives, instead of * reaching the renderer as a bare function and being dropped as an empty node. * * Returns a fresh array, preserving the accessor's defensive-copy contract. * Each function goes through `invokeSlotFn`, so its result is normalised exactly * as the `slots` prop form's is: `null`/`undefined` contributes nothing and an * array is flattened one level. * * Only call this for a list that actually CONTAINS a function — a hand loop is * roughly 2x `list.slice()` at a handful of children and ~6.5x at a hundred, so * the callers gate on a flag recorded while the children were collected rather * than paying the scan on every slot read. * * Single pass: element children are copied into a fresh array (by sequential * index, which stays dense) as they are scanned; only once the first function * is found does it truncate to the copied prefix and switch to append-mode for * the rest. */ export declare function invokeFunctionChildren(list: any[], scopedProps?: any, name?: string): any[]; /** * The named slot a child routes to, or `null` when it belongs to the default * slot — the ONE definition of the routing predicate. The client extractor and * the server renderer's mirror both call it, so the two sides cannot drift on * which children are routable (they must agree, or hydration mismatches). * * Only host children route: `slot` is the HTML attribute, and routing follows * it. A COMPONENT child never routes — `slot` on a component is an ordinary * (undeclared) prop, and the typed way to fill a named slot with a component * is the `slots` prop, which is checked against the consumer's declared * slots. Until #588 the predicate matched ANY object vnode carrying * `props.slot`, so a cast could route a component child; that was accidental * (the check predates the distinction, from the initial commit) and * untypeable, so it is ignored rather than blessed. The component test is * `typeof type === 'function'` — a `component()` factory or a plain function * component; host elements are strings and `Fragment` is a symbol, so * neither matches. */ export declare function namedSlotFor(child: any): string | null; /** * Internal slots object with tracking properties. * * A slot accessor is present (a callable) only when content was provided for * that slot — including `default`; an unprovided slot reads as `undefined`. */ export interface InternalSlotsObject { default?: (scopedProps?: any) => any[]; _children: any; _version: { v: number; }; _slotsFromProps: Record; _isPatching?: boolean; [key: string]: any; } /** * Create slots object from children and slots prop. * Uses a version signal to trigger re-renders when children change. * * A slot reads as a callable accessor **only when content was provided** for * it; an unprovided slot — `default` included — reads as `undefined`. So * presence is a plain truthiness/optional-call check (`slots.header?.()`, * `slots.header?.() ?? fallback`), and presence stays reactive: the accessor * lookup reads the version signal, so a slot appearing or disappearing * re-renders the consumer. * * Supports named slots via: * - `slots` prop object (e.g., `slots={{ header: () =>
...
}}`) — * the typed form, checked against the consumer's declared slots, and the * only way to fill a named slot with a component * - `slot` prop on HOST-ELEMENT children (e.g., `
...
`, * mirroring the HTML attribute); on a component child `slot` is an ordinary * prop and does not route (see {@link namedSlotFor}, #588) * * A **function child** is a render-prop fill: it is invoked with the scoped * props the consumer passed to the accessor, and its result takes its place. * Function and element children may be mixed freely in one default slot — * every function is invoked with the same scoped props and element children * pass through, in source order — so a slot is not all-or-nothing about the * form its content takes. A function only ever fills the DEFAULT slot: routing * a child to a named slot requires a `slot` prop on it, and a function is not * an object, so it can never be routed there. * * @example * ```tsx * // Parent component *

Title

}}> *

Default content

* Footer text *
* * // Card component setup * const slots = createSlots(children, slotsFromProps); * return () => ( *
* {slots.header?.() ??

Fallback heading

} * {slots.default?.()} * {slots.footer?.()} *
* ); * ``` */ export declare function createSlots(children: any, slotsFromProps?: Record): InternalSlotsObject; //# sourceMappingURL=slots.d.ts.map