---
title: "حقل الرقاقات"
description: "يجمع قائمة من النصوص القصيرة، كعناوين البريد الإلكتروني وأرقام الهاتف والكلمات المفتاحية، تُكتب واحدًا بعد الآخر في حقل واحد. كل نص يقبله فحصك يصير رقاقة يمكن إزالتها، أو إعادتها إلى جزء الكتابة لتغييرها، والقائمة هي القيمة الواحدة للحقل."
url: "https://tanrei.chnotchy.com/ar/components/chip-field/"
last_updated: 2026-10-23T21:17:12.000Z
---

# حقل الرقاقات

> يجمع قائمة من النصوص القصيرة، كعناوين البريد الإلكتروني وأرقام الهاتف والكلمات المفتاحية، تُكتب واحدًا بعد الآخر في حقل واحد. كل نص يقبله فحصك يصير رقاقة يمكن إزالتها، أو إعادتها إلى جزء الكتابة لتغييرها، والقائمة هي القيمة الواحدة للحقل.

## نظرة عامة

استخدم حقل الرقاقات (chip field) حيث يُدخل الشخص عدة نصوص قصيرة من نوع واحد: مستلمو رسالة، أو الأشخاص الذين يُشارَك معهم مستند، أو الأرقام التي يُرسل إليها تنبيه، أو الكلمات المفتاحية لمقالة. يُفحص كل نص وحده، فالعنوان الواحد المكتوب خطأً بين اثني عشر عنوانًا لا يُضيع البقية، ويمكن إزالة كل مُدخلة أو تغييرها وحدها.

