Background
Currently, Codex components that use submittable elements and other form associated HTML tags do not directly support exposing the Constraint Validation API methods or emitting associated events such as 'invalid'. While all of these can be accessed by querying the inner elements of the component, or setting up native event listeners. This creates quite a lot of boilerplate for usage that is available natively by well-supported DOM APIs. Adding support for this API will allow Codex users to leverage constraint validation attributes such as min, max, pattern, etc. and enable them to better implement more semantic HTML. In Wikidata Query Builder, for example, we either have to forego usage of a type=number input and utilize home baked validation rules in the update method (this can be seen in the current code with Wikit, and in a recent patch to migrate to Codex) or jerry-rig the component to allow us to leverage native constraint validation (see pastes in comment below: T373872#10112820).
This issue proposes to add support for native constraint validation in all Codex components that are meant to be used as form controls, beginning with CdxTextInput. These components are:
- TextInput.vue
- TextArea.vue
- Checkbox.vue
- Radio.vue
- ToggleSwitch.vue
- SearchInput.vue
- Combobox.vue
- ChipInput.vue
- Lookup.vue
- Select.vue(?)
Acceptance criteria
- An ADR is published detailing how we intend to support the constraint validation API in Codex
- The components listed above are updated to expose the native properties and methods provided by the constraint validation API
- A composable is provided to make it easy to work with these properties and methods within Codex
- Use of the API and the composable is documented on the Codex docs site
