Campo de cuadro combinado
Permite encontrar un valor escribiendo, como campo de un formulario: un cuadro combinado, con una lista de opciones que se reduce a medida que la persona escribe y de la que elige una o, donde el producto lo permite, un valor propio, bajo una etiqueta que puede decir si el campo es obligatorio u opcional, con una línea de ayuda y el motivo por el que se rechazó un valor.
- Categoría
- Entradas de texto
- Tokens
comp.field- Nivel
- Compuesto
- Web
tanrei-combobox-fieldschedule - SwiftUI
TanreiComboboxFieldradio_button_unchecked - Jetpack Compose
TanreiComboboxFieldradio_button_unchecked - Flutter
TanreiComboboxFieldradio_button_unchecked - React Native
ComboboxFieldradio_button_unchecked
- Variantes que no se incluyen en
- tanrei: filled, outlined
Generado a partir de docs/status/status.json, specs/combobox-field.spec.json
Un campo de cuadro combinado que acepta una de sus opciones y otro que acepta además un valor propio de la persona
Usa un campo de cuadro combinado siempre que un formulario pida un valor que las personas prefieren escribir a buscar desplazándose: una ciudad entre cientos, una persona, un token. También sirve para un campo que sugiere valores y acepta uno propio de la persona, como una familia de fuentes. Es el caso corriente, listo para usarse: una etiqueta, la caja con su lista, una línea de ayuda y las palabras para un valor incorrecto. La caja se dibuja y se mide como la del campo de texto de la misma variante y el mismo tamaño, y la lista se dibuja como la de un select.
Se compone de un campo y un cuadro combinado. El campo es el marco: la etiqueta, la marca de obligatorio o de opcional, la ayuda y el error. El cuadro combinado es el control: la caja, el texto que se escribe en ella y la lista con sus opciones. El campo de cuadro combinado no dibuja nada propio y no tiene ningún token: cada propiedad que tiene es una propiedad de uno de los dos, que recibe sin cambios, y las opciones que le das son las de su cuadro combinado.
Es un bloque tan ancho como el lugar en el que se pone, y su caja lo llena. No tiene ancho propio: para un campo más estrecho, dale un lugar más estrecho. Su ancho nunca depende de sus opciones ni de su valor, porque la persona escribe en él antes de que se conozca ninguna opción.
En la web es <tanrei-combobox-field>, con elementos <tanrei-option> como hijos, los mismos que contiene un select. Las demás plataformas todavía no lo han implementado.
Un campo de cuadro combinado guarda lo que guarda su cuadro combinado, que son dos cosas. value es la elección confirmada: el valor de la opción elegida o un texto propio. inputValue es el texto del campo de entrada. El valor solo cambia cuando la persona elige una opción, confirma el texto (con Enter sin ninguna opción activa, o al salir del campo) o pulsa el botón de borrar; escribir y moverse por la lista nunca lo cambian.
<form>
<tanrei-combobox-field name="city" label="Ciudad" value="tokyo" required required-text="Obligatorio"
clearable clear-label="Borrar ciudad" empty-text="Sin coincidencias">
<tanrei-option value="kyoto">Kioto</tanrei-option>
<tanrei-option value="tokyo">Tokio</tanrei-option>
</tanrei-combobox-field>
</form>
<!-- La caja sola, donde una etiqueta está en otro lugar: un cuadro combinado, que recibe su nombre de su propio label. Importar el campo de cuadro combinado lo define. -->
<tanrei-combobox label="Token" placeholder="Buscar un token" no-chevron style="inline-size: 16rem">
<tanrei-option value="primary">primary</tanrei-option>
</tanrei-combobox>
<!-- Las opciones son sugerencias: un texto que no nombra ninguna pasa a ser el valor. -->
<tanrei-combobox-field label="Familia de fuentes" value="Recursive" allow-custom-value>
<tanrei-option value="Inter">Inter</tanrei-option>
</tanrei-combobox-field>
<!-- Filtras tú: en cada evento input, desde un servidor. La fila de estado dice qué está haciendo tu fuente de datos. -->
<tanrei-combobox-field id="assignee" label="Persona asignada" filter="none" no-chevron placeholder="Buscar una persona">
<span slot="leading-icon">person_search</span>
</tanrei-combobox-field>
<script type="module">
import '@tanrei/web/components/combobox-field';
const assignee = document.querySelector('#assignee');
// La persona cambió el texto. El cuadro combinado no retrasa ni descarta este evento: aplica tú el debounce.
assignee.addEventListener('input', async () => {
assignee.status = 'loading';
assignee.statusText = 'Cargando personas';
const people = await find(assignee.inputValue);
assignee.replaceChildren(...people.map(option));
assignee.status = 'idle';
assignee.statusText = `Se muestran ${people.length} de ${total} personas`;
});
// El valor confirmado cambió. El valor ya es el nuevo.
assignee.addEventListener('change', (e) => save(e.detail.value));
// La persona abrió o cerró la lista; un cierre dice por qué. No se propaga: escúchalo en el propio campo.
assignee.addEventListener('toggle', (e) => console.log(e.detail.open, e.detail.reason));
</script>import { ComboboxField, Option } from '@tanrei/react';
<ComboboxField label="Ciudad" value={city} clearable clearLabel="Borrar ciudad" emptyText="Sin coincidencias" onChange={(event) => setCity(event.detail.value)}>
<Option value="kyoto">Kioto</Option>
<Option value="tokyo">Tokio</Option>
</ComboboxField>Un campo de cuadro combinado es un campo con un cuadro combinado dentro. Escribe tú los dos donde necesites algo que el campo no ofrece: algo tuyo entre la etiqueta y la caja, o debajo de la ayuda. La imagen, el nombre, la descripción y los estados son los mismos.
<!-- El campo de cuadro combinado -->
<tanrei-combobox-field name="city" label="Ciudad" required required-text="Obligatorio"
supporting-text="Adónde se envía el pedido." value="tokyo">
<tanrei-option value="kyoto">Kioto</tanrei-option>
<tanrei-option value="tokyo">Tokio</tanrei-option>
</tanrei-combobox-field>
<!-- Lo mismo, a mano: las propiedades del marco en el campo; todo lo demás, y las opciones, en el cuadro combinado -->
<tanrei-field label="Ciudad" required required-text="Obligatorio" supporting-text="Adónde se envía el pedido.">
<tanrei-combobox name="city" value="tokyo">
<tanrei-option value="kyoto">Kioto</tanrei-option>
<tanrei-option value="tokyo">Tokio</tanrei-option>
</tanrei-combobox>
</tanrei-field>Un campo con un cuadro combinado dentro: la misma imagen que un campo de cuadro combinado
Lo que cambia es dónde está el control del formulario: a mano es el cuadro combinado, que recibe el name; en el campo de cuadro combinado es el campo.
Grupos, texto de apoyo con una opción deshabilitada, un error, un campo de cuadro combinado de solo lectura y uno deshabilitado
| Parte | Qué es |
|---|---|
| Etiqueta | La fila del campo encima del contenedor (stacked), o la etiqueta propia del cuadro combinado flotando dentro de él (filled, outlined). Es el nombre accesible, tanto si se dibuja como si se oculta con labelHidden |
| Marca de obligatoriedad | Después de la etiqueta: el tag de obligatoriedad en su forma de obligatorio, un asterisco o nada con required; el tag de obligatoriedad en su forma de opcional con optional. Una etiqueta flotante lleva el asterisco |
| Campo de entrada | El texto: lo que la persona escribe para encontrar una opción y, mientras no escribe, la etiqueta de la opción elegida o el valor propio. Una sola línea, que se desplaza |
| Marcador de posición | Una indicación que se muestra mientras el campo de entrada está vacío. Nunca es una etiqueta ni un valor |
| Icono inicial | El glifo del slot leading-icon o, si no lo hay, el de la opción elegida |
| Botón de borrar | Con clearable, mientras el texto no está vacío: vacía el texto y el valor |
| Chevron | Dice que el campo tiene una lista que se puede recorrer, y la abre y la cierra. No gira. Omítelo (chevron en false) donde solo hay sugerencias para lo que se ha escrito |
| Texto de apoyo | La fila del campo: una línea de ayuda. Mientras error es true, errorText ocupa su lugar (o va debajo de ella, donde el sistema de diseño conserva las dos). Las dos empiezan donde empieza el texto del campo de entrada |
La fila de la etiqueta, la marca y la fila de apoyo son del campo y se dibujan con los tokens del campo; todo lo demás es del cuadro combinado. Las tres variantes y los tres tamaños, small (32), medium (40) y large (56), son los del campo de texto. El sistema predeterminado solo incluye stacked.
Mientras la lista está abierta, la etiqueta y la ayuda se dibujan con foco junto con la caja, tenga o no el foco el campo de entrada.
La lista se abre a una distancia de comp.combobox.list.offset por debajo del contenedor, exactamente con su mismo ancho, y por encima de él donde no hay sitio debajo. Es tan alta como sus filas hasta list.max-height (320), y a partir de ahí se desplaza.
| Parte | Qué es |
|---|---|
| Opción | Una fila con una etiqueta y, de forma opcional, una línea de apoyo y un glifo. La elegida tiene un relleno discreto y una marca de verificación |
| Coincidencia | Con filter="contains", la parte de cada etiqueta que coincide con el texto se dibuja con más peso |
| Grupo | Una serie de opciones bajo un título opcional. Un grupo que el filtro deja vacío no se dibuja |
| Fila de estado | Después de las opciones: statusText, un indicador de carga mientras status es loading, el fallo mientras es error, o emptyText donde no hay ninguna coincidencia |
filter="contains" muestra las opciones cuya etiqueta contiene el texto, sin distinguir mayúsculas de minúsculas, el ancho de los caracteres ni los signos diacríticos de las letras. Con filter="none", el cuadro combinado muestra todas las opciones que le das y filtras tú, con el evento input. El cuadro combinado nunca obtiene datos, espera, ordena ni clasifica.
| Entrada | Qué ocurre |
|---|---|
| Escribir | Edita el texto y abre la lista, filtrada. La primera coincidencia es la opción activa, y se lee cuando la escritura se detiene; con allowCustomValue no lo es ninguna |
| Flecha abajo, Flecha arriba, con la lista cerrada; el chevron | Abre la lista con todas las opciones. La opción activa es la elegida o, si no hay ninguna, la primera habilitada |
| Flecha abajo, Flecha arriba, con la lista abierta | La opción siguiente o la anterior, atravesando los grupos y dando la vuelta en los extremos (a través del texto, con allowCustomValue), salvo que wrap sea false |
| Av Pág, Re Pág | Diez opciones hacia abajo o hacia arriba |
| Inicio, Fin, Flecha izquierda, Flecha derecha | Mueven el cursor de texto |
| Enter, con una opción activa; una pulsación en una opción | La elige y cierra la lista. No envía el formulario |
| Enter, sin ninguna opción activa | Confirma el texto, emite action y envía el formulario, salvo que action se cancele |
| Escape | Cierra la lista abierta y conserva el texto. Pulsada otra vez, restablece el texto del valor confirmado. Nunca borra un valor |
| Tab; una pulsación fuera | Sale del campo: el texto se resuelve y la lista se cierra. La opción activa no se elige |
| Una pulsación en la etiqueta | Lleva el foco al campo de entrada y no abre nada. Mientras la lista está abierta, es una pulsación fuera del cuadro combinado: la lista se cierra y el foco se queda en el campo de entrada |
Al salir del campo, el texto se resuelve: el cuadro combinado decide qué valor representa ese texto. Un texto vacío vacía el valor. La etiqueta completa de una opción elige esa opción. Cualquier otro texto pasa a ser el valor con allowCustomValue, y sin él se descarta.
La lista no se abre al recibir el foco. Define tú open si quieres que lo haga.
Mientras un método de entrada está componiendo, todas las teclas le pertenecen. El Enter que confirma una conversión no elige ni envía nada.
toggle lleva el motivo de un cierre: select, commit, escape, outside, press, tab, focus-out, anchor-hidden o empty.
Anatomía
Anatomía
stacked-empty, tal como lo dibuja el paquete web.| Parte | Descripción |
|---|---|
1 field | The Field: the label row with its glyph and its requirement mark, and the supporting row with the help and the error text. In a look whose combobox floats the label it draws no label row. |
2 combobox | The combobox, as the Field's one control: the box and the text typed in it, the leading glyph, the clear button and the chevron, the list with its options, groups and status row, and the label that floats in the box in the looks that float one. |
Propiedades
| Propiedad | Tipo | Valor predeterminado | Descripción |
|---|---|---|---|
variant | stacked | filled | outlined | "stacked" | The text input's three looks, so that a combobox is drawn as the text inputs beside it: stacked is a filled box that shows focus and error with a line inside its edge and draws no label of its own; filled and outlined float the label inside the box. Use one style per form. A design system may leave some out (the Tanrei system ships stacked only) or add values. — Combobox |
size | small | medium | large | "medium" | Minimum height of the container: stacked 32 / 40 / 56, as tall as a Button of the same size, so that the box and a Button side by side in one row stand as tall as each other; filled and outlined 40 / 48 / 56, which hold the label that floats inside them. These are the text input's three sizes, small for a bar, a toolbar or a dense row of controls. The hit area always meets the minimum target. A design system may add values. — Combobox |
value | string | "" | The committed choice: the chosen option's value, or, with allowCustomValue, a text the person typed that names no option. Empty while nothing is chosen. It is one string, for ever: several values are another component. — Combobox Held by the combobox, which changes it by a choice, a commit or the clear button; the combobox field's is the same at every moment (CBF-3). |
inputValue | string | "" | The text in the input. The combobox writes it as the person types and when a value is chosen or restored; the product may set it, and reads it from input to load options. — Combobox Held by the combobox, which writes it as the person types and when a value is chosen or restored; the combobox field's is the same at every moment (CBF-3). |
label | string | "" | Names the control, visibly and to assistive technology. Required, unless the control names itself (a checkbox or a switch with its own label): then leave it empty and the field adds only help and an error. — Field Names the combobox. In a filled or outlined look the combobox draws it, floating in its box, and the Field draws no label row (FLD-25, CMB-8). |
labelHidden | boolean | false | Does not draw the label, which stays the accessible name. For a control whose visible label is elsewhere (a table column, a toolbar). — Field Hides the label wherever it would be drawn: the Field's row, or the combobox's floating label (FLD-25). |
placeholder | string | "" | A hint shown while the input is empty and no label is in the input line. Never a replacement for a name. — Combobox |
supportingText | string | "" | Help shown below the control and given to assistive technology as the control's description. While the field is in error it gives way to errorText, unless the design system keeps both (comp.field.error-text.placement append). — Field |
errorText | string | "" | Shown while error is true, in supportingText's place — or below it, which then stays, where the design system's comp.field.error-text.placement is append: what is wrong and how to put it right, in words. — Field |
error | boolean | false | Puts the field in the error condition: the error text is drawn, the control is exposed as invalid and, where it has an error condition of its own, drawn in it. What a value means is the product's to validate; the field never sets this itself. — Field Puts the Field in its error condition, which puts the combobox in its own (FLD-8, CMB-10). |
disabled | boolean | false | Disables the control and draws the frame as disabled. Disable a framed control here, not on the control, so that its label follows. — Field Disables the Field, which disables the combobox (FLD-14, CMB-46). |
readOnly | boolean | false | The value is shown, can be focused, selected and copied, and is submitted, but cannot be changed: the list does not open and neither the chevron nor the clear button is drawn. — Combobox |
required | boolean | false | What the form asks of the control: true exposes it as required and draws the required mark beside the label. It never validates: a missing answer is the product's to report with error. — Field |
optional | boolean | false | Draws the optional tag after the label and adds optionalText to the control's description, because assistive technology has no state for it. Ignored while required is true: a control is never both. — Field |
requiredMark | auto | tag | asterisk | none | "auto" | How this control shows that it is required: tag is a small filled Tag with requiredText, asterisk is "*" after the label, none draws nothing and keeps the semantics. Auto takes comp.field.requirement.mark, which follows sys.behavior.requirement-mark, the system's one answer. Ignored unless required is true. — Field |
requiredText | string | "" | The text of the required tag, in the product's language ("Required", "必須"). The product's: Tanrei has no word for it. Empty reads the product's words; with neither, FLD-24 says what is drawn. — Field |
optionalText | string | "" | The text of the optional tag, in the product's language ("Optional", "任意"); also read to assistive technology as part of the description. The product's: Tanrei has no word for it. Empty reads the product's words. — Field |
open | boolean | false | Whether the list is shown. The combobox opens and closes itself and emits toggle; the product may also set it (to open on focus, for one). Ignored while the combobox is disabled or read-only or has nothing to show. — Combobox Held by the combobox, which opens and closes its list itself; the combobox field's is the same at every moment (CBF-3). |
allowCustomValue | boolean | false | False: the value is always one of the options, and a text that names none is given up when the person leaves. True: the options are suggestions, and a text that names none becomes the value as typed (a font family, a tag, an address). — Combobox |
filter | contains | none | "contains" | Who decides which options answer the text. contains: the combobox shows the options whose label contains what was typed, ignoring case, and marks the match. none: the combobox shows every option it is given and the product filters — on input, from its own data or a server — and says what it is doing with status. — Combobox |
wrap | boolean | true | Whether the arrow keys go round at the ends of the list: Down Arrow on the last option to the first, Up Arrow on the first to the last — with allowCustomValue true, through the text itself, where no option is active (CMB-26). False stops them at the ends. — Combobox |
chevron | boolean | true | Draws the chevron that opens the whole list without typing. False for a field whose suggestions exist only for what was typed (a remote search): there is no list to look through. — Combobox |
clearable | boolean | false | Draws a clear button while the text is not empty, for a combobox whose value may be none. Without it, emptying the text and leaving the field clears the value. — Combobox |
clearLabel | string | "" | The clear button's accessible name, in the product's language ("Clear"). Required while clearable is true. — Combobox |
status | idle | loading | error | "idle" | What the product's source of options is doing, which the product sets: idle (the options given are final), loading (options are on their way: the status row shows a loading indicator), error (the source failed: the status row shows statusText in the error color). — Combobox |
statusText | string | "" | The status row's text, in the product's language, announced to assistive technology when it changes: a count ("12 of 340 shown"), that loading failed, or, while status is loading, the loading indicator's name ("Loading options"). — Combobox |
emptyText | string | "" | Shown in the list while the text names nothing the combobox can show, allowCustomValue is false and no status is set, in the product's language ("No matches"). The product's: Tanrei has no words for it. Empty reads the product's words; with neither, no such row is drawn and it is reported (CMB-32). — Combobox |
separation | auto | divider | gap | "auto" | How a group of options is told from what is next to it. divider: a line between them. gap: empty space and no line. Auto takes comp.combobox.separation, which follows the design system's choice. — Combobox |
iconSpace | auto | always | never | "auto" | Whether a shown option keeps the room of the leading icon column where it has no icon, so that the labels of a section start on one line — a section being the shown options of a group, or a run of adjacent shown options outside any group. auto: an option keeps the column while another shown option of its section has a leading icon; an option the filter hides does not count. always: every option keeps it. never: only an option that has an icon has the column. The menu's and the select's iconSpace, with the same values and default (CMB-67). — Combobox |
density | regular | compact | "regular" | How much room an option of the list takes: its least height, its paddings, the gap between its columns and the size of its glyphs (the leading icon, the check), and never its text style. regular (a 48 row in the default system) is for a product used by touch as well as by pointer; compact (a 32 row with 20 glyphs, the menu's compact row) is for a tool used with a pointer, whose lists are long. For touch an option is never lower than the touch target in either (CMB-34). The field's own box is not changed: its height is size's. A design system may add values. — Combobox |
Slots
| Slot | Descripción |
|---|---|
leading-icon | A glyph at the start of the container that stands for the combobox whatever is chosen (a magnifier before a field that searches people). It takes the place of the chosen option's own glyph. — Combobox |
label-icon | A glyph before the label. — Field |
Eventos
| Evento | Descripción |
|---|---|
input | The person changed the text (typing, deleting, pasting, dictating, the clear button, Escape restoring it); carries the new text. Not emitted when the product sets inputValue or value, or when a choice writes its label. It is the product's cue to load options; the combobox does not delay or drop it. — Combobox |
change | The committed value changed by the person: an option was chosen, a custom text was committed, or the value was cleared; carries the new value and the text now shown. Not emitted when the product sets value, when the chosen option is chosen again, or while the person only types or moves through the list. — Combobox |
toggle | The list was opened or closed by the person or by having nothing left to show; carries the new open and, for a close, the reason: select, commit, escape, back, outside, press, tab, focus-out, anchor-hidden or empty (in the platform's casing). After a choice it follows change. — Combobox |
action | The person pressed Enter with no option active and the text was committed; emitted after any change it caused. On the web it is followed by the form's submission unless cancelled. — Combobox |
Elementos
Los tipos de elemento que el componente repite. Un fixture enumera sus elementos en orden; cada plataforma nombra cada tipo según su propio estilo.
option
One choice of the combobox: a label, the value it stands for, and optionally a supporting line and a glyph. The same kind a select holds.
| Propiedad | Tipo | Valor predeterminado | Descripción |
|---|---|---|---|
label | string | "" | The option's text and its accessible name: what the filter searches and what the input shows once the option is chosen. Required. |
value | string | "" | Identifies the choice: the option is the chosen one while the combobox's value equals it. Unique within the combobox and not empty: the empty value means that nothing is chosen. |
supportingText | string | "" | A line below the label that says more about the choice. Shown in the list, not in the input; not searched. |
leadingIcon | string | "" | The name of an icon (a glyph of the system's icon set) before the label; the container shows it too while the option is chosen and the combobox has no leading icon of its own. |
disabled | boolean | false | Prevents the option from being chosen. It stays reachable with the arrow keys. |
| Especificación | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| Elemento | tanrei-option | TanreiComboboxOption | TanreiComboboxOption | TanreiComboboxOption | ComboboxOption |
label · Propiedad | label | title | text | label | label |
value · Propiedad | value | tag | value | value | value |
supportingText · Propiedad | supportingText | supportingText | supportingText | supportingText | supportingText |
leadingIcon · Propiedad | leadingIcon | leadingIcon | leadingIcon | leadingIcon | leadingIcon |
disabled · Propiedad | disabled | disabled | enabled | enabled | disabled |
| Notas | <tanrei-option value="tokyo">Tokyo</tanrei-option>: the element a select holds, and the same data: the label is the label attribute or, without one, the element's text. Attributes supporting-text, leading-icon, disabled. It draws nothing itself. tanrei-option and tanrei-option-group are one pair of elements for the select and the combobox, defined once; an option with the empty value is refused by the combobox (CMB-17, CMB-57), not by the element, because a select allows it. | TanreiComboboxOption(_ title:, supportingText:, leadingIcon:).tag(value); disabled follows .disabled(_:). | TanreiComboboxOption(text, value, supportingText, leadingIcon, enabled), called in the combobox's content lambda. | TanreiComboboxOption<String>(value:, label:, supportingText:, leadingIcon:, enabled:), in the combobox's options list, as DropdownMenuEntry. | { label, value, supportingText?, leadingIcon?, disabled? }: an element of the options array. |
option-group · grupo: contiene elementos
A run of related options, optionally titled. The combobox separates a group from what is next to it by a divider or a gap, and draws neither a group nor its title while the filter leaves it empty.
| Propiedad | Tipo | Valor predeterminado | Descripción |
|---|---|---|---|
title | string | "" | A short heading drawn above the group's options, which also names the group; empty draws none and leaves the group unnamed. |
| Especificación | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| Elemento | tanrei-option-group | TanreiComboboxSection | TanreiComboboxGroup | TanreiComboboxGroup | ComboboxOptionGroup |
title · Propiedad | label | title | title | title | title |
| Notas | The title is the label attribute, as <optgroup label>: a title attribute would also draw the browser's tooltip. | TanreiComboboxSection(_ title:) { … }, as Section. | TanreiComboboxGroup(title) { … }. | TanreiComboboxGroup(title:, options: […]), in the same list. | { kind: 'group', title?, options: ComboboxOption[] } in the same array. |
Estados
Comportamiento
Requisitos en formato EARS. Cada implementación de plataforma se prueba contra estos identificadores. El texto de los requisitos se muestra tal como está en la especificación, en inglés.
| ID | Requisito |
|---|---|
CBF-1 | THE combobox field SHALL be a Field that frames one combobox, and nothing else. It SHALL give label, labelHidden, supportingText, errorText, error, disabled, required, optional, requiredMark, requiredText and optionalText to its Field and every other prop to its combobox, each unchanged; SHALL hold the label-icon slot for its Field and the leading-icon slot for its combobox; SHALL give its options to its combobox (CBF-2); and SHALL emit its combobox's events as its own, each once. THE combobox field SHALL be as wide as the place it stands in, and its combobox SHALL fill it: it is a block with no width of its own, as its Field is (FLD-1), around a control that fills the width it is given (CMB-49). It SHALL draw no part of its own and have no token of its own: what it shows, how it behaves and what it exposes to assistive technology SHALL be exactly what that Field and that combobox do when a product places the one in the other (FLD-1 to FLD-28; CMB-1 to CMB-62) — the label row and its requirement mark (FLD-2 to FLD-6), or the label that floats in the box with the Field's row left out (FLD-25, CMB-7, CMB-8); the supporting row and the error (FLD-7 to FLD-9, FLD-26, CMB-10); the name, the description and the states (FLD-10, FLD-11, FLD-14, CMB-12, CMB-46); and the list, which is the combobox's alone and as wide as its container (CMB-22). |
CBF-2 | THE combobox field SHALL take the options and the option groups a product gives it — in the platform's form for a combobox's own (its child elements on the web) — and give them to its combobox as that combobox's options, in the order given, each with its label, its value, its supporting text, its leading icon and its disabled, and each group with its title: the option a product wrote SHALL be the option its combobox reads, never a copy of it. THE combobox field SHALL NOT read, filter, order, count or keep an option, and SHALL make no option active or chosen: which options are shown, which is active and which is the chosen one are its combobox's (CMB-25, CMB-26, CMB-36). WHEN the product adds, removes, reorders or changes an option or a group THE combobox field's combobox SHALL meet the change at once and as CMB-31 says, as though the product had changed that combobox's own options. |
CBF-3 | THE combobox field SHALL hold no value, no text and no open state of its own: its value, its inputValue and its open SHALL at every moment be its combobox's. WHEN its combobox changes one of them — a choice, a commit or the clear button (CMB-17, CMB-20, CMB-27 to CMB-29); typing, or a text the combobox writes itself for a choice, for a commit that was given up or for Escape (CMB-16, CMB-27, CMB-29, CMB-30); the list opening or closing, or open taken back because there is nothing to show (CMB-21, CMB-30, CMB-57) — THE combobox field's SHALL be the new one before any event that reports the change is emitted, and equally WHERE no event reports it. WHEN the product sets one on the combobox field THE combobox field SHALL set it on its combobox and nothing else, so that no event follows (CMB-31). |
CBF-4 | WHERE the platform has forms (the web) THE combobox field SHALL be the one control the form sees: it SHALL take name, submit its combobox's value — never the text of an edit that was not committed — reset to the value it was first given, restore it on navigation, report to the form's constraint validation exactly what its combobox would report there (CMB-59), and be left out WHILE disabled is true or a disabled group of the form holds it; its combobox and its Field SHALL take no part in the form themselves. WHEN Enter asks for the form's submission (CMB-28) the form asked SHALL be the combobox field's own, through that form's default button (BTN-30), and not WHEN action was cancelled. |
CBF-5 | WHEN the combobox field is given focus — by the product, by a press on any part of it that FLD-12 or CMB-14 gives to the input, or by a form that reports its validity — THE combobox field SHALL pass the focus to its combobox's input and SHALL add no stop to the focus order: the stops inside it are its combobox's, in that combobox's order (the input, then the clear button while it is shown). WHILE focus is anywhere inside it, or its combobox's list is open, its Field's rows SHALL be drawn focused, because its combobox says so to its Field (FLD-13, CMB-61): the combobox field arranges nothing for it. A press on its Field's label row WHILE the list is open is a press outside the combobox: the list SHALL close with the reason outside, choosing nothing (CMB-30), and focus SHALL go to the input (FLD-12). |
CBF-6 | IF the combobox field is placed in a Field THE combobox field SHALL in debug builds report that it is a field already and that the bare control is the combobox, and both SHALL still render (FLD-15). WHILE it stands in a field group THE combobox field SHALL follow that group's disabled, through its own Field, and take nothing else from the group (FGR-20). |
CBF-7 | THE combobox field SHALL have no words of its own and SHALL read none: requiredText and optionalText are read by its Field (FLD-24), emptyText and clearLabel by its combobox (CMB-60), each from the instance's prop and then from the product's words. |
CBF-8 | WHERE the platform has ARIA attributes (the web), WHEN the product sets an aria- attribute on the host, by the attribute or by the ARIA property that reflects it, THE combobox field SHALL move it to the data-aria- attribute of the same name, so that the host is no second node with its name, description or state, and SHALL expose it on the element that carries its role — an id reference by the elements it names in the host's tree or a tree around it, an error message as part of the description while the combobox field is invalid — except those the combobox field owns (aria-label, aria-labelledby, aria-disabled, aria-haspopup, aria-expanded, aria-controls), which it SHALL move and not expose: its name is label (CBF-1). WHEN the product removes the aria- attribute or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaDescribedByElements…) to null, THE combobox field SHALL take it off that element. WHEN the product sets an aria- attribute the combobox field owns THE combobox field SHALL report it in debug builds. |
Correspondencia de nombres por plataforma
Paridad no significa API idénticas. Cada plataforma expresa el mismo contrato con su propio estilo.
| Especificación | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| Componente | tanrei-combobox-field | TanreiComboboxField | TanreiComboboxField | TanreiComboboxField | ComboboxField |
variant · Propiedad | variant | variant | variant | variant | variant |
size · Propiedad | size | size | size | size | size |
value · Propiedad | value | selection | value | value | value |
inputValue · Propiedad | inputValue | text | inputValue | controller | inputValue |
label · Propiedad | label | label | label | labelText | label |
labelHidden · Propiedad | labelHidden | labelsHidden | labelHidden | labelHidden | labelHidden |
placeholder · Propiedad | placeholder | prompt | placeholder | hintText | placeholder |
supportingText · Propiedad | supportingText | supportingText | supportingText | helperText | supportingText |
errorText · Propiedad | errorText | errorText | errorText | errorText | errorText |
error · Propiedad | error | error | isError | isError | error |
disabled · Propiedad | disabled | disabled | enabled | enabled | disabled |
readOnly · Propiedad | readOnly | readOnly | readOnly | readOnly | readOnly |
required · Propiedad | required | isRequired | required | required | required |
optional · Propiedad | optional | isOptional | optional | optional | optional |
requiredMark · Propiedad | requiredMark | requiredMark | requiredMark | requiredMark | requiredMark |
requiredText · Propiedad | requiredText | requiredText | requiredText | requiredText | requiredText |
optionalText · Propiedad | optionalText | optionalText | optionalText | optionalText | optionalText |
open · Propiedad | open | isPresented | expanded | menuController | open |
allowCustomValue · Propiedad | allowCustomValue | allowCustomValue | allowCustomValue | allowCustomValue | allowCustomValue |
filter · Propiedad | filter | filter | filter | filter | filter |
wrap · Propiedad | wrap | wrap | wrap | wrap | wrap |
chevron · Propiedad | noChevron | chevron | chevron | chevron | chevron |
clearable · Propiedad | clearable | clearable | clearable | clearable | clearable |
clearLabel · Propiedad | clearLabel | clearLabel | clearContentDescription | clearSemanticLabel | clearAccessibilityLabel |
status · Propiedad | status | status | status | status | status |
statusText · Propiedad | statusText | statusText | statusText | statusText | statusText |
emptyText · Propiedad | emptyText | emptyText | emptyText | emptyText | emptyText |
separation · Propiedad | separation | separation | separation | separation | separation |
iconSpace · Propiedad | iconSpace | iconSpace | iconSpace | iconSpace | iconSpace |
density · Propiedad | density | density | density | density | density |
input · Evento | input | text | onInputValueChange | onInputChanged | onInputValueChange |
change · Evento | change | selection | onValueChange | onChanged | onValueChange |
toggle · Evento | toggle | isPresented | onExpandedChange | onOpenChanged | onOpenChange |
action · Evento | action | onSubmit | keyboardActions | onSubmitted | onSubmitEditing |
| Notas | The tag tanrei-combobox-field, the class TanreiComboboxField, the React name ComboboxField. It takes the combobox's attributes, children and listeners and the Field's, name for name. The element is composed as every composed element on the web is (the web package's README, Composed elements); what follows is what is particular to it, and the three places where this element needs more than every composed element has. Members: <tanrei-field> holding one <tanrei-combobox> in its default slot; the product places no member. The host is display: block. Value member: tanrei-combobox. The host is the form's element — name, the value and its state, validity anchored on the combobox's input, reset to the value attribute, restore, form, a disabled fieldset — and the combobox inside has no name. Props, set as properties on the member each is from. On the Field: label, labelHidden, supportingText, errorText, error, disabled, required, optional, requiredMark, requiredText, optionalText. On the combobox: variant, size, value, inputValue, placeholder, readOnly, open, allowCustomValue, filter, noChevron (the inverse of chevron, attribute no-chevron), clearable, clearLabel, status, statusText, emptyText, separation. Attributes are the members' own: kebab-case, except readonly. Props of one name on both members — label, labelHidden, error, disabled — are the Field's; the combobox's are never set by the element and reach the combobox through the connection. **1. Three props the member writes** (a composed element sets each prop on its member, with one exception, the value, which it reads back on the member's event): the combobox writes value, inputValue and open itself, and writes the text with no event when a commit is given up (CMB-29). The host therefore keeps no copy of the three: each is an accessor over the member's property — a get reads the member's, a set writes the member's, and a value set before the member exists is kept and given at its first render — so that event.target.value, .inputValue and .open are the new ones in every listener and between events (CBF-3). open reflects on the host as it does on the member: the host writes its own attribute when the member tells it of an update, by the primitive through which the member already tells the host its form value. **2. The options are passed by the default slot** (other passed-on children use named slots): the shadow root is <tanrei-field><slot name="label-icon" slot="label-icon"></slot><tanrei-combobox><slot></slot><slot name="leading-icon" slot="leading-icon"></slot></tanrei-combobox></tanrei-field>. The product's <tanrei-option> and <tanrei-option-group> children stay the host's light-DOM children and are assigned to the unnamed <slot>, which is a child of the combobox; the combobox reads a <slot> among its children as the elements assigned to it and reads again on slotchange and on a change of an assigned element (primitives/option-list.ts, the combobox's web note; the select reads its options the same way, with the same reader). Unlike a passing named slot, the unnamed one is always rendered: the combobox draws no room for options, so an empty slot is no option. The host never reads its option children. Slots: label-icon is passed to the Field and leading-icon to the combobox, each by a slot element of the same name rendered only while the host has a child for it. **3. A forwarded attribute that is no prop**: inline, the combobox's web-only attribute that draws an open list in place for the fixtures, is forwarded as a property, and select() is passed on as focus() and blur() are. Events: input is the native, composed event of the text element, and change and action are the combobox's own composed, bubbling events; the three leave by themselves, with the host as their target, and action stays cancelable. toggle is composed and does not bubble: it is heard on the host, as on any shadow host, and by no ancestor — which needs the combobox's toggle to be composed, as it is not today (the combobox's web note). None is stopped and none is copied. Parts: the member hosts are field and combobox. Exported from the Field: label, label-icon, requirement-label, supporting-text. Exported from the combobox: container, outline, active-indicator, label, requirement-label, input, leading-icon, clear-button, chevron, list, option, option-label, option-supporting-text, option-leading-icon, mark, group, group-title, divider, status. Two names collide, label and requirement-label. Each is exported with its member's name before it, always (field-label, combobox-label, field-requirement-label, combobox-requirement-label), and under the bare name from both members as well, because the two are one thing to a person and are never drawn at once: FLD-25 is the sentence that holds it. Focus: the shadow root does not delegate. focus(), blur() and select() call the combobox's; a press on the label row focuses the input by FLD-12, a press on the box by CMB-14, and a press on the help does nothing. The combobox's list is a popover of the combobox's own shadow root, in the top layer; the combobox is its opener, so a press on the Field's rows while it is open is a press outside (CBF-5). The connection is the Field's with its control, with one value more upward, that the control is drawn focused (FLD-13, FLD-25, FLD-26, CMB-61); the element takes no part in it. Parts and tokens of its own: none. The element writes no custom property: --tanrei-comp-field-*, --tanrei-comp-input-box-* and --tanrei-comp-combobox-* reach the members by inheritance, and one combobox field is set apart by setting any of them on the element. What its twin cannot do that it does: nothing. The twin: <tanrei-field label="City" supporting-text="Where the order is sent." required><tanrei-combobox name="city" value="tokyo"><tanrei-option value="kyoto">Kyoto</tanrei-option><tanrei-option value="tokyo">Tokyo</tanrei-option></tanrei-combobox></tanrei-field>. Before the element is defined its options are running text: a page hides them with tanrei-combobox-field:not(:defined) > * { display: none } and gives the tag a block size. Words: none of its own; required-text and optional-text are read by the Field, empty-text and clear-label by the combobox. | TanreiComboboxField("City", selection: $city, text: $query) { TanreiComboboxOption("Tokyo").tag("tokyo") … }: a view built from TanreiField and TanreiCombobox, with the combobox's two bindings and its content builder passed through and the Field's arguments beside them. It takes TanreiCombobox's arguments, name for name. One instance is set apart by .tanreiTheme(_:) on the view. The options are TanreiComboboxOption and TanreiComboboxSection, the combobox's own. Planned, after the Field and the combobox. | TanreiComboboxField(value, onValueChange, label = "City") { TanreiComboboxOption("Tokyo", "tokyo") … }: a composable that calls TanreiField with TanreiCombobox as its content and passes the content lambda through. enabled is the inverse flag and isError keeps Compose's name. One instance is set apart by TanreiTheme(…) { } around it. Planned, after the Field and the combobox. | TanreiComboboxField(value:, onChanged:, labelText:, helperText:, errorText:, options: […]): a widget that builds TanreiField around TanreiCombobox and passes options through; labelText, hintText, helperText, errorText and enabled keep InputDecoration's names, enabled the inverse flag. TanreiComboboxFormField wraps the combobox field as a FormField<String>. One instance is set apart by a TanreiTheme around it. Planned, after the Field and the combobox. | <ComboboxField label="City" supportingText="Where the order is sent." value={city} onValueChange={setCity} options={[…]} />: a component that renders Field around Combobox and passes options through as given. inputValue / onInputValueChange and open / onOpenChange are the combobox's optional pairs. One instance is set apart by a provider around it. Planned, after the Field and the combobox. |
Tokens
| Token | Alias de | Valor resuelto (claro) |
|---|---|---|
--tanrei-comp-field-counter-gap | sys.space.space200 | 16px |
--tanrei-comp-field-error-text-gap | sys.space.space50 | 4px |
--tanrei-comp-field-error-text-placement | — | 0 |
--tanrei-comp-field-label-icon-gap | sys.space.space100 | 8px |
--tanrei-comp-field-label-icon-size | sys.icon.small | 20px |
--tanrei-comp-field-label-gap | sys.space.space100 | 8px |
--tanrei-comp-field-motion-state-duration | sys.motion.role.state.default | 250ms |
--tanrei-comp-field-motion-state-easing | sys.motion.easing.state | cubic-bezier(0.2, 0, 0, 1) |
--tanrei-comp-field-requirement-asterisk-gap | sys.space.space25 | 2px |
--tanrei-comp-field-requirement-gap | sys.space.space100 | 8px |
--tanrei-comp-field-requirement-mark | sys.behavior.requirement-mark | 0 |
--tanrei-comp-field-standard-counter-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-disabled-counter-color | — | |
--tanrei-comp-field-standard-disabled-error-text-color | — | |
--tanrei-comp-field-standard-disabled-error-counter-color | — | |
--tanrei-comp-field-standard-disabled-error-label-icon-color | — | |
--tanrei-comp-field-standard-disabled-error-label-color | — | |
--tanrei-comp-field-standard-disabled-error-required-asterisk-color | — | |
--tanrei-comp-field-standard-disabled-error-supporting-text-color | — | |
--tanrei-comp-field-standard-disabled-error-value-text-color | — | |
--tanrei-comp-field-standard-disabled-label-icon-color | — | |
--tanrei-comp-field-standard-disabled-label-color | — | |
--tanrei-comp-field-standard-disabled-required-asterisk-color | — | |
--tanrei-comp-field-standard-disabled-supporting-text-color | — | |
--tanrei-comp-field-standard-disabled-value-text-color | — | |
--tanrei-comp-field-standard-error-text-color | sys.color.error | |
--tanrei-comp-field-standard-error-counter-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-error-label-icon-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-error-label-color | sys.color.on-surface | |
--tanrei-comp-field-standard-error-required-asterisk-color | sys.color.primary | |
--tanrei-comp-field-standard-error-supporting-text-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-error-value-text-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-focused-counter-color | — | |
--tanrei-comp-field-standard-focused-error-text-color | — | |
--tanrei-comp-field-standard-focused-error-counter-color | — | |
--tanrei-comp-field-standard-focused-error-label-icon-color | — | |
--tanrei-comp-field-standard-focused-error-label-color | — | |
--tanrei-comp-field-standard-focused-error-required-asterisk-color | — | |
--tanrei-comp-field-standard-focused-error-supporting-text-color | — | |
--tanrei-comp-field-standard-focused-error-value-text-color | — | |
--tanrei-comp-field-standard-focused-label-icon-color | — | |
--tanrei-comp-field-standard-focused-label-color | — | |
--tanrei-comp-field-standard-focused-required-asterisk-color | — | |
--tanrei-comp-field-standard-focused-supporting-text-color | — | |
--tanrei-comp-field-standard-focused-value-text-color | — | |
--tanrei-comp-field-standard-label-icon-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-label-color | sys.color.on-surface | |
--tanrei-comp-field-standard-required-asterisk-color | sys.color.primary | |
--tanrei-comp-field-standard-supporting-text-color | sys.color.on-surface-variant | |
--tanrei-comp-field-standard-value-text-color | sys.color.on-surface-variant | |
--tanrei-comp-field-supporting-text-gap | sys.space.space50 | 4px |
--tanrei-comp-field-value-text-gap | sys.space.space200 | 16px |
--tanrei-comp-field-label-typescale | sys.typescale.label | 500 14px/1.4286 |
--tanrei-comp-field-supporting-text-typescale | sys.typescale.label-small | 500 12px/1.3333 |
--tanrei-comp-field-value-text-typescale | sys.typescale.label | 500 14px/1.4286 |
Fixtures
Representaciones canónicas. Todas las plataformas capturan cada fixture con el mismo identificador para poder comparar los resultados.
variant: stacked (46)
stacked-empty
variant: stacked label: City items: 5 stacked-value
variant: stacked value: tokyo label: City items: 5 stacked-open
variant: stacked value: tokyo label: City open: true items: 5 Dibujado por separado en una ventana de 312 × 472stacked-large
variant: stacked size: large value: tokyo label: City items: 5 stacked-error
variant: stacked label: City errorText: Choose the city you are sending to. error: true items: 5 stacked-disabled
variant: stacked value: tokyo label: City disabled: true items: 5 stacked-placeholder
label: City placeholder: Type to find a city items: 5 stacked-label-hidden
value: tokyo label: City labelHidden: true items: 5 stacked-supporting
value: tokyo label: City supportingText: Where the order is sent. items: 5 stacked-error-value
value: nairobi label: City supportingText: Where the order is sent. errorText: We do not deliver to Nairobi yet. error: true items: 5 stacked-read-only
value: tokyo label: City readOnly: true items: 5 stacked-clearable
value: tokyo label: City clearable: true clearLabel: Clear city items: 5 stacked-no-chevron
label: Address placeholder: Start typing an address filter: none chevron: false items: 1 stacked-custom-value
value: Recursive label: Font family allowCustomValue: true items: 4 stacked-required
label: City required: true requiredText: Required items: 5 stacked-optional
label: City optional: true optionalText: Optional items: 5 stacked-required-asterisk
label: City required: true requiredMark: asterisk items: 5 stacked-required-error
label: City errorText: Choose the city you are sending to. error: true required: true requiredText: Required items: 5 stacked-required-disabled
value: tokyo label: City disabled: true required: true requiredText: Required items: 5 stacked-label-icon
value: tokyo label: City items: 5 slots: label-icon stacked-leading-icon
label: Assignee placeholder: Find a person items: 2 slots: leading-icon stacked-option-icon
value: train label: Transport items: 3 open-none-chosen
label: City open: true items: 5 Dibujado por separado en una ventana de 312 × 473open-filtered
value: tokyo inputValue: to label: City open: true items: 5 Dibujado por separado en una ventana de 312 × 473open-filtered-none
inputValue: zz label: City open: true emptyText: No matches items: 5 Dibujado por separado en una ventana de 312 × 473open-icons
value: train label: Transport open: true items: 3 Dibujado por separado en una ventana de 312 × 473open-supporting-text
value: sys.color.on-primary inputValue: primary label: Token open: true items: 4 Dibujado por separado en una ventana de 312 × 473open-disabled-chosen
value: sys.color.secondary label: Token open: true items: 4 Dibujado por separado en una ventana de 312 × 473open-groups
value: Europe/Lisbon label: Time zone open: true items: 3 Dibujado por separado en una ventana de 312 × 473open-groups-divider
value: Europe/Lisbon label: Time zone open: true separation: divider items: 3 Dibujado por separado en una ventana de 312 × 473open-groups-gap
value: Europe/Lisbon label: Time zone open: true separation: gap items: 3 Dibujado por separado en una ventana de 312 × 473open-groups-filtered
inputValue: in label: Time zone open: true items: 3 Dibujado por separado en una ventana de 312 × 473open-many
value: lisbon label: City open: true items: 24 Dibujado por separado en una ventana de 312 × 473open-long-options
label: Licence open: true items: 2 Dibujado por separado en una ventana de 312 × 473open-custom-suggestions
inputValue: no label: Font family open: true allowCustomValue: true items: 4 Dibujado por separado en una ventana de 312 × 473open-loading
inputValue: ai label: Assignee open: true filter: none chevron: false status: loading statusText: Loading people items: 1 Dibujado por separado en una ventana de 312 × 473open-status
inputValue: a label: Assignee open: true filter: none chevron: false statusText: 2 of 48 people shown. Keep typing to nar… items: 2 Dibujado por separado en una ventana de 312 × 473open-status-error
inputValue: ai label: Assignee open: true filter: none chevron: false status: error statusText: People could not be loaded. Check your c… items: 1 Dibujado por separado en una ventana de 312 × 473long-value
value: cc-by-nc-sa label: Licence items: 2 long-label
label: Which of the cities we deliver to is nea… supportingText: If none of them is near enough, leave th… required: true requiredText: Required items: 5 stacked-required-ja
value: kyoto label: 都市 required: true requiredText: 必須 items: 3 open-filtered-ja
inputValue: 京 label: 都市 optional: true optionalText: 任意 open: true emptyText: 一致する項目がありません items: 3 Dibujado por separado en una ventana de 312 × 473stacked-required-rtl
value: cairo label: المدينة supportingText: إلى أين نرسل الطلب. required: true requiredText: مطلوب clearable: true clearLabel: مسح المدينة direction: rtl items: 2 slots: label-icon open-rtl
value: Asia/Riyadh inputValue: ال label: المنطقة الزمنية open: true direction: rtl items: 2 Dibujado por separado en una ventana de 312 × 473long-value-rtl
value: cc-by-nc-sa label: רישיון direction: rtl items: 2 stacked-error-rtl
label: עיר errorText: יש לבחור עיר מהרשימה. error: true optional: true optionalText: רשות direction: rtl items: 2 variant: filled (6)
filled-empty
variant: filled label: City items: 5 filled-value
variant: filled value: tokyo label: City items: 5 filled-open
variant: filled value: tokyo label: City open: true items: 5 Dibujado por separado en una ventana de 312 × 473filled-large
variant: filled size: large value: tokyo label: City items: 5 filled-error
variant: filled label: City errorText: Choose the city you are sending to. error: true items: 5 filled-disabled
variant: filled value: tokyo label: City disabled: true items: 5 variant: outlined (8)
outlined-empty
variant: outlined label: City items: 5 outlined-value
variant: outlined value: tokyo label: City items: 5 outlined-open
variant: outlined value: tokyo label: City open: true items: 5 Dibujado por separado en una ventana de 312 × 473outlined-large
variant: outlined size: large value: tokyo label: City items: 5 outlined-error
variant: outlined label: City errorText: Choose the city you are sending to. error: true items: 5 outlined-disabled
variant: outlined value: tokyo label: City disabled: true items: 5 outlined-required
variant: outlined label: City required: true requiredText: Required items: 5 outlined-rtl
variant: outlined value: cairo label: المدينة direction: rtl items: 2 Generado a partir de specs/combobox-field.spec.json, tokens/comp/field.tokens.json, design/tokens/
<tanrei-option>y<tanrei-option-group>son datos: no dibujan nada. Son los elementos que contiene un select. Una opción cuyo valor es la cadena vacía se dibuja y no se puede elegir, porque el valor vacío significa que no hay nada elegido.- El shadow root del elemento contiene un
<tanrei-field>alrededor de un<tanrei-combobox>. Tus hijos<tanrei-option>siguen siendo hijos suyos y llegan al cuadro combinado a través de un slot; nada se mueve ni se copia. - El campo de cuadro combinado es un elemento asociado a formularios: el único control que ve el formulario. Recibe
name, envíavaluey nunca el texto de una edición que no se confirmó, se restablece al valor del atributovaluey, mientrasrequiredyvalueestá vacío, notifica al formulario que falta un valor. Enter sin ninguna opción activa envía su formulario. value,inputValueyopenson en todo momento los del cuadro combinado: cada uno es ya el nuevo en todos los listeners.chevronywrapson los atributos inversosno-chevronyno-wrap, yreadOnlyesreadonly.inputes el evento nativo del elemento de texto.changeyactionllevandetail.valueydetail.inputValue. Los cuatro eventos son los propios del cuadro combinado, con el campo de cuadro combinado como destino;toggleno se propaga.focus()va al campo de entrada. El elemento no puede recibir el foco por sí mismo y no tiene rol: dale nombre conlabel, nunca conaria-label.- Partes:
fieldycomboboxson los dos miembros; las partes de cada miembro se exportan con sus propios nombres, ylabelyrequirement-labeltambién comofield-label,combobox-label,field-requirement-labelycombobox-requirement-label. - Un solo campo se diferencia con una propiedad personalizada definida en él:
--tanrei-comp-field-*para las filas,--tanrei-comp-input-box-*para la caja,--tanrei-comp-combobox-*para la lista. - La lista es un elemento
popover="manual"en la capa superior. Una pulsación fuera la cierra y además llega al elemento que hay debajo. - La fila de estado queda debajo de las opciones y no se desplaza con ellas, de modo que un recuento o un fallo se mantienen a la vista.
- Antes de que el elemento esté definido, sus opciones son texto corrido. Oculta
tanrei-combobox-field:not(:defined) > *y reserva la altura. - La web no tiene un gesto de retroceso propio, así que
togglenunca lleva el motivoback.
| Aspecto | Campo de cuadro combinado | Select | Búsqueda | Campo de texto |
|---|---|---|---|---|
| Contiene | Un valor que se encuentra escribiendo | Un valor de una lista cerrada | Una consulta | Cualquier texto |
| Muestra las opciones | A medida que la persona escribe | Tras una pulsación | Sugerencias y resultados | No |
| Acepta un valor que no está en la lista | Con allowCustomValue |
No | Sí | Sí |
| Forma parte de un formulario | Sí | Sí | No | Sí |
- Con hasta unas cinco opciones cortas, muéstralas todas: botones de opción.
- Si la lista es lo bastante corta para recorrerla con la vista, y cerrada, es un select.
- Si las personas prefieren escribir a desplazarse, o si el campo acepta un valor que no está en la lista, es un campo de cuadro combinado.
- Si escribir lleva a lugares a los que ir y no a un valor, es una búsqueda.
- Varios valores son otro componente: un cuadro combinado guarda uno solo.
- Si la etiqueta está en otro lugar —un filtro en una barra de herramientas, una celda de una tabla—, es el cuadro combinado sin nada más, que recibe su nombre de su propio
label.
- Escribe una etiqueta que nombre lo que se elige, y mantenla visible en un formulario.
- Usa
allowCustomValuesolo donde un valor que no está en la lista sea una respuesta real. - Da
clearablea un campo de cuadro combinado cuyo valor pueda ser ninguno, y da nombre al botón conclearLabel. - Cuando cargues opciones, define
statusystatusTextpara que la lista diga que está esperando, cuántas muestra o que ha fallado. - Da
emptyText, en el campo de cuadro combinado o una sola vez para todo el producto consetWords({ emptyText }). Tanrei no incluye textos propios: sin él, un texto que no coincide con nada no dibuja ninguna fila, y la lista no tiene nada que mostrar.
- No uses el marcador de posición como etiqueta. Desaparece en cuanto la persona escribe.
- No guardes, navegues ni envíes con
input. Se emite con cada pulsación de tecla;changees el valor confirmado. - No trates un texto que no nombra ninguna opción como un error del campo. Se descarta cuando la persona sale. Si quieres decir «elige una opción de la lista», define tú
erroryerrorText. - No pongas un campo de cuadro combinado dentro de un campo. Ya es un campo; el control que un campo enmarca es el cuadro combinado.
- No abras la lista al recibir el foco en un formulario de muchos campos: en cada parada tapa los campos de debajo.
- Rol
combobox- Etiquetado
- The combobox field adds nothing to what its members expose and coordinates nothing: the Field gives the combobox its name, its description and its required, invalid and disabled states (FLD-8, FLD-10, FLD-11, FLD-14), and the combobox carries them on its own input, with its expanded state, its list and its active option (CMB-12, CMB-48). Assistive technology meets one editable combobox named by label, with a list of the same name, exactly as it meets a Field around a combobox written by hand.
- Objetivo mínimo
- El área de pulsación cumple el tamaño mínimo de objetivo aunque el tamaño visual sea menor. minimum 32px · pointer 44px · spacing 8px · touch 48px
Teclado
| Teclas | Acción |
|---|---|
| Every key | The combobox's (its accessibility block; CMB-16, CMB-20, CMB-21, CMB-26 to CMB-30). The combobox field handles no key and adds no focus stop (CBF-5). |
Notas
- One level down is the same thing: a Field with a combobox in it, holding the same options. Every fixture has that pair as its twin, and the accessibility tree of the two is the same (CBF-1).
- The options are the product's, and they are the combobox's: the combobox field passes them on and does nothing with them (CBF-2). Value, text and open are the combobox's too, and the combobox field keeps no second copy that could disagree with it (CBF-3).
- On the web the two members stand in the combobox field's own shadow root, so the form meets the combobox field and not the combobox (CBF-4); focus passes through to the input (CBF-5); and the product's option elements stay its own children, read by the combobox through a slot.
- A list is not a second thing the component reports: choosing an option is setting its one value, so the combobox field is composed, not a feature.
Generado a partir de specs/combobox-field.spec.json, tokens/sys/measure.tokens.json
- El campo de entrada es un cuadro combinado editable con un cuadro de lista. Su nombre es
label, tanto si se dibuja como si se oculta, y nunca el marcador de posición. El campo se lo da al cuadro combinado, que lo lleva en su propio campo de entrada. - El texto de apoyo o de error que se muestra es su descripción, junto con
optionalTextmientras el campo es opcional. - Un error que aparece mientras el foco está en el campo se anuncia una vez, de forma cortés.
- Se expone como no válido mientras
errores true, como obligatorio mientrasrequiredestá activado, como de solo lectura, y como expandido mientras su lista está abierta. - El foco permanece en el campo de entrada mientras la lista está abierta. La opción activa es su descendiente activo, de modo que escribir nunca deja de editar el texto. Una opción que la escritura convirtió en activa se señala cuando la escritura se detiene medio segundo, para que un lector de pantalla lea primero la letra escrita y después la opción que elegiría Enter; una opción a la que llevan las teclas de flecha se señala al instante.
- La lista es un cuadro de lista que recibe su nombre de la etiqueta. Cada opción tiene su nombre, su descripción, si es la elegida, si está deshabilitada y su posición entre las opciones que se muestran. Un grupo recibe su nombre de su título.
- Una coincidencia se marca con el peso, nunca solo con el color. La etiqueta se lee como un solo texto.
- La fila de estado es una región activa (live region): su texto se lee de forma cortés cuando cambia, y de inmediato cuando la fuente de datos ha fallado. Durante la carga, la lista se marca como ocupada y no se anuncia nada.
- Mientras un método de entrada está componiendo, el cuadro combinado no atiende ninguna tecla.
- El chevron es un botón para el puntero y para la exploración táctil, fuera del orden del foco. El teclado abre la lista con Flecha abajo.
- El botón de borrar es un botón que recibe su nombre de
clearLabel, y es la siguiente parada del foco después del campo de entrada. - Escape cierra la lista y no va más allá, de modo que un diálogo que rodee al cuadro combinado permanece abierto.
- El área de pulsación del campo cumple el objetivo mínimo, y las opciones son al menos tan altas como el objetivo mínimo.
- Con el texto al 200%, la etiqueta, la ayuda, las opciones, los títulos y la fila de estado saltan de línea. Solo el texto del campo de entrada se queda en una línea, y se desplaza.
- Con colores forzados, el campo y la lista ganan un borde, la opción activa toma los colores de resaltado y la opción elegida se muestra con su marca de verificación.
- En un diseño de derecha a izquierda, el campo y cada fila se reflejan, y cada texto conserva su propia dirección. El chevron, el glifo del botón de borrar y la marca de verificación no se reflejan.
Carencias conocidas en la web:
- El divisor entre dos grupos no se expone como separador: un cuadro de lista solo contiene opciones y grupos.
- El filtro iguala mayúsculas, ancho y signos diacríticos del mismo modo en todos los sistemas de escritura. No encuentra el hangul por su consonante inicial ni el kana por su lectura.
- Antes de que el elemento esté definido, las opciones son texto en la página, sin ningún control.
- Da un
labela cada campo de cuadro combinado, y a cada opción una etiqueta y un valor que no esté vacío. - Da un
clearLabela un campo de cuadro combinado que se pueda borrar. - Escribe
statusTexten el campo de cuadro combinado. DaemptyText,requiredText,optionalTextyclearLabelen el campo de cuadro combinado, o una sola vez para todo el producto consetWords(). Tanrei no incluye textos propios; si falta uno, se notifica en desarrollo. Consulta Los textos del producto. - Valida tú el valor, activa
errory escribeerrorTextde modo que diga cómo corregir la respuesta. - Mantén únicos los valores de las opciones dentro de un campo de cuadro combinado.