0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Form-associated chat input with auto-growing textarea, Enter-to-send, and keyboard shortcuts.
Overview
A form-associated web component (static formAssociated = true) that wraps a textarea[data-grow] with send controls. Light DOM, participates in native form submission, validation, reset and <fieldset disabled> via ElementInternals. The textarea auto-resizes using VB's existing textarea-grow-init utility.
It has two send paths. Inside a <form>, sending submits the form. Standalone, it dispatches chat-input:send. <chat-window> uses the standalone path.
A placeholder is not a label. Give the textarea an accessible name with aria-label, aria-labelledby or a <label for>. If the textarea has none, chat-input adds aria-label="Message" as a fallback. The fallback is generic, so write a label that fits the context ("Reply to Sarah", "Ask the assistant").
The textarea drops its own border, so chat-input draws the focus ring while the textarea has focus. The ring uses the --focus-ring-* tokens and is inset so a clipping parent cannot hide it.
Inside a Form
As a form-associated element, chat-input takes part in native FormData, form submit, constraint validation and reset(). Inside a form, Enter and the [data-send] button submit the form. Enter calls requestSubmit(), so validation and the submit event run as they would for a button click. No chat-input:send event fires in this mode.
The input clears after the submit event, unless a listener calls preventDefault(). A prevented submit means the page handles the outcome, for example by sending with fetch(). Call form.reset() when it succeeds.
form.addEventListener('submit', async (e) => { e.preventDefault(); // keep the text until the send succeedsconst res = awaitfetch(form.action, { method: 'POST', body: newFormData(form) });if (res.ok) form.reset(); // clears chat-input via formResetCallback});
Disabled State
Set disabled to prevent input. This disables the textarea and the send button and reduces opacity. It works whether the attribute is in the markup, set later, or comes from an ancestor <fieldset disabled>.
Disabled chat input
12345678
<chat-inputname="message"disabled><textareadata-growrows="1"aria-label="Message"placeholder="Input is disabled..."></textarea><footer><buttontype="submit"class="small"data-sendaria-label="Send"><icon-wcname="send"></icon-wc></button></footer></chat-input>
Events
Event
Detail
When
chat-input:send
{ message }
Enter key or send button click when the input is not inside a form. message is trimmed. The input clears afterwards
chat-input:input
{ value, length }
Keystroke (debounced 100ms)
chat-input:change
{ value, source: 'api' }
The value property was set to a new value (no event when the value is unchanged)