**يُبنى من** [حقل](https://tanrei.chnotchy.com/ar/components/field/) و[حقل إدخال النص](https://tanrei.chnotchy.com/ar/components/text-input/) و[رقاقات](https://tanrei.chnotchy.com/ar/components/chip/). الحقل هو الإطار: التسمية، وعلامة المطلوب أو الاختياري، والمساعدة، والخطأ. وحقل إدخال النص هو الصندوق والمكان الذي تُكتب فيه المُدخلة التالية. وكل مُدخلة رقاقة إدخال صغيرة تقف في الصندوق، قبل النص المكتوب. وحقل الرقاقات لا يرسم شيئًا من عنده وليس له أي رمز تصميم (token)، فيبدو كحقول النص التي بجانبه في كل نظام تصميم.

عرضه عرض المكان الذي يوضع فيه. والمُدخلات والنص المكتوب تقف في أسطر تلتفّ، ويكبر الصندوق بأسطر كاملة. وكل مُدخلة تُعرض: لا تُخفى واحدة منها، ولا تُطوى في عدد مثل «`+3`»، ولا تُمرَّر خارج مجال الرؤية.

على الويب هو `<tanrei-chip-field>`. والمنصات الأخرى لم تنفّذه بعد.

### الاستخدام

الخاصية `value` هي قائمة المُدخلات، مصفوفة من النصوص. والخاصية `inputValue` هي النص المكتوب الذي لم يصر مُدخلة بعد.

تُصنع المُدخلة من النص المكتوب:

- بالمفتاح Enter؛
- بفاصل تدرجه في `separators`. وليس هناك فاصل افتراضيًّا، لأن الفاصلة تنهي عنوان بريد إلكتروني وهي جزء من «Lovelace, Ada»؛
- حين يغادر التركيز الحقل؛
- من نص ملصوق فيه فاصل أو فاصل سطر: تُعرض كل قطعة على الفحص، بالترتيب.

لا يعرف Tanrei ما عنوان البريد الإلكتروني ولا ما رقم الهاتف. الخاصية `type` تختار لوحة المفاتيح ولا تفحص شيئًا. وكل نص مرشَّح يُعرض عليك بالحدث `check`: ارفضه، فيبقى في الصندوق نصًّا مكتوبًا والحقل يعرض خطأه. والنص نفسه مرتين، والنص الذي يتجاوز `maxEntries`، يُرفضان من غير أن تُسأل.

**Web**

```html
<form>
  <tanrei-chip-field name="to" label="المستلمون" type="email"
    supporting-text="افصل بين العناوين بفاصلة."
    invalid-text="أدخِل عنوانًا كاملًا، مثل name@example.com."
    duplicate-text="هذا العنوان موجود في القائمة سلفًا."
    remove-label="إزالة {entry}"
    added-text="تمت إضافة {entry}" added-count-text="عدد ما أُضيف: {count}" removed-text="تمت إزالة {entry}"></tanrei-chip-field>
</form>

<script type="module">
  import '@tanrei/web/components/chip-field';

  const to = document.querySelector('tanrei-chip-field');
  to.separators = [',', ';', ' '];
  // فحصك لمُدخلة واحدة، في سطر واحد. أجب قبل أن يعود الحدث.
  to.addEventListener('check', (e) => {
    if (!/^\S+@\S+\.\S+$/.test(e.detail.text)) e.preventDefault();
  });
  // غيّر الشخص القائمة. و `value` هي الآن القائمة الجديدة.
  to.addEventListener('change', (e) => save(e.detail.value));
</script>
```

**React**

```tsx
import { ChipField } from '@tanrei/react';

<ChipField name="to" label="المستلمون" type="email" separators={[',', ';', ' ']}
  supportingText="افصل بين العناوين بفاصلة."
  invalidText="أدخِل عنوانًا كاملًا، مثل name@example.com."
  removeLabel="إزالة {entry}" addedText="تمت إضافة {entry}" removedText="تمت إزالة {entry}"
  value={recipients}
  onCheck={(event) => { if (!isAddress(event.detail.text)) event.preventDefault(); }}
  onChange={(event) => setRecipients(event.detail.value)} />
```

لتقول سبب رفض واحد بكلماتك، عيِّن `event.detail.reason` في مستمع الحدث `check`. وإلا عرض الحقل `invalidText` أو `duplicateText` أو `limitText` بحسب السبب، و `errorText` حيث يكون ذلك فارغًا. والحدث `reject` يخبرك بكل نص مرفوض وبالسبب وبالكلمات المعروضة.

المُدخلة التي تجدها خاطئة فيما بعد، كعنوان يبلّغ خادم بأنه غير معروف، عليك أنت أن تبلّغ عنها: عيِّن `error` و `errorText`، وسمِّ المُدخلة في الكلمات. والشخص يزيلها، أو يعيدها إلى الكتابة ليغيّرها.

### تغيير مُدخلة

| الغاية | ما تفعله |
| --- | --- |
| الوصول إلى المُدخلات من جزء الكتابة | المفتاح Backspace، أو مفتاح السهم الذي يشير إلى بداية السطر، ومؤشر الكتابة في بداية النص |
| التنقل بين المُدخلات | مفتاحا السهم لليسار والسهم لليمين، والمفتاحان Home و End |
| إزالة مُدخلة | المفتاح Backspace أو Delete عليها، أو إجراء الإزالة فيها |
| تغيير مُدخلة | المفتاح Enter أو Space عليها، أو ضغطة على الرقاقة: يعود نصها إلى جزء الكتابة |
| العودة إلى جزء الكتابة | المفتاح Escape أو Tab، أو كتابة حرف |

الضغطة الأولى على Backspace تصل إلى المُدخلة الأخيرة لا غير. والضغطة الثانية تزيلها، والمفتاح الذي يبقى مضغوطًا يُستجاب له مرة واحدة، فمحو النص المكتوب لا يمتد أبدًا إلى القائمة.

### مستوى واحد إلى الأسفل

الحقل نفسه مكتوبًا باليد من أعضائه هو الصورة نفسها:

```html
<tanrei-field label="المستلمون" supporting-text="افصل بين العناوين بفاصلة.">
  <tanrei-text-input type="email">
    <tanrei-chip slot="entries" kind="input" size="small" label="ada@example.com"
      remove-label="إزالة ada@example.com"></tanrei-chip>
    <tanrei-chip slot="entries" kind="input" size="small" label="grace.hopper@example.org"
      remove-label="إزالة grace.hopper@example.org"></tanrei-chip>
  </tanrei-text-input>
</tanrei-field>
```

ما لا تفعله الأعضاء المكتوبة باليد هو ما يضيفه حقل الرقاقات:

| ما يضيفه حقل الرقاقات | باليد |
| --- | --- |
| صنع المُدخلة: المفتاح Enter، والفواصل، والمغادرة، والقوائم الملصوقة | تستمع إلى حقل إدخال النص وتقطّع النص |
| الفحوص وخطأ الإدخال | تعيّن `error` و `errorText` على الحقل |
| موضع توقف واحد للمفتاح Tab، والمفاتيح بين المُدخلات | كل رقاقة وكل إجراء إزالة موضع توقف مستقل؛ وأنت تزيل الرقاقة وتنقل التركيز |
| عرض المُدخلات للتقنيات المساعدة قائمةً واحدة، والإعلانات الثلاثة | تكتب إعلاناتك بنفسك |
| القائمة قيمةً واحدة في النموذج | حقول إدخال مخفيّة، أو إرسال من عندك |

انزل إلى هذا المستوى لترتيب لا يقدّمه حقل الرقاقات، كمُدخلات ليست رقاقات، أو أيقونة في الصندوق.

## المواصفات

### ما يعطيه كل عضو

| الجانب | من الحقل | من حقل إدخال النص | ما لحقل الرقاقات نفسه |
| --- | --- | --- | --- |
| الخصائص | `label`، `labelHidden`، `supportingText`، `errorText`، `error`، `disabled`، `required`، `optional`، `requiredMark`، `requiredText`، `optionalText` | `variant`، `size`، `type`، `placeholder`، `readOnly`، `autocomplete`، ثم `inputValue` (وهي `value` في حقل إدخال النص) | `value`، `separators`، `maxEntries`، `invalidText`، `duplicateText`، `limitText`، `removeLabel`، `addedText`، `addedCountText`، `removedText` |
| الأحداث | — | `input`، `action` | `change`، `check`، `reject` |
| المنافذ (slots) | `label-icon` | — | — |
| رموز التصميم | `comp.field.*` | `comp.input-box.*` للصندوق؛ و `comp.text-input.*` لمكان المُدخلات | لا شيء؛ والمُدخلات تقرأ `comp.chip.*` |

- **المُدخلات رقاقات صغيرة** في حجمي الصندوق كليهما. والمُدخلة الطويلة تأخذ سطرًا لها وحدها وتقصّها الرقاقة؛ ونصها الكامل يبقى اسمها وقيمتها. وإجراءات إزالتها عادية، كما هي في الرقاقة افتراضيًّا: فالمُدخلة المُزالة يمكن كتابتها من جديد.
- **النص النائب** لا يُعرض إلا ما دامت القائمة فارغة.
- **للقراءة فقط**: يمكن الوصول إلى المُدخلات وقراءتها، وهي تُرسل. ولا يمكن صنع مُدخلة ولا إزالتها ولا إعادتها إلى الكتابة، وكل رقاقة تُرسم بلا إجراء الإزالة. وينتهي الحقل بآخر سطر من رقاقاته: لا يحتفظ بمساحة للكتابة. أما الحقل المعطَّل فيحتفظ بتلك المساحة، ليكون له الشكل نفسه حين يُفعَّل من جديد.
- **معطَّل**: الحقل والصندوق وكل رقاقة معطَّلة، ولا يُرسل شيء.
- **الخاصية `maxEntries`** ترفض المُدخلة الزائدة، بنص `limitText`. ولا يُعطَّل شيء ولا يُعلَّم شيء مسبقًا: قل الحد في `supportingText`.
- **الخاصية `type`** قيمتها `text` أو `email` أو `tel` أو `url`. وأي نوع آخر يتصرف تصرف `text`.

### تخصيص حقل واحد دون غيره

ليس لحقل الرقاقات رمز تصميم خاص به. ولتغيير مثيل واحد، عيِّن رمز تصميم أحد الأعضاء عليه:

```html
<tanrei-chip-field label="المستلمون"
  style="--tanrei-comp-text-input-entries-row-gap: 12px"></tanrei-chip-field>
```

- Category: Text inputs
- Level: composed
- Listing: default
- Built from: Field, Text input, Chip
- Page: https://tanrei.chnotchy.com/components/chip-field/
- Spec: https://github.com/chnotchy/tanrei/blob/main/specs/chip-field.spec.json

### Availability

| Design system | Has it | Notes |
| --- | --- | --- |
| Tanrei (`tanrei`) | Yes | Variants left out: `filled`, `outlined`. |
| Cupertino (Apple HIG-inspired) (`cupertino`) | Yes | — |
| M3 Expressive-like (Material 3 Expressive-inspired) (`m3-expressive-like`) | Yes | — |
| M3-like (Material 3-inspired) (`m3-like`) | Yes | — |

### Platforms

- Web: the element `<tanrei-chip-field>`, registered by importing `@tanrei/web` (or only its own module, `@tanrei/web/components/chip-field`).
- React: `ChipField` from `@tanrei/react`.

| Platform | Name | Status |
| --- | --- | --- |
| Web | `tanrei-chip-field` | lagging |
| SwiftUI | `TanreiChipField` | planned |
| Jetpack Compose | `TanreiChipField` | planned |
| Flutter | `TanreiChipField` | planned |
| React Native | `ChipField` | planned |

Names a platform gives in its own idiom:

| Spec | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
| --- | --- | --- | --- | --- | --- |
| `value` (prop) | `value` | `entries` | `entries` | `entries` | `value` |
| `inputValue` (prop) | `inputValue` | `text` | `text` | `controller` | `text` |
| `type` (prop) | `type` | `contentType` | `keyboardType` | `keyboardType` | `inputMode` |
| `readOnly` (prop) | `readOnly` | `isReadOnly` | `readOnly` | `readOnly` | `readOnly` |
| `autocomplete` (prop) | `autocomplete` | `.textContentType(_:)` | `contentType` | `autofillHints` | `autoComplete` |
| `label` (prop) | `label` | `label` | `label` | `labelText` | `label` |
| `labelHidden` (prop) | `labelHidden` | `.labelsHidden()` | `labelHidden` | `labelHidden` | `labelHidden` |
| `supportingText` (prop) | `supportingText` | `supportingText` | `supportingText` | `helperText` | `supportingText` |
| `error` (prop) | `error` | `error` | `isError` | `error` | `error` |
| `disabled` (prop) | `disabled` | `.disabled(_:)` | `enabled` | `enabled` | `disabled` |
| `required` (prop) | `required` | `isRequired` | `required` | `required` | `required` |
| `optional` (prop) | `optional` | `isOptional` | `optional` | `optional` | `optional` |
| `change` (event) | `change` | `entries (Binding)` | `onEntriesChange` | `onChanged` | `onChange` |
| `input` (event) | `input` | `text (Binding)` | `onTextChange` | `controller (listener)` | `onChangeText` |
| `check` (event) | `check` | `check:` | `check` | `check` | `check` |
| `reject` (event) | `reject` | `onReject:` | `onReject` | `onRejected` | `onReject` |
| `action` (event) | `action` | `.onSubmit` | `onAction` | `onSubmitted` | `onSubmitEditing` |

Statuses: `planned` — In the inventory. Nothing shippable exists yet. `lagging` — An implementation of an earlier spec exists; it has not caught up with the current one. `alpha` — Implemented with tests. The API may still change. `beta` — Feature complete and at parity. Only fixes are expected. `stable` — Covered by semantic versioning. `deprecated` — Still shipped; scheduled for removal.

### Anatomy

- `field`: The Field: the label row with its glyph and its requirement mark, and the supporting row with the help and the error text. The Field's own, from the Field's tokens.
- `text-input`: The Text input the Field frames: the box, its states, the typing part, and the lines in which its entries and its typing part stand. The Text input's own, from the Text input's tokens.
- `chip` (optional): One entry of the list: an input Chip at its small size, with its remove action, standing in the Text input's box before the typing part. The Chip's own, from the Chip's tokens.

### Props

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `value` | `strings` | `` | `value` | The entries, in the order they were made: the one value the chip field holds. Each is a text; none is empty, and no two are the same text. The chip field writes it as the person makes, removes and takes back entries, and emits change; what the product sets is shown as given and is not checked (CHF-3). |
| `inputValue` | `string` | `""` | `input-value` | The text in the field; for date, time and date-time, the ISO 8601 form of what its segments give (2026-09-27, 14:30, 2026-09-27T14:30), or empty while a segment is empty or the value is not available. (From Text input: The text being typed that is not an entry yet. The chip field empties it when the text becomes an entry and writes it when an entry is taken back to be changed (CHF-15). It is never part of value and is never submitted.) |
| `separators` | `strings` | `` | `separators` | The texts that end an entry when they are typed or found in what is pasted, as the product names them for what its entries are: a comma, a semicolon and a space for e-mail addresses ([",", ";", " "]); a comma for keywords that may hold a space. Empty, the default: Enter and a line break alone make an entry, because Tanrei knows no grammar of entries and a name such as "Lovelace, Ada" must not be cut in two by a default. |
| `maxEntries` | `number` | `0` | `max-entries` | The most entries the list may hold; 0 is no limit. An entry that would exceed it is refused with the reason limit (CHF-10); the typing part stays usable. It never cuts a list the product sets. |
| `variant` | `enum`: `stacked`, `filled`, `outlined` | `"stacked"` | `variant` | Stacked is a filled box that shows focus and error with a line inside its edge and draws no label: the label of the Field that frames it stands above it. Filled and outlined float the label inside the box, marked by a tinted box and a bottom line, or by a border. Use one style per form. A design system may leave some out (the Tanrei system ships stacked only) or add values. (From Text input.) |
| `size` | `enum`: `small`, `medium`, `large` | `"medium"` | `size` | Minimum height of a single-line input's container: stacked 32 / 40 / 56, as tall as a Button of the same size, so that an input 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. Medium and large are for forms; small is for an input in an app bar, a toolbar or a dense row of controls, beside a small select or button. The hit area always meets the minimum target. (From Text input: The least height of the box: it grows by whole lines as entries wrap (CHF-18). The entries are small chips at either size.) |
| `type` | `enum`: `text`, `email`, `password`, `number`, `search`, `tel`, `url`, `code`, `date`, `time`, `date-time` | `"text"` | `type` | What the value is: chooses the keyboard, autocorrection, obscured entry and semantics. code is text written for a machine rather than for a reader — a snippet of configuration, a pattern, an identifier, a query, a key: a left-to-right run in the code face that the platform does not correct, capitalise, check for spelling or complete, on one line or, with multiline, on many. date, time and date-time are entered segment by segment in the locale's numeric form and held as ISO 8601. The value is a string for every type. (From Text input: What one entry is: it chooses the keyboard of the typing part and checks nothing. Only a type the Text input draws as one line of plain text is an entry of a list (text, email, tel, url); any other behaves as text (CHF-26).) |
| `placeholder` | `string` | `""` | `placeholder` | A hint shown while the value is empty and the label is not in the input line (above, floated or hidden). Never a replacement for label. In a code field it is an example of the code and is drawn as code (TXI-53, TXI-54); a hint in words belongs in the supportingText of its Field. Ignored by a date, time or date-time field, whose empty segments each show their own. (From Text input: Shown only while the list is empty and nothing is typed (CHF-17).) |
| `readOnly` | `boolean` | `false` | `readonly` | The value can be focused, selected and copied, but not changed. (From Text input: Also of the entries: none can be made, removed or taken back, and each is drawn without its remove action (CHF-20).) |
| `autocomplete` | `string` | `""` | `autocomplete` | The autofill hint, as an HTML autofill field name (email, current-password, new-password, one-time-code, tel, postal-code, …); each platform maps it to its own content type. A code field left without one asks the platform to offer no remembered entry (TXI-55). (From Text input: What the platform fills in is typed text: it becomes an entry as typed text does (CHF-8).) |
| `label` | `string` | `""` | `label` | 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. (From Field: Always given. It names the typing part and the list of entries (CHF-21).) |
| `labelHidden` | `boolean` | `false` | `label-hidden` | Does not draw the label, which stays the accessible name. For a control whose visible label is elsewhere (a table column, a toolbar). (From Field.) |
| `supportingText` | `string` | `""` | `supporting-text` | 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). (From Field: The place to say what an entry is and how one is made ("Separate addresses with a comma."): the chip field has no words for it.) |
| `errorText` | `string` | `""` | `error-text` | 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. (From Field: Also shown while an entry was refused and no text of its own reason is given (CHF-6).) |
| `error` | `boolean` | `false` | `error` | 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. (From Field: For a reason that is the product's: the list as a whole, or an entry found wrong after it was made. A refused entry needs no setting: the chip field shows that itself (CHF-6).) |
| `disabled` | `boolean` | `false` | `disabled` | Disables the control and draws the frame as disabled. Disable a framed control here, not on the control, so that its label follows. (From Field: Also disables every entry (CHF-19).) |
| `required` | `boolean` | `false` | `required` | 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. (From Field: asks for at least one entry (CHF-25).) |
| `optional` | `boolean` | `false` | `optional` | 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. (From Field.) |
| `requiredMark` | `enum`: `auto`, `tag`, `asterisk`, `none` | `"auto"` | `required-mark` | 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. (From Field.) |
| `requiredText` | `string` | `""` | `required-text` | 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. (From Field.) |
| `optionalText` | `string` | `""` | `optional-text` | 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. (From Field.) |
| `invalidText` | `string` | `""` | `invalid-text` | The error text shown while an entry was refused by the product's check and the check gave no reason of its own ("Enter a full address, such as name@example.com."). The product's, for this field: what makes an entry right differs from field to field, so it reads no word key. Empty, errorText is shown. |
| `duplicateText` | `string` | `""` | `duplicate-text` | The error text shown while an entry was refused because the list already holds the same text ("That one is already in the list."). Empty reads the product's words; with neither, errorText is shown. |
| `limitText` | `string` | `""` | `limit-text` | The error text shown while an entry was refused because the list holds maxEntries already ("No more can be added."). Empty reads the product's words; with neither, errorText is shown. |
| `removeLabel` | `string` | `""` | `remove-label` | The accessible name of each entry's remove action. The product writes the whole name in its own language and marks one place in it, {entry}, which the chip field fills with that entry's text ("Remove {entry}", "{entry}を削除"), because the remove action is an element of its own and two of them must be told apart (CHP-18, CHP-28). Empty reads the product's words. Required: with neither, the action is exposed without a name and that is reported. |
| `addedText` | `string` | `""` | `added-text` | The sentence assistive technology is told when one entry is made, with the place {entry} filled by its text ("{entry} added", "{entry}を追加しました"). Empty reads the product's words; with neither, nothing is said and that is reported (CHF-22). |
| `addedCountText` | `string` | `""` | `added-count-text` | The sentence assistive technology is told when several entries are made at once, from pasted text, with the place {count} filled by how many ("{count} added"). Empty reads the product's words; with neither, addedText is said for the last of them. |
| `removedText` | `string` | `""` | `removed-text` | The sentence assistive technology is told when an entry is removed, with the place {entry} filled by its text ("{entry} removed"). Empty reads the product's words; with neither, nothing is said and that is reported (CHF-22). |

### Events

| Event | Description |
| --- | --- |
| `change` | The list changed by the person: an entry was made, several were made from pasted text, one was removed, or one was taken back to be changed. Carries the new value, and what was added and what was removed. Not emitted when the product sets value. |
| `input` | The user changed the value; carries the new value. Emitted for every change, not when the product sets value. A date, time or date-time field emits it when its value changes — when its last segment is filled, a filled field is edited, or it is emptied — not for a segment that leaves the value empty. (From Text input: Of the text being typed, never of the list (CHF-16).) |
| `check` | Asked of the product once for each candidate entry, before it is made: carries the candidate's text and the entries so far. The product refuses the candidate by answering no — cancelling the event on the web, returning its answer from the callback elsewhere — and may give the reason in its own words; left unanswered, the candidate is accepted. Answered at once, never later. Not asked for what the product sets, nor for a candidate already refused as a duplicate or over the limit. |
| `reject` | A candidate entry was refused; carries its text, the reason (invalid: the product's check; duplicate: the list holds the same text; limit: the list holds maxEntries) and the words shown. Emitted once for each refused candidate. |
| `action` | The user pressed the keyboard's action key (Enter, Return, Go, Search, Done) in a single-line field. (From Text input: Only while the typing part is empty: the action key pressed on text makes an entry and emits no action (CHF-4, CHF-16).) |

### Slots

| Slot | Description |
| --- | --- |
| `label-icon` | A glyph before the label. (From Field.) |

### States

`enabled`, `disabled`, `hovered`, `focused`, `error`

### Accessibility

- Role: `textbox (the typing part), after a list of the entries`
- Labeling: label names the typing part (a text box) and the list of entries; the supporting text with, in error, the error text after it describes the typing part, with optionalText while optional is true — all through the Field (FLD-10, FLD-11). Each entry is a button named by its whole text, cut or not, and its remove action a button named by removeLabel with the entry in it. A refusal is said by the Field's error announcement; an entry made or removed by addedText, addedCountText and removedText in a polite live region. Every word is the product's.
- Minimum target size: yes

| Keys | Action |
| --- | --- |
| Tab / Shift+Tab | Moves focus to the typing part, the chip field's one stop, and on from it. From an entry, Tab moves to the typing part and Shift+Tab leaves the chip field backwards. |
| Enter | In the typing part with text: offers the text as an entry. With no text: the Text input's action key (on the web, asks for the form's submission). On an entry: takes it back into the typing part to be changed. |
| A separator the product lists | Offers the text before it as an entry; the separator itself is not kept. |
| Backspace | In the typing part with the caret at the start and nothing selected: moves focus to the last entry and removes nothing. On an entry: removes it; focus goes to the entry before it. A held key is answered once. |
| Delete | On an entry: removes it; focus goes to the entry after it, or to the typing part. |
| Left Arrow / Right Arrow | From the start of the typing part, the arrow that points to where the line starts moves focus to the last entry. Among entries, each arrow moves the way it points, in either layout direction; past the last entry focus returns to the typing part. |
| Home / End | On an entry: moves focus to the first or the last entry. In the typing part they are the caret's. |
| Space | On an entry: takes it back to be changed, as Enter does. In the typing part: a character, or a separator where the product lists it. |
| Escape | On an entry: moves focus to the typing part. |
| Any character | On an entry: moves focus to the typing part and types the character there. |

- One stop, not one for every entry: a person who moves through a form with Tab lands in the typing part, where entries are made, and passes a list of thirty addresses in one press. The entries are reached from there with the arrow keys or Backspace, and by pointer, touch and a screen reader's own navigation as the separate elements they are. This replaces, inside the chip field only, the stops a Chip has when it stands alone (CHP-23), which that sentence leaves to whatever holds the chips.
- A refused entry stays text. It is not drawn as a chip in an error state: the Chip has no such state, a refused chip would have to carry its reason somewhere a person who cannot see its color finds it, and the text is exactly what must be corrected — it is already under the caret. The error is the Field's: words in the supporting row, the invalid state on the typing part, announced once (WCAG 3.3.1, 3.3.3, 1.4.1).
- An entry the product finds wrong after it was made (an address that turns out not to exist) is the product's to report with error and errorText, naming the entry in words; the person removes it or takes it back to change it.
- Backspace takes two presses to remove the last entry — one to reach it, one to remove it — and a held key never reaches an entry, so that erasing typed text cannot run on into the list (WCAG 3.3.4 in spirit: a removal is deliberate).
- Activating an entry takes it back into the typing part. Nothing in its name says so, because Tanrei has no words: a product whose people need it said writes it in supportingText ("Press Enter on an address to change it").
- Targets: an entry is a small Chip, 24 high, whose own hit area and whose remove action's reach the minimum target (CHP-5, CHP-21); between two lines of entries those areas overlap and meet at the middle (CHF-30). Every pointer action has a key: Backspace and Delete remove, Enter takes back.
- Enter never submits a form while there is text to make an entry of; with an empty typing part it is the Text input's action key. Text that is typed and not yet an entry is not part of the value: it becomes an entry when focus leaves, and a product that submits by script while the field has focus reads inputValue.
- The text of an input method's composition is never cut into entries: the key that commits a composition commits it, and only then is the text read (CHF-7). A Japanese or Chinese ideographic comma is a separator only where the product lists it.
- A long entry is cut by the Chip with an ellipsis and keeps its whole text as its name; there is no tooltip. Taking it back shows it whole in the typing part.
- Forced colors: the chip field draws nothing of its own, so there is nothing of its own to lose.
- How a state looks is a value decision of the active design system; components read the state's tokens and never compute the effect themselves.

### Behaviour

Requirements in EARS form, each with its stable id.

- **CHF-1** THE chip field SHALL be a Field that frames one Text input, with every entry of value drawn as a Chip in the place the Text input keeps inside its box for what was entered already, before the typing part. It SHALL draw nothing of its own: the label row, the requirement mark, the supporting row and the error are the Field's (FLD-1 to FLD-8), the box, its states, its typing part and the lines its entries stand in are the Text input's, and each entry is the Chip's (CHF-2). THE chip field SHALL give the Text input and the Chips no look they do not have anywhere else, and SHALL read no token of its own. THE chip field SHALL be as wide as the place it stands in, and its Text input 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 (TXI-63); its entries wrap inside that width (CHF-18).
- **CHF-2** THE chip field SHALL draw each entry as a Chip of kind input, size small and the Chip's default variant, whose label is the entry's text and whose remove action is named by removeLabel with its place {entry} filled by that text (CHF-23), in the order of value, the first at the start of the first line. The Chip SHALL be drawn, measured, cut where it does not fit and answered as the Chip's own spec says (CHP-3, CHP-8 to CHP-10, CHP-16 to CHP-18, CHP-20, CHP-21, CHP-27, CHP-32); THE chip field SHALL give an entry no icon and no avatar.
- **CHF-3** WHEN the product sets value THE chip field SHALL show exactly those entries in that order, SHALL NOT ask the product's check about them, apply maxEntries to them or refuse one that is there twice, because the chip field checks what the person enters and the product what it sets, SHALL end an entry error (CHF-6), and SHALL NOT emit change, check or reject nor announce anything; an entry that is empty or only white space SHALL be left out and in debug builds reported. WHEN the product sets inputValue THE chip field SHALL show that text in the typing part and make no entry of it until the person does (CHF-4). IF an entry that has focus is no longer in the list the product set THE chip field SHALL move focus to the typing part.
- **CHF-4** WHILE the typing part holds text THE chip field SHALL offer that text, without the white space at its two ends, as a candidate entry (CHF-5) WHEN the person presses the keyboard's action key (Enter, Return, Done), WHEN a separator is entered (CHF-9), or WHEN focus leaves the chip field for another part of the product — not when focus moves between the typing part and an entry, and not when the window itself loses focus. A candidate that is empty after its ends are trimmed SHALL make no entry, SHALL empty the typing part and SHALL be refused to no one. The action key pressed on text SHALL NOT emit action and SHALL NOT submit a form: it has made an entry.
- **CHF-5** WHEN a candidate entry is offered THE chip field SHALL decide in this order, and stop at the first that refuses: IF value already holds the same text, compared character for character, it SHALL refuse the candidate with the reason duplicate; IF maxEntries is greater than 0 and value holds that many entries it SHALL refuse it with the reason limit (CHF-10); otherwise it SHALL emit check with the candidate and the entries so far and, IF the product refuses it there, refuse it with the reason invalid and the words the product gave, if any. A check that no one answers accepts. THE chip field SHALL wait for no answer that comes later: the product answers check before the event returns. WHEN the candidate is accepted THE chip field SHALL add it at the end of value, empty the typing part of it, keep focus where it is, end an entry error (CHF-6), emit change once with the new list, and announce the entry (CHF-22).
- **CHF-6** WHEN a candidate entry is refused THE chip field SHALL leave its text in the typing part as the person wrote it, with the caret at its end WHILE focus is still there, SHALL NOT add it to value, and SHALL enter an entry error: WHILE it lasts THE chip field SHALL be in the Field's error condition whatever error is (FLD-8), showing as the Field's error text, where FLD-31 puts it (FLD-28), the first of these that is not empty — the words the product's check gave; invalidText, duplicateText or limitText, by the reason; errorText — and SHALL emit reject once with the text, the reason (invalid, duplicate or limit) and the words shown. The Field announces those words as it announces any error under the person's focus (FLD-9), and the chip field SHALL announce nothing more for a refusal. WHERE none of those words is given THE chip field SHALL still mark the typing part invalid and in debug builds report that a refusal has no words. THE entry error SHALL end WHEN the person changes the text in the typing part, WHEN an entry is made, removed or taken back, or WHEN the product sets value or inputValue; it SHALL NOT end because focus leaves, SHALL NOT bring focus back to a field the person left, and SHALL NOT change error, which is the product's.
- **CHF-7** WHILE an input method is composing text in the typing part (TXI-4) THE chip field SHALL make no entry: the action key that commits a composition SHALL commit the composition and nothing else, and a separator inside text that is still being composed SHALL be left to the input method. WHEN the composition is committed THE chip field SHALL read the committed text for separators as it reads any entered text (CHF-9).
- **CHF-8** WHEN text that holds a line break or a separator is pasted, dropped or dictated into the typing part, or filled in by the platform, THE chip field SHALL read it together with the text already there as a row of candidates — cut at every line break and at every separator — and offer each in order (CHF-5), dropping the empty ones without a word; the accepted ones SHALL become entries in that order, change SHALL be emitted once for all of them, and they SHALL be announced once (CHF-22). The refused ones SHALL stay in the typing part in their order, joined by the first of separators followed by a space, or by one space WHERE separators is empty, and THE chip field SHALL enter the entry error of the first that was refused and emit reject for each. A piece after the last line break or separator SHALL be offered with the others when the text was pasted, dropped or filled in, and SHALL stay as typed text when it was typed. Text that holds neither SHALL be the Text input's own to take: it stays typed text and makes no entry.
- **CHF-9** THE chip field SHALL take as separators the texts separators lists, and always a line break. WHEN a separator comes to stand in the typing part by any means the person has — a key, a touch keyboard, a committed composition, dictation — THE chip field SHALL offer the text before it as a candidate (CHF-4), SHALL NOT keep the separator in the typing part or in the entry, and SHALL keep the text after it as typed text; a separator entered while nothing but white space stands before it SHALL be dropped and make no entry. It SHALL find a separator in the text and not by the key that was pressed, so that a keyboard that reports no key still ends an entry. An entry of separators that is empty SHALL be ignored and in debug builds reported; white space is a separator only where the product lists it.
- **CHF-10** WHILE maxEntries is greater than 0 and value holds that many entries THE chip field SHALL keep its typing part focusable and editable, SHALL refuse every candidate with the reason limit (CHF-5, CHF-6), and SHALL NOT disable, hide or mark anything beforehand: that the list is full is said by the product in supportingText and by limitText when one more is tried. WHEN maxEntries is not a whole number of 0 or more THE chip field SHALL behave as 0 and in debug builds report it. THE chip field SHALL draw no count of its entries.
- **CHF-11** THE chip field SHALL be one stop in the focus order: its typing part. WHILE it holds entries THE chip field SHALL take each Chip and each remove action out of the Tab order, in place of the stops CHP-23 gives a chip that stands alone, and SHALL keep each entry reachable from the keyboard by the keys of CHF-12 and CHF-13, by pointer and touch, and as an element of its own by assistive technology. WHILE an entry has focus Tab SHALL move focus to the typing part and Shift+Tab to what stands before the chip field. A press on the box outside every entry SHALL move focus to the typing part as the Text input says (TXI-8); a press on the label does what the Field says (FLD-12).
- **CHF-12** WHILE the typing part has focus, its caret stands at the start of its text and nothing in it is selected, WHEN the person presses the arrow key that points to where the line starts (Left Arrow; Right Arrow in a right-to-left layout) or Backspace THE chip field SHALL move focus to the last entry and remove nothing; WHILE value is empty it SHALL leave the key to the Text input. THE chip field SHALL NOT answer the repeats of a key that is held down: a Backspace held to erase the typed text SHALL stop at the start of the text and never reach an entry.
- **CHF-13** WHILE an entry has focus THE chip field SHALL move focus, without activating or removing anything: on Left Arrow to the entry drawn before it on the left and on Right Arrow to the one drawn after it on the right — in a right-to-left layout the same two keys the other way, so that an arrow always moves the way it points — on Home to the first entry and on End to the last; the arrow that points past the last entry SHALL move focus to the typing part with the caret at the start of its text, the arrow that points before the first entry SHALL do nothing, and focus SHALL NOT wrap. Up Arrow and Down Arrow SHALL do nothing: the entries are one row in their order, however many lines it is drawn on. Escape SHALL move focus to the typing part. WHEN the person types a character while an entry has focus THE chip field SHALL move focus to the typing part and that character SHALL be typed there. Focus that arrives on an entry from the keyboard SHALL show the Chip's focus ring (CHP-4) and bring the entry into view.
- **CHF-14** WHEN an entry's Chip emits remove — Backspace or Delete on the focused entry (CHP-19), or its remove action by pointer, touch or assistive technology (CHP-18) — THE chip field SHALL take that entry out of value, as CHP-22 leaves it to do, end an entry error (CHF-6), emit change once with the new list, and announce the removal (CHF-22). It SHALL then move focus: after Backspace to the entry that stood before the removed one, or to the one that followed WHERE it was the first; after Delete or the remove action to the entry that followed, always on the Chip and never on a remove action; and to the typing part WHERE no entry is left or none follows. THE chip field SHALL NOT answer the repeats of a held Backspace or Delete, so that one press removes one entry.
- **CHF-15** WHEN the person activates an entry's Chip itself — by pointer, touch, Enter or Space (CHP-1), not its remove action — and readOnly is false THE chip field SHALL take the entry back to be changed: it SHALL first offer any text in the typing part as a candidate (CHF-4) and, IF that is refused, do nothing more than CHF-6 says; otherwise it SHALL take the entry out of value, write its text into the typing part with the caret at its end, move focus there, and emit change once with the new list. The text is then typed text like any other: it becomes an entry again, at the end of the list, as CHF-4 says, and is checked again. THE chip field SHALL announce nothing for it: the typing part, focused with its text, is what assistive technology reads.
- **CHF-16** WHEN the person presses the action key while the typing part is empty THE chip field SHALL leave the key to the Text input, which emits action and, on the web, asks for the form's submission (TXI-3); WHEN the person changes the text in the typing part THE chip field SHALL emit input with the new text as the Text input does. THE chip field SHALL emit change only for a change of its list by the person (CHF-5, CHF-8, CHF-14, CHF-15), never for typed text, and never when focus leaves with nothing made.
- **CHF-17** WHILE value holds an entry THE chip field SHALL give the Text input no placeholder, so that a hint for the first entry does not stand after the last; WHILE variant is filled or outlined and value holds an entry the Text input shows its label floated, as it does for a value that is not empty (TXI-13), and THE chip field SHALL hide the Field's label row in those two looks as the text field does.
- **CHF-18** THE chip field SHALL show every entry it holds: it SHALL NOT hide an entry, stand a count in the place of some, scroll its lines or limit its height. The entries and the typing part stand in lines that wrap inside the box, which grows by whole lines from the height of its size, as the Text input says of its entries; an entry whose text is wider than a line SHALL have that line to itself and be cut by the Chip's own rule (CHP-17), its whole text staying its accessible name and its value. WHEN entries come, go or change the lines THE chip field SHALL keep focus where it is and add no motion of its own.
- **CHF-19** WHILE disabled is true THE chip field SHALL disable the Field, and through it the Text input (FLD-14, TXI-5), and every entry's Chip (CHP-2, CHP-6): nothing in it SHALL take focus, no entry SHALL be made, removed or taken back, and it SHALL emit no event; its entries SHALL stay drawn and readable to assistive technology as disabled, and it SHALL be left out of form submission.
- **CHF-20** WHILE readOnly is true and disabled is false THE chip field SHALL make no entry, remove none and take none back: the typing part is the Text input's read-only one (TXI-10), each entry SHALL be drawn as an input Chip without a remove action, a press or a key on an entry SHALL move focus and do nothing else (CHF-13), Backspace and Delete on an entry SHALL do nothing, and check, reject and change SHALL NOT be emitted. The entries SHALL stay reachable by the keys of CHF-12 and CHF-13 so that each can be read, and the list SHALL be submitted with its form.
- **CHF-21** THE chip field SHALL expose to assistive technology, in this order: the entries as one list named by label, each entry an item that holds its Chip — a button named by the entry's whole text — and beside it its remove action, a button named by removeLabel (CHF-2); then the typing part, a text box named by label and described by what the supporting row shows, invalid WHILE the field is in error or in an entry error and required WHILE required is true, all given by the Field (FLD-8, FLD-10, FLD-11). WHILE value is empty it SHALL expose no list. It SHALL add no role, role description or word of its own for being a field of several entries: what an entry is and how one is made is the product's to say in supportingText.
- **CHF-22** THE chip field SHALL hold one live region of its own, polite, empty at rest and not drawn. WHEN one entry is made (CHF-5) it SHALL put into it addedText with {entry} filled by the entry's text; WHEN several are made at once (CHF-8) addedCountText with {count} filled by how many, written as the platform writes a whole number in the language of the field, or addedText for the last of them WHERE addedCountText is not given; WHEN an entry is removed (CHF-14) removedText with {entry} filled by its text. An entry's text SHALL be put into the sentence as plain text of its own direction, isolated from it. A later sentence SHALL replace what the region holds and SHALL NOT queue behind it. THE chip field SHALL announce nothing when the product sets value, when an entry is taken back (CHF-15), or when one is refused (CHF-6: the Field says it).
- **CHF-23** THE chip field SHALL have no words of its own: it SHALL take requiredText and optionalText as the Field does (FLD-24), and duplicateText, limitText, removeLabel, addedText, addedCountText and removedText from the instance's prop and, WHILE that is empty, from the product's words under the key each names, and from nowhere else; invalidText is the instance's alone. It SHALL fill the places {entry} and {count} as a word with places is filled — wherever and however often the product's sentence has them, any other text between braces and a brace that opens or closes nothing left as it is written and in debug builds reported once per page or screen, naming the prop, and a brace written twice drawn as one brace — SHALL say or name with a sentence that has no place exactly as it is written, and in debug builds SHALL report a removeLabel without {entry}, because two remove actions would then have one name. IF neither gives removeLabel THE chip field SHALL still draw the remove action and keep it working, expose it without a name and in debug builds report it; IF neither gives addedText or removedText it SHALL say nothing for that and in debug builds report it.
- **CHF-24** WHERE the platform has forms that collect named values (the web's form) THE chip field SHALL take part in one itself, under its name, as a control that holds several values does: it SHALL submit one value for each entry, in the order of value, each under that same name, and none WHILE the list is empty; SHALL NOT submit the text in the typing part, which is not an entry; SHALL return to the list it was first given WHEN the form is reset, with an empty typing part and no entry error; and SHALL have the platform restore its list where it restores a form's state. Its members stand outside the form and SHALL submit nothing themselves.
- **CHF-25** WHILE required is true THE chip field SHALL expose its typing part as required (FLD-4, FLD-10) and, on the web, report an empty list to the form's constraint validation as a missing value — whatever text stands in the typing part, which is not an entry. THE chip field SHALL NOT validate otherwise because of required: it SHALL NOT set error or show an error text for an empty list, which is the product's to report.
- **CHF-26** THE chip field SHALL take from type only what the Text input gives its typing part for it (TXI-20) and SHALL hold no rule of its own for what an address, a number or a link is: a text of any type becomes an entry unless it is the same as another, exceeds maxEntries or is refused by the product's check (CHF-5). WHEN type names a value other than text, email, tel and url — a type the Text input draws as something else than one line of plain text, or one it does not know — THE chip field SHALL behave as text and in debug builds report it; WHEN variant or size names a value the active design system does not have, the Text input says what is drawn.
- **CHF-27** WHERE the layout direction is right-to-left THE chip field SHALL be mirrored as its members are (FLD-18, TXI-24, CHP-25): every line of entries starts at the right, the typing part follows the last entry to its left, and the order of value, of focus (CHF-13) and of reading (CHF-21) stays the order the entries were made in. THE chip field SHALL take its layout direction from where it is used and have no direction setting of its own (FLD-19); each entry's text keeps its own direction as the Chip says (CHP-31), so that an e-mail address or a telephone number reads left to right inside a right-to-left list.
- **CHF-28** WHILE the text size is enlarged THE chip field SHALL grow with its members (FLD-16, CHP-17): at twice the text size in a place 320 wide every entry SHALL still be shown, each on a line of its own where two no longer fit, cut only by the Chip's own rule with its whole text as its name, the typing part SHALL stay wide enough to type in on a line of its own where the last line leaves it too little, and nothing SHALL lie over another part or need scrolling in two directions.
- **CHF-29** WHERE the platform draws with a person's own forced colors THE chip field SHALL draw nothing of its own there either: the frame is drawn as the Field says (FLD-17) and the box and each entry as the Text input and the Chip are drawn there. It SHALL rely on no color to tell a refused entry from an accepted one: a refused entry is text in the typing part and an accepted one is a Chip, and the reason is in words (CHF-6).
- **CHF-30** WHILE disabled is false and readOnly is false THE chip field SHALL keep every entry's hit areas as the Chip gives them (CHP-5, CHP-21): the remove action's reaches sys.target.touch for touch input and sys.target.pointer for fine pointers, and WHERE the hit areas of neighbouring entries, on one line or on two, overlap THE chip field SHALL give a press on an entry's visible bounds to that entry and a press between two to the nearer one. A press that lands on no entry and no remove action SHALL be the typing part's (CHF-11).
- **CHF-31** 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 chip 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 chip field is invalid — except those the chip field owns (aria-label, aria-labelledby, aria-disabled), which it SHALL move and not expose: its name is label (CHF-21). 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 chip field SHALL take it off that element. WHEN the product sets an aria- attribute the chip field owns THE chip field SHALL report it in debug builds.

### Tokens

As written in the token documents (DTCG): an alias in braces names the token it takes its value from, which each design system resolves. On the web each token is a CSS custom property: `--tanrei` and the name after `tanrei`, joined by hyphens (`tanrei.comp.field.…` → `--tanrei-comp-field-…`).

#### `tanrei.comp.field`

| Token | Type | Value |
| --- | --- | --- |
| `comp.field.label.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.label.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.label-icon.size` | `dimension` | `{tanrei.sys.icon.small}` |
| `comp.field.label-icon.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.mark` | `number` | `{tanrei.sys.behavior.requirement-mark}` |
| `comp.field.requirement.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.asterisk-gap` | `dimension` | `{tanrei.sys.space.space25}` |
| `comp.field.supporting-text.typescale` | `typography` | `{tanrei.sys.typescale.label-small}` |
| `comp.field.supporting-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.counter.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.motion.state-duration` | `duration` | `{tanrei.sys.motion.role.state.default}` |
| `comp.field.motion.state-easing` | `cubicBezier` | `{tanrei.sys.motion.easing.state}` |
| `comp.field.standard.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.error.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error-text.color` | `color` | `{tanrei.sys.color.error}` |
| `comp.field.value-text.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.value-text.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.error-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.error-text.placement` | `number` | `0` |

Per-state tokens, valued by the design system's pattern rules (not written by hand):

- `comp.field.<variant>.<state>.<property>` for the variants `standard`, the states `focused`, `disabled` and the properties `label.color`, `label-icon.color`, `supporting-text.color`, `required-asterisk.color`, `error.label.color`, `error.label-icon.color`, `error.supporting-text.color`, `error.required-asterisk.color`, `counter.color`, `error.counter.color`, `value-text.color`, `error.value-text.color`, `error-text.color`.

### ما يرسمه الويب بطريقة مختلفة

- جذر الظل (shadow root) في العنصر فيه عنصر `<tanrei-field>` بداخله عنصر `<tanrei-text-input>`، وعنصر `<tanrei-chip>` لكل مُدخلة في المنفذ `entries` من حقل إدخال النص. واستيراد العنصر يعرّف الثلاثة.
- الخاصية `value` مصفوفة: أسنِد مصفوفة جديدة لتغيّرها. وخاصية HTML (attribute) `value` تُقرأ مرة واحدة، مصفوفة JSON من السلاسل النصية، وهي ما تعود إليه إعادة ضبط النموذج. والخاصية `separators` مصفوفة أيضًا؛ وخاصية HTML المقابلة لها مصفوفة JSON.
- العنصر مرتبط بالنماذج (form-associated). يرسل قيمة لكل مُدخلة تحت `name`، بالترتيب، ولا يرسل شيئًا ما دامت القائمة فارغة أو الحقل معطَّلًا. والنص المكتوب لا يُرسل أبدًا. ويتبع عنصر `<fieldset>` المعطَّل، ويُستعاد عند التنقل، ويبلّغ بأن القيمة ناقصة ما دامت `required` معيَّنة والقائمة فارغة.
- الأحداث `change` و `check` و `reject` من النوع CustomEvent ويرسلها العنصر: وفي `detail` لها، على الترتيب، `{ value, added, removed }` و `{ text, values }` و `{ text, reason, message }`. والحدث `check` قابل للإلغاء ويُقرأ حين يعود: فالجواب الذي يُعطى بعد ذلك لا يُقرأ.
- الحدثان `input` و `action` هما حدثا حقل إدخال النص نفسه. والحدث `action` لا يصدر إلا بالمفتاح Enter وجزء الكتابة فارغ، ويطلب عندئذ إرسال النموذج. والمفتاح Enter على نص يصنع مُدخلة: يُوقَف المفتاح قبل أن يسمعه حقل إدخال النص، فمستمع `keydown` في طور التصاعد (bubbling) لا يسمع تلك الضغطة.
- الأجزاء: `field` و `text-input` و `chip` هي الأعضاء. وأجزاء الحقل وحقل إدخال النص تحتفظ بأسمائها (`label`، `supporting-text`، `container`، `input`، `entries`، وهكذا). وأجزاء الرقاقة هي `entry-container` و `entry-label` و `entry-remove`.
- العنصر نفسه غير قابل للتركيز وليس له دور: فالدالة `focus()` تذهب إلى جزء الكتابة. سمِّه بالخاصية `label`، ولا تسمِّه أبدًا بالخاصية `aria-label`.
- يُقرأ النص بحثًا عن الفواصل حين يتغيّر، لا من المفتاح الذي ضُغط أبدًا، فلوحة مفاتيح اللمس والإملاء ينهيان المُدخلة أيضًا. وما دام أسلوب الإدخال يركّب نصًّا لا يُصنع شيء: المفتاح الذي يعتمد التركيب يعتمده، وعندئذ فقط يُقرأ النص.
- خصائص HTML مكتوبة بصيغة kebab-case، مثل `input-value` و `max-entries` و `remove-label` و `added-count-text`. أما `readonly` و `autocomplete` فتحتفظان باسميهما في HTML.
- قبل أن يُعرَّف العنصر لا يكون له حجم ولا يعرض شيئًا. احجز ارتفاع الصندوق. والصفحة التي يجب أن تأخذ قائمة بلا سكربت تستخدم عنصر `<input>` أو `<textarea>` عاديًّا وتقطّع النص على خادمها.

## الإرشادات

### حقل الرقاقات، أم مربع التحرير والسرد، أم مجموعة الوسوم

| تحتاج إلى | استخدم |
| --- | --- |
| قائمة من نصوص يكتبها الشخص، ويُفحص كلٌّ منها وحده | حقل الرقاقات |
| اختيار من خيارات عند المنتج | [مربع التحرير والسرد](https://tanrei.chnotchy.com/ar/components/combobox/). فليس لحقل الرقاقات قائمة اقتراحات |
| مجموعة من الوسوم أو الرقاقات قائمة بذاتها، بلا كتابة ولا قيمة في نموذج | [مجموعة الوسوم](https://tanrei.chnotchy.com/ar/components/tag-group/) |
| بضع مُدخلات طويلة تحتاج كلٌّ منها إلى تسمية | [مجموعة حقول](https://tanrei.chnotchy.com/ar/components/field-group/) من حقول النص |
| نص واحد، مهما طال | [حقل النص](https://tanrei.chnotchy.com/ar/components/text-field/) |

### افعل

- قل في `supportingText` ما المُدخلة وكيف تُصنع: «افصل بين العناوين بفاصلة.»
- لا تدرج في `separators` إلا ما لا يمكن أبدًا أن يكون جزءًا من مُدخلة. ولأسماء مثل «Lovelace, Ada» لا تدرج شيئًا.
- اكتب `removeLabel` وفيها الموضع `{entry}`، فلا يشترك إجراءا إزالة في اسم واحد أبدًا.
- أعطِ `invalidText` بكلمات تقول كيف تبدو المُدخلة الصحيحة.
- قل الحد في `supportingText`، وما يحدث عنده في `limitText`.

### لا تفعل

- لا تضع حقل رقاقات داخل حقل. فهو حقل أصلًا.
- لا تعتمد على `type="email"` لفحص عنوان. فهي تختار لوحة المفاتيح ولا شيء غير ذلك.
- لا تجب عن الحدث `check` فيما بعد. والمُدخلة التي يرفضها خادم يُبلَّغ عنها بالخاصيتين `error` و `errorText`.
- لا تقرأ النص المكتوب جزءًا من القيمة. فهو يصير مُدخلة حين يغادر التركيز؛ والمنتج الذي يرسل بسكربت والتركيز على الحقل يقرأ `inputValue`.

## إمكانية الوصول

### ما يتكفل به المكوّن

- تلقى التقنيات المساعدة قائمة تسمّيها التسمية، فيها عنصر لكل مُدخلة: زر يسمّيه نص المُدخلة كاملًا، وإجراء الإزالة فيها، وهو زر تسمّيه `removeLabel` وفيها المُدخلة. وبعد القائمة يأتي جزء الكتابة، وهو مربع نص (text box) تسمّيه التسمية وتصفه المساعدة أو الخطأ.
- الحقل موضع توقف واحد للمفتاح Tab، أيًّا كان عدد المُدخلات التي يحملها. ويوصل إلى المُدخلات بمفاتيح الأسهم أو بالمفتاح Backspace، وبالمؤشر واللمس وبتنقل قارئ الشاشة نفسه.
- المُدخلة المرفوضة تبقى نصًّا في جزء الكتابة، حيث مؤشر الكتابة (caret)، والسبب مكتوب بالكلمات في خطأ الحقل، وهو يُعلَن مرة واحدة. واللون لا يفرّق أبدًا بين مُدخلة مرفوضة ومُدخلة مقبولة.
- المُدخلة التي تُصنع، وعدة مُدخلات تُصنع دفعة واحدة، والمُدخلة التي تُزال، تُقال كلٌّ منها في منطقة حيّة (live region) بتهذيب، بجُملك أنت.
- الإزالة مقصودة: المفتاح Backspace يحتاج إلى ضغطتين، والمفتاح الذي يبقى مضغوطًا يُستجاب له مرة واحدة.
- الاتجاه يتبع المكان الذي يُستخدم فيه الحقل. ففي تخطيط من اليمين إلى اليسار تبدأ الأسطر من اليمين، ومفاتيح الأسهم تظل تتحرك في الاتجاه الذي تشير إليه. والعنوان الذي في الداخل يحتفظ باتجاهه.
- عند تكبير النص إلى 200% في مكان ضيق تبقى كل مُدخلة معروضة، ويأخذ جزء الكتابة سطرًا خاصًّا به حيث يترك له السطر الأخير أقل مما يكفي.

فجوات معروفة على الويب: ما تقوله قارئات الشاشة قُرئ من أشجار إمكانية الوصول في المتصفحات، ولم يُسمع بقارئ شاشة.

### ما عليك فعله

- أعطِ `label` دائمًا.
- أعطِ `removeLabel` و `addedText` و `removedText`، على العنصر أو مرة واحدة ضمن كلمات المنتج. فمن دونها لا يكون لإجراءات الإزالة اسم ولا يُعلَن شيء.
- قل في `supportingText` كيف تُصنع المُدخلة. وحيث يحتاج الناس إلى أن يعرفوا أن المفتاح Enter على مُدخلة يغيّرها، قل ذلك أيضًا.
- قل لماذا رُفضت المُدخلة بكلمات تقول كيف تُصلَح.
