linewisp

Facet Fields / developer preview

Fields that carry
their own weight.

Facet Fields are original, form-associated Web Components for the input details that make an application feel dependable: labels, messages, constraints, validation, and safe state changes.

Preview statusFacet Fields can be evaluated in the browser today. The current package namespace is @linewisp/wisp-fields; it is not published to npm yet.

Getting started

Register the element, place it inside a form, and configure it in JavaScript. Values, labels, options, help text, and errors are set through safe DOM APIs rather than generated HTML.

import { defineWispField } from '@linewisp/wisp-fields';

defineWispField();
document.querySelector('wisp-field').configure({
  name: 'project-name',
  label: 'Project name',
  type: 'text',
  required: true,
  minLength: 3,
  helpText: 'Use a name your team will recognise.',
});

The essentials

Field types

Use ordinary platform semantics first. Each type retains its native browser input behavior and can take the shared theme and density settings.

Text entrytext, email, number, password, tel, url, and textarea.
Choiceselect with safe text-only option labels, and checkbox with form-aware checked state.
Hintsplaceholder, helpText, autoComplete, inputMode, read-only, disabled, and required behavior.

Configuration API

OptionTypePurpose
name, label, typerequiredDefines the form name, visible label, and supported native-field type.
value, checkedstring, booleanSets the initial state. Checkbox values are included only while checked.
optionsarrayRequired for select; labels are always rendered as text.
required, min, max, minLength, maxLength, patternconstraintsUses clear built-in error messages before custom validation runs.
validatefunctionReturns an error string or null for synchronous application rules.
validateAsyncasync functionReceives a cancellation signal. Stale results are ignored.
theme, densityshared valuesAligns the field with the rest of the Facet interface.

Validation lifecycle

Built-in constraints run on change and blur. Call validate() on form submission, or use validateAsync() for a host-provided check. Starting a new validation or changing a value cancels any older async request, so late responses cannot overwrite the latest result.

Use setValue(value) and setChecked(checked) for programmatic changes. Both preserve form-associated state. Read valid when you need the current constraint result without displaying a new error.

Methods and events

Methods and state

  • value, checked, and valid
  • setValue(value, validate?)
  • setChecked(checked, validate?)
  • validate() and validateAsync()
  • reset() and focus()

Events

  • wisp-field-input on a value edit
  • wisp-field-change after a committed change
  • Both include name, value, valid, and error.

Framework use

Facet Fields is browser-native, with typed adapters for React, Vue, and Angular. Each adapter owns component registration, applies configuration changes, forwards the native events, and gives advanced users access to the underlying WispFieldElement. Open Fields Studio ↗ to change a configuration and copy a framework starter.

JavaScript

import { defineWispField } from '@linewisp/wisp-fields';

defineWispField();
document.querySelector('wisp-field').configure({
  name: 'email', label: 'Email address', type: 'email', required: true,
});

React

import { WispField } from '@linewisp/wisp-fields-react';

<WispField configuration={{ name: 'email', label: 'Email address', type: 'email' }}
  onFieldChange={({ value, valid }) => save(value, valid)} />

Vue

import { WispField } from '@linewisp/wisp-fields-vue';

<WispField :configuration="emailField" @field-change="save" />

Angular

import { WispFieldComponent } from '@linewisp/wisp-fields-angular';

<linewisp-field [configuration]="emailField"
  (fieldChange)="save($event)" />

Accessibility and safety

Every field connects its label, help, and error text with native relationships. Errors announce through an alert, async checks announce their pending state, focus styles are visible, and checkbox state follows native input semantics. The component validates untyped JavaScript configuration and renders option labels as text rather than HTML.

Open the live Fields demo ↗