Mixins / foldkit-mixins

Slots: the public contract

A slot is metadata, not a DOM node:

ts
Slot.make({
  capability: Capability.TextInput,
  events: [Event.Input],
  attributes: [Attr.AriaInvalid],
  hidden: false,
  protected: { events: [Event.Click], attributes: [Attr.Role], style: ['position'] },
})
  • Capability describes structural compatibility. The built-in hierarchy is Base → Interactive → { Container, Focusable → TextInput, Draggable }, plus Base → Collection. A behavior that requires Interactive may attach to a TextInput. Extend it with Capability.make(name, { extends }).
  • Event and Attr are branded metadata tokens. Event.make and Attr.make add custom ones; declaring them does not install handlers.
  • Requirement tokens name platform needs such as Keyboard, Pointer and Clipboard for tooling to inspect.
  • hidden reserves an internal extension point: public Style and Behavior specs do not even offer that key.
  • protected keeps structural events, attributes or style properties from being replaced by an attachment.

Names come from the keys passed to Slots.define; they are never repeated inside each slot.