التخطّي إلى المحتوى
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
البدءWebReactSwiftUIJetpack ComposeFlutterReact Nativeالإعدادات الجاهزةنظام التصميم الخاص بكاستخدام Tanrei مع وكلاء الذكاء الاصطناعيالعلامة التجاريةرموز التصميمأنظمة التصميم والتخصيصTheme Studioاللونالطباعةالأيقوناتالشكلالارتفاعالحركةحالات التفاعلالسلوكالتخطيطإمكانية الوصولالكلماترموز الألوانرموز السلّم الطباعيرموز الشكلرموز الارتفاعرموز الحركةرموز الحالةرموز التباعد والقياسالمكوّناتالزرزر الإجراء الرئيسيالزر المقسَّممجموعة الأزرارزر مع قائمةشريط الأدواتزر النسخخانة الاختيارزر الاختيارمفتاح التبديلالرقاقةقائمة الخياراتشريط التمريرحقل شريط التمريرالتقويمDateTimePickerمجموعة الحقولمجموعة أزرار الاختيارمجموعة خانات الاختيارعنصر الاختيارحقل الاختيارشريط القوائمرفع الملفاتمنتقي الملفات متقدّمساحة الإفلاتحقل إدخال النص متقدّمحقل النصحقل الرقاقاتالحقلمربع التحرير والسرد متقدّمحقل التحرير والسردحقل إدخال العدد متقدّمحقل العددحقل إدخال اللون متقدّمحقل اللونحقل إدخال الرمز لمرة واحدة متقدّمحقل الرمز لمرة واحدةحقل إدخال النص المدمج متقدّممربع كتابة الرسائلالبطاقةالفاصلالطبقة النمطية متقدّممربع الحوارالقائمة (list)صف القائمةاللوحة السفليةاللوحة الجانبيةالعرض الدوّاركتلة الشيفرةالجدولاللوحة المنبثقةالخطواتالأكورديونقائمة الوصفالشكل التوضيحيهيكل التطبيقرأس الصفحةالعرض الشجريالخط الزمنيمعاينة الصورمقبض تغيير الحجمالإطار القابل لتغيير الحجممنطقة التمريرالشارةمؤشر التقدمالعدّادعارض الأرقام المتحرّكمؤشر التحميلشريط الإشعار (Snackbar)التلميحاختصار لوحة المفاتيحالوسمالشيفرة المضمَّنةالتنويهالصورة الرمزيةالحالة الفارغةمجموعة الوسومهيكل التحميلعنصر الملفمربع اللونالنص المتحركعلامات التبويبعرض التبويباتشريط التطبيقشريط التنقلدرج التنقلالبحثالرابطالتنقل بين الصفحاتروابط السابق والتاليمؤشر الخطواتمسار التنقلجدول المحتوياتبطاقة الرابطقائمة FABالحالةكيف يُبنى Tanreiالمساهمةالترخيص والإسناد
الرئيسيةالمكوّناتالبحث

البحث

شريط بحث، أو مشغِّل مدمج له، يقدّم اقتراحات ونتائج والأشخاص يكتبون، في عرض مُرسى تحت الشريط أو في مربع حوار أو فوق الشاشة كلها.

content_copyعرض بتنسيق Markdown
الفئة
التنقل
الرموز
comp.search
المستوى
ميزة
مبني من
Modal layer

نظرة عامة

Web
tanrei-search
schedule
SwiftUI
TanreiSearch
schedule
Jetpack Compose
TanreiSearch
schedule
Flutter
TanreiSearch
schedule
React Native
Search
schedule

مولَّد من docs/status/status.json, specs/search.spec.json

مواصفة معدَّلة، لم تصل إلى كل المنصات بعد

تصف هذه الصفحة البحث كما هو في المواصفة الآن، بحثًا في موقع أيضًا: مشغِّل (trigger) مكان الشريط، وعرض في مربع حوار، ونتائج هي روابط، ثم صف للحالة، واختصار. مكوّن الويب يفعل ذلك كله، وكذلك العروض التوضيحية. أما SwiftUI و Compose و Flutter و React Native فموسومة أعلاه بأنها متأخرة: إلى أن تلحق بالمواصفة تقدّم المراجعة السابقة، وهي الشريط مع حقل إدخاله، والعرضان المُرسى وملء الشاشة، والاقتراحات، وعيّناتها تعرض تلك المراجعة.

فارغ، ومع استعلام، ومع أزرار أيقونات

menumicaccount_circle

بحث في موقع: مشغِّل في هيئة زر مع اختصاره، ومشغِّل أيقونة، وشريط يعرض اختصاره. اضغط مشغِّلًا ليُفتح عرضه

اقتراحات تحت صف الاستعلام، والإكمال داخل الحقل. اكتب فات ثم تنقّل بمفاتيح الأسهم

الاستخدام

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

شريط أو مشغِّل. الخاصية bar تقول ما الذي يقف حيث يوضع البحث:

  • field (الافتراضي): الشريط مع حقل إدخاله.
  • button: مشغِّل في هيئة الشريط لا يحمل حقل إدخال، بل رسم البحث والنص النائب وتلميح الاختصار فقط. استخدمه في ترويسة فيها متسع.
  • icon: زر بأيقونة فقط يعرض رسم البحث. استخدمه في ترويسة لا متسع فيها.

المشغِّل يفتح عرضًا نمطيًّا (modal)، مربع الحوار أو عرض ملء الشاشة، وحقل الإدخال يكون في ترويسة ذلك العرض. والمنتج الواحد يستخدم button في النافذة العريضة و icon في الضيقة.

ثلاث طرائق للعرض. الخاصية presentation تقول أين يُفتح العرض:

  • docked (الافتراضي): سطح تحت الشريط مباشرة، بعرضه، في طبقة التراكب الخاصة بالمنصة، كما تُفتح قائمة الخيارات تحت عنصر ارتكازها. يبقى التركيز في حقل إدخال الشريط، فيواصل الشخص الكتابة والاقتراحات تتغيّر. وإن لم يكن تحته متسع كافٍ فُتح العرض فوق الشريط.
  • dialog: سطح نمطي قرب أعلى النافذة، فوق حجاب، له ترويسة تحمل زر رجوع وحقل الإدخال وزر المسح. وهو للنافذة الكبيرة، يُفتح من مشغِّل. والضغط على الحجاب يغلقه.
  • full-screen: عرض نمطي فوق النافذة كلها، بالترويسة نفسها. يأخذ التركيز ويحتفظ به، ويعيده إلى الشريط أو إلى المشغِّل حين يُغلق.

استخدم المُرسى أو مربع الحوار في النوافذ الكبيرة، وملء الشاشة في الصغيرة. البحث لا يختار عنك: عيِّن presentation من نقاط التحوّل (breakpoints) التي عندك. والمشغِّل مع docked يفتح مربع الحوار، لأن العرض المُرسى ليس له حقل إدخال خاص به، وتبلّغ بنيات التنقيح (debug) عن ذلك.

الاقتراحات نوع من العناصر: استعلامات قد يريدها الشخص، كاستعلام سابق أو تكملة لما كتبه. لكل اقتراح value و headline، واختياريًّا supportingText و leadingIcon، كأيقونة السجل لاستعلام سابق. أنت تقدّم الاقتراحات للاستعلام الحالي؛ والبحث يرسمها ولا يصفّيها. وحين يبدأ اقتراح بالاستعلام يُرسم الجزء الذي يضيفه بخط أثقل، كما ترسمه محركات البحث على الويب. واختيار أحدها يُصدر select مع قيمته. والبحث لا يغيّر الاستعلام بنفسه أبدًا، فأنت تقرر ما معنى الاختيار: في الغالب أن يوضع الاقتراح في الشريط ويُبحث عنه.

صف الاستعلام. ما دامت الاقتراحات معروضة، فالصف الأول هو الاستعلام كما كُتب: رمز البحث والاستعلام، وتحتهما queryRowText إن قدّمته (“البحث في كل البريد”). ويكون هذا الصف نشطًا منذ ظهور الاقتراحات، فيبحث Enter دائمًا عمّا كُتب، كما يفعل الصف الأول في شريط العناوين في المتصفح؛ ومفتاح السهم للأسفل ينتقل إلى الاقتراحات. ولا يحتاج الصف إلى كلمات: الرمز والاستعلام وحدهما صف كامل. وللشكل الشائع الآخر، شكل صفحة محرك البحث على الويب، اجعل queryRow بالقيمة none: فلا يكون هذا الصف، ولا يصبح شيء نشطًا حتى يتنقل الشخص، ويبحث Enter إلى ذلك الحين عمّا كُتب.

التنقل بين الصفوف. تمرّ مفاتيح الأسهم على صف الاستعلام، ثم الاقتراحات، ثم النتائج. والاقتراح الذي تصل إليه يُعرض في حقل الإدخال دون أن يتغيّر الاستعلام، فيختار Enter ما يعرضه الحقل؛ وعند العودة إلى صف الاستعلام يعود الاستعلام كما كُتب. وعند الطرفين تدور المفاتيح: السهم للأسفل على الصف الأخير ينتقل إلى الأول، والسهم للأعلى على الأول ينتقل إلى الأخير. ولإيقافها عند الطرفين اجعل wrap بالقيمة false.

الإكمال داخل الحقل. يُكمل inlineCompletion الاستعلام في حقل الإدخال من أول اقتراح يبدأ به، والجزء المضاف محدَّد بعد المؤشر، كما يفعل شريط العناوين. وتحريك المؤشر يقبل الإكمال، والمفتاح Backspace يزيله، والمفتاح Enter يقبله ويبحث. ولا يُكمل أبدًا بعد حذف أو لصق، ولا أثناء تركيب أسلوب الإدخال للنص، ولا على لوحة مفاتيح الشاشة. وهو متوقف افتراضيًّا.

النتائج نوع ثانٍ من العناصر، للأشياء التي وجدها البحث: صفحة أو قسم أو رسالة. للنتيجة value و headline و excerpt واختياريًّا leadingIcon، وهي تقود إلى مكان: مع href يكون صفها رابطًا حقيقيًّا، تفتحه المنصة كما تفتح أي رابط، في تبويب جديد مع مفتاح تعديل، وبقائمة السياق الخاصة به. ومن دون href يكون الصف زرًّا، ويكون select هو الإشارة الوحيدة. و مجموعة النتائج تضع نتائج تحت عنوان واحد: عنوان هادئ مثل «الرسائل»، أو، مع href خاص بها، الصفحة التي تكون النتائج أقسامًا منها. والمقتطف فقرة تميّز فيها أنت ما طابق؛ فالبحث لا يفتّش عن الاستعلام في النص. على الويب المقتطف هو محتوى العنصر نفسه مع <mark> حول المطابقات، أو مقاطع excerpt، وكل مقطع ثانٍ منها مطابقة.

الحالة. البحث لا يجري استعلامًا ولا ينتظر ولا يصفّي أبدًا: يُصدر input لكل تغيّر ويرسم ما تعطيه. أخبره بما يفعله بحثك بالخاصيتين status (idle أو loading أو error) و statusText: العدد («12 نتيجة عن الرموز»)، أو أن لا شيء وُجد، أو الإخفاق. صف الحالة يعرض النص ويُعلِنه حين يتغيّر، وفي أثناء التحميل يعرض مؤشر تحميل بعد مهلة قصيرة.

الاختصار. الخاصية shortcut تسمّي المفاتيح التي تفتح البحث، بأسماء المفاتيح التي في اختصار لوحة المفاتيح (mod+k و /). يكتبها البحث تلميحًا، سطرًا من النص بحسب لوحة مفاتيح الشخص: في نهاية المشغِّل الذي في هيئة زر، وفي الشريط ما دام فارغًا وليس عليه التركيز. ويعرضها على أنها اختصار لوحة المفاتيح للمشغِّل أو لحقل الإدخال. والمفاتيح لا تعمل إلا إذا ربطتها أنت، أو عيّنت bindShortcut: عندئذ يستمع البحث في النافذة كلها ما دام معروضًا ومفعَّلًا، فيُفتح بالمفاتيح ويُغلق بها ثانية.

الفتح والإغلاق. الضغط على الشريط، أو الكتابة، أو مفتاح السهم للأسفل في حقل الإدخال يفتح العرض. أما التركيز وحده فلا يفتحه أبدًا: الوصول إلى الشريط بالمفتاح Tab، أو عودة التركيز من عرض ملء الشاشة، يتركه مغلقًا. يطلب البحث الفتح أو الإغلاق بالحدث toggle، الذي يحمل الحالة الجديدة، وعند الإغلاق يحمل السبب: escape أو back أو select أو submit أو outside أو tab أو focus-out أو shortcut. ويبقى الاستعلام كما هو حين يُغلق العرض. وما دامت الاقتراحات معروضة، فالمفتاح Enter على صف الاستعلام يُصدر submit مع الاستعلام كما كُتب؛ وإن لم تكن هناك اقتراحات وكانت هناك نتائج، فتح Enter النتيجة الأولى، كما في البحث داخل التوثيق. وبعد submit يبقى العرض مفتوحًا ما دام يعرض نتائج أو حالة، ليستطيع الشخص أن ينتقل إليها. على الويب يعيّن العنصر قيمة expanded فيه بنفسه، وعلى SwiftUI و Flutter يتغيّر الربط (binding) أو المتحكّم (controller). وعلى Compose و React Native تعيّن أنت expanded من دالة رد النداء، كما في قائمة الخيارات.

<tanrei-search name="q" label="البحث في البريد" placeholder="ابحث في البريد" clear-label="مسح البحث" query-row-text="البحث في كل البريد">
  <tanrei-button variant="text" slot="trailing" label="البحث الصوتي"><span slot="icon">mic</span></tanrei-button>
  <tanrei-search-suggestion value="invoices" headline="فواتير" leading-icon="history"></tanrei-search-suggestion>
  <tanrei-search-suggestion value="folder:invoices" headline="الفواتير"
    supporting-text="مجلد · 24 رسالة" leading-icon="folder"></tanrei-search-suggestion>
  <!-- العناصر الفرعية الأخرى هي محتواك أنت في العرض، بعد الاقتراحات. -->
</tanrei-search>

<!-- شكل صفحة محرك البحث على الويب: لا صف للاستعلام، ولا شيء نشط حتى يتنقل الشخص؛ وتتوقف الأسهم عند الطرفين. -->
<tanrei-search label="البحث في الويب" placeholder="ابحث" query-row="none" no-wrap></tanrei-search>

<!-- شكل شريط العناوين: يُكمَل الاستعلام في الحقل من أول اقتراح يبدأ به. -->
<tanrei-search label="ابحث أو اكتب عنوانًا" inline-completion></tanrei-search>

<!-- في نافذة صغيرة: العرض يغطي النافذة وله زر رجوع. -->
<tanrei-search presentation="full-screen" label="البحث في البريد" placeholder="ابحث في البريد"
  clear-label="مسح البحث" back-label="رجوع"></tanrei-search>

<!-- بحث في موقع: مشغِّل مع اختصاره، وعرض في مربع حوار، ونتائج هي روابط. -->
<tanrei-search id="docs-search" bar="button" presentation="dialog" label="البحث في التوثيق" placeholder="بحث"
  shortcut="mod+k" bind-shortcut clear-label="مسح البحث" back-label="رجوع">
  <!-- المجموعة التي لها href هي الصفحة؛ ونتائجها هي الأقسام التي وُجدت فيها. -->
  <tanrei-search-result-group value="/tokens/" headline="رموز التصميم" href="/tokens/" leading-icon="article">
    الألوان والمقاسات والحركة في صورة <mark>رموز</mark>، في ثلاثة مستويات.
    <tanrei-search-result value="/tokens/#layers" headline="الطبقات" href="/tokens/#layers" leading-icon="tag">
      الطبقة تغيّر قيمة <mark>رمز</mark> وقد تضيف رموزها.
    </tanrei-search-result>
  </tanrei-search-result-group>
  <!-- العناصر الفرعية الأخرى هي محتواك أنت، بعد النتائج. -->
  <tanrei-button variant="text">تحميل نتائج أخرى</tanrei-button>
</tanrei-search>

<script type="module">
  import '@tanrei/web/components/search';
  import '@tanrei/web/components/button';
  const search = document.querySelector('[name="q"]');
  search.addEventListener('input', () => showSuggestionsFor(search.value));
  search.addEventListener('submit', () => runSearch(search.value)); // قابل للإلغاء؛ وداخل نموذج يرسل النموذج بعد ذلك
  search.addEventListener('select', (e) => openSuggestion(e.detail.value));
  // العنصر يعيّن expanded الخاصة به قبل أن يُصدر toggle.
  search.addEventListener('toggle', (e) => log(e.detail.expanded, e.detail.reason));

  // البحث لا يستعلم ولا ينتظر ولا يؤخّر (debounce) أبدًا: ذلك من شأنك.
  const docs = document.querySelector('#docs-search');
  let asked = 0;
  docs.addEventListener('input', async () => {
    const mine = ++asked;
    docs.status = 'loading';
    docs.statusText = 'جارٍ البحث';
    const found = await query(docs.value);
    if (mine !== asked) return; // طُرح سؤال أحدث: أهمِل هذا الجواب
    show(found); // استبدل العناصر الفرعية <tanrei-search-result>
    docs.status = 'idle';
    docs.statusText = `${found.length} نتيجة عن ${docs.value}`; // يُعيَّن مرة لكل جواب: فهو يُعلَن
  });
  // فُعِّلت نتيجة في مكانها. ألغِ الحدث لتسلّم الرابط إلى الموجِّه (router) عندك.
  docs.addEventListener('select', (e) => { /* e.preventDefault(); router.push(e.detail.value); */ });
</script>
import { Button, Search, SearchResult, SearchResultGroup, SearchSuggestion } from '@tanrei/react';

<Search
  label="البحث في البريد"
  placeholder="ابحث في البريد"
  clearLabel="مسح البحث"
  value={query}
  onInput={(e) => setQuery(e.currentTarget.value)}
  onSubmit={() => runSearch(query)}
  onSelect={(e) => openSuggestion(e.detail.value)}
>
  <Button variant="text" slot="trailing" label="البحث الصوتي" onClick={dictate}><span slot="icon">mic</span></Button>
  {suggestions.map((s) => (
    <SearchSuggestion key={s.value} value={s.value} headline={s.headline} supportingText={s.detail} leadingIcon={s.icon} />
  ))}
</Search>

// بحث في موقع: مشغِّل مع اختصاره، وعرض في مربع حوار، ونتائج هي روابط.
// excerpt مقاطع من النص: كل مقطع ثانٍ مطابقة.
<Search
  bar="button"
  presentation="dialog"
  label="البحث في التوثيق"
  placeholder="بحث"
  shortcut={['mod+k']}
  bindShortcut
  clearLabel="مسح البحث"
  backLabel="رجوع"
  status={status}
  statusText={statusText}
  onInput={(e) => runQuery(e.currentTarget.value)}
  onSelect={(e) => { e.preventDefault(); router.push(e.detail.value); }}
>
  {pages.map((page) => (
    <SearchResultGroup key={page.url} value={page.url} headline={page.title} href={page.url} leadingIcon="article" excerpt={page.excerpt}>
      {page.sections.map((s) => (
        <SearchResult key={s.url} value={s.url} headline={s.title} href={s.url} leadingIcon="tag" excerpt={s.excerpt} />
      ))}
    </SearchResultGroup>
  ))}
</Search>
import Tanrei

// كل تعديل يكتب text؛ والفتح والإغلاق يكتبان isExpanded.
TanreiSearch("البحث في البريد", text: $query, isExpanded: $isSearching,
             prompt: Text("ابحث في البريد"), clearLabel: "مسح البحث",
             onSubmit: { value in runSearch(value) },
             onSelect: { value in openSuggestion(value) }) {
    TanreiSearchSuggestion("فواتير", leadingIcon: "history", value: "invoices")
    TanreiSearchSuggestion("الفواتير", supportingText: "مجلد · 24 رسالة", leadingIcon: "folder", value: "folder:invoices")
}
import io.github.chnotchy.tanrei.components.TanreiSearch
import io.github.chnotchy.tanrei.components.TanreiSearchSuggestion

// رفع الحالة (state hoisting): أنت تحتفظ بالقيمتين value و expanded، وتحرّكهما من دوال رد النداء.
TanreiSearch(
    value = query,
    onValueChange = { query = it },
    expanded = expanded,
    onExpandedChange = { open, _ -> expanded = open }, // الوسيط الثاني هو السبب
    label = "البحث في البريد",
    placeholder = "ابحث في البريد",
    clearLabel = "مسح البحث",
    onSearch = { runSearch(query) },
    onSelect = { openSuggestion(it) },
) {
    TanreiSearchSuggestion(value = "invoices", headline = "فواتير", leadingIcon = "history")
    TanreiSearchSuggestion(value = "folder:invoices", headline = "الفواتير", supportingText = "مجلد · 24 رسالة", leadingIcon = "folder")
}
import 'package:tanrei/tanrei.dart';

// TanreiSearchController هو TextEditingController يحمل isExpanded أيضًا.
final TanreiSearchController search = TanreiSearchController();

TanreiSearch(
  controller: search,
  semanticLabel: 'البحث في البريد',
  hintText: 'ابحث في البريد',
  clearLabel: 'مسح البحث',
  onChanged: showSuggestionsFor,
  onSubmitted: runSearch,
  onSelected: openSuggestion,
  suggestions: const <TanreiSearchSuggestion>[
    TanreiSearchSuggestion(value: 'invoices', headline: 'فواتير', leadingIcon: 'history'),
    TanreiSearchSuggestion(value: 'folder:invoices', headline: 'الفواتير', supportingText: 'مجلد · 24 رسالة', leadingIcon: 'folder'),
  ],
);
import { Search } from '@tanrei/react-native';

// مُتحكَّم به: أنت تحرّك value و expanded من onChangeText و onExpandedChange.
<Search
  value={query}
  onChangeText={setQuery}
  expanded={expanded}
  onExpandedChange={(next) => setExpanded(next)}
  accessibilityLabel="البحث في البريد"
  placeholder="ابحث في البريد"
  clearLabel="مسح البحث"
  onSubmitEditing={() => runSearch(query)}
  onSelect={openSuggestion}
  suggestions={[
    { value: 'invoices', headline: 'فواتير', leadingIcon: 'history' },
    { value: 'folder:invoices', headline: 'الفواتير', supportingText: 'مجلد · 24 رسالة', leadingIcon: 'folder' },
  ]}
/>

// في نافذة صغيرة: presentation="full-screen" و backLabel="رجوع". زر الرجوع في Android يغلق العرض.

المواصفات

العرض المُرسى مع اقتراح، ثم صف الحالة، ونتائج مجمَّعة، مرسومًا في مكانه

معطَّل، والعرض المُرسى مفتوحًا

البنية

الخصائص

الخاصية النوع القيمة الافتراضية الوصف
presentation docked | dialog | full-screen "docked" Where the view opens: docked under the bar, without taking focus from it; dialog, a modal surface near the top of the window with its own header (a large screen, opened from a trigger); or full-screen, over the whole window with its own header (a small screen). One product uses more than one and switches by window size.
bar field | button | icon "field" What stands where the search is placed. field: the bar with its input, as before. button: a trigger shaped like the bar that holds no input — the search glyph, the placeholder and the shortcut hint — for an app bar with room. icon: an icon-only Button showing the search glyph, for an app bar without. A trigger opens a modal view (dialog or full-screen), where the input is. One product uses button on a wide window and icon on a narrow one.
value string "" The query.
label string "" Names the search field, the trigger, the view, the suggestions and the results for assistive technology ("Search mail"). Drawn only as a button trigger's text while placeholder is empty. Required.
placeholder string "" A hint shown while the value is empty, and the text of a button trigger. Never a replacement for label.
expanded boolean false Whether the view is open. The search asks to open and close it with toggle (SRC-5, SRC-6, SRC-36, SRC-38).
disabled boolean false Prevents focus, editing and opening the view.
clearLabel string "" The clear button's accessible name, in the product's language ("Clear search"). Required while the clear button can show.
backLabel string "" The accessible name of the back button in a modal view's header ("Back"). Required for full-screen and for dialog.
shortcut strings The keyboard shortcut that opens the search, in the keyboard shortcut component's key names: one chord per string, pressed in order (["mod+k"], ["/"]). The search writes it as a hint, a line of text with no keycaps (SRC-37), and exposes it as the keyboard shortcut of its trigger or input. It makes the keys work only while bindShortcut is true (SRC-38); otherwise the product binds them.
bindShortcut boolean false Makes the search itself listen for shortcut, anywhere in the window, for as long as it is shown and enabled: the keys open it, and close it again while it is open (SRC-38). Off by default: a component listens outside itself only where the product asks it to.
status idle | loading | error "idle" What the product's search is doing, which the product sets: idle (nothing is awaited: results, or none, are final), loading (a query is running: the status row shows a loading indicator after its delay) or error (the query failed: statusText is drawn as an error and announced at once). The search never runs a query itself (SRC-51).
statusText string "" The status row's text, in the product's language, announced to assistive technology when it changes: the count ("12 results for tokens"), that nothing was found ("No results for tokne"), the failure ("Search is unavailable"); while loading, the loading indicator's name ("Searching"). Empty draws no status row unless status is loading.
queryRow first | none "first" Where the query as typed stands among the suggestions, which are queries. first: a row of its own above them — the search glyph and the value, with queryRowText under it — drawn while the view shows suggestions and the value is not empty, and active from the moment they show, so that the action key always searches for what was typed, as the first row of a browser's address bar does (SRC-57). none: no such row: no suggestion is active until the person moves to one, so that the action key searches for what was typed until then, as a web search page does, and the input itself is the place before the first suggestion in the arrow keys' cycle (SRC-14).
queryRowText string "" What the query row says beside the query, in the product's language, drawn as its supporting text and read as its description ("Search all mail", "Ask the assistant"). Empty draws the search glyph and the query alone: the row needs no words. Ignored while queryRow is none.
inlineCompletion boolean false Completes the query in the input while the person types, from the first suggestion whose headline begins with it: the rest of that headline is written after the caret, selected, and the query row shows the completed query (SRC-55). A completion of the beginning only; never after a deletion or a paste, during an input-method composition or on an on-screen keyboard; moving the caret accepts it, Backspace takes it away. Off by default: an address bar completes, a search page does not. Ignored while queryRow is none.
wrap boolean true Whether the arrow keys go round at the ends of the view's rows: Down Arrow on the last to the first, Up Arrow on the first to the last — with queryRow none, through the input's own place before the first suggestion (SRC-14, SRC-49). False stops them at the ends.
iconSpace auto | always | never "auto" Whether a row of the view — a suggestion, a result, a result group's linked heading — keeps the room of the leading icon column where it has no icon, so that the headlines of the view start on one line. auto: every row keeps the column while any suggestion or result of the view has a leading icon, and none while none has. always: every row keeps it. never: only a row that has an icon has the column. The view is decided as a whole. The menu's iconSpace, with the same values and default (SRC-52).
density regular | compact "regular" How much room a row of the view takes — a suggestion, a result, a result group's linked heading —: its least height, its paddings, the gap after its icon column and the size of its glyph, and never its text style. regular (a 56 row in the default system) is for a product used by touch as well as by pointer; compact (a 32 row with a 20 glyph, the tree view's compact row) is for a tool used with a pointer, a command palette looked through with the keyboard. For touch a row is never lower than the touch target in either (SRC-16). The bar, the trigger and the view's header are not changed. A design system may add values.

المنافذ

المنفذ الوصف
leading An icon-only Button at the bar's start (a menu or back button), drawn in place of the search glyph.
trailing Up to two icon-only Buttons at the bar's end, after the clear button (voice input, account).
default The product's own content in the view, after the suggestions, the status row and the results: a button that loads more results, a link to the full results page, or richer content for an empty query.

الأحداث

الحدث الوصف
input The person changed the value (typing, deleting, pasting, dictating, the clear button, Escape); carries the new value. Not emitted when the product sets value. It is the product's cue to run its query; the search does not delay or drop it (SRC-51).
submit The person pressed the keyboard's action key (Enter, Search) with no suggestion active and no result current; carries the value.
select The person chose a suggestion, or activated a result in place (without a modifier key, in the same window); carries its value. For a result with an href it is emitted before the platform follows the link, and on the web cancelling it keeps the link from being followed, so that a router can take it.
toggle The search asks to open or close its view; carries the new expanded value and, when closing, the reason: escape, back, select, submit, outside, tab, focus-out or shortcut (in the platform's casing).

العناصر

أنواع العناصر التي يكررها المكوّن. يسرد كل نموذج اختبار عناصره بالترتيب، وتسمّي كل منصة كل نوع بأسلوبها.

suggestion

A choice that completes or replaces the query while the person types: a query they searched before, or a completion. Choosing it emits select and the product sets the value. A thing the product opens is a result.

الخاصية النوع القيمة الافتراضية الوصف
value string "" Identifies the suggestion; select carries it. Unique among the suggestions.
headline string "" The suggestion's text, and its accessible name.
supportingText string "" A second line under the headline ("Folder · 24 messages"), and its description.
leadingIcon string "" The name of a glyph at the row's start (history for a past query, a folder for a result). Empty draws none.
المواصفة Web SwiftUI Jetpack Compose Flutter React Native
العنصر tanrei-search-suggestion TanreiSearchSuggestion TanreiSearchSuggestion TanreiSearchSuggestion SearchSuggestion
value · الخاصية value value value value value
headline · الخاصية headline headline headline headline headline
supportingText · الخاصية supportingText supportingText supportingText supportingText supportingText
leadingIcon · الخاصية leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
ملاحظات A child element with value, headline, supporting-text and leading-icon attributes, as <option> in a <datalist>. TanreiSearchSuggestion(_ headline:, supportingText:, leadingIcon:, value:) in the suggestions view builder. TanreiSearchSuggestion(value, headline, supportingText, leadingIcon) called in the search's content lambda, before the product's own content. TanreiSearchSuggestion(value:, headline:, supportingText:, leadingIcon:) in the search's suggestions: list. The element type of the suggestions array: { value, headline, supportingText?, leadingIcon? }.

result

A thing the search found that the person can go to: a page, a section of a page, a message, a file. It is a link, not an option.

الخاصية النوع القيمة الافتراضية الوصف
value string "" Identifies the result; select carries it. Unique among the suggestions, results and result groups.
headline string "" The result's title, and its accessible name.
excerpt strings A passage of the thing found, as runs of text in order: the first, third, fifth… run is plain text and the second, fourth… is a match, drawn marked (SRC-43). ["Tokens are ", "design", " decisions"] marks design; a passage that begins with a match begins with an empty run; one run alone is a passage without marks. The product's search decides what matched; the search component does not look for the query in the text.
leadingIcon string "" The name of a glyph at the row's start (article for a page, tag for a section). Empty draws none.
href string "" Where the result goes: an address as the platform's links take one (a URL; on the web a path or a fragment as well), in the prop set every control with a destination takes. Not empty, it makes the row a link, opened by the platform as its own links are (SRC-45). Empty makes the row a button: select is then the only signal, and the product opens the thing.
target same | new "same" Where the destination opens. same: where the person is. new: a new context — a new tab or window on the web, outside the current screen elsewhere — which targetLabel says. Ignored without href.
targetLabel string "" What assistive technology reads after the result's name while target is new ("opens in a new tab"), in the product's language. Required while target is new; ignored otherwise.
المواصفة Web SwiftUI Jetpack Compose Flutter React Native
العنصر tanrei-search-result TanreiSearchResult TanreiSearchResult TanreiSearchResult SearchResult
value · الخاصية value value value value value
headline · الخاصية headline headline headline headline headline
excerpt · الخاصية excerpt excerpt excerpt excerpt excerpt
leadingIcon · الخاصية leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · الخاصية href destination href href href
target · الخاصية target target target target target
targetLabel · الخاصية targetLabel targetLabel targetLabel targetLabel targetLabel
ملاحظات A child element whose link is an <a href> (a <button> without href) it keeps as its own first child in the light DOM, drawn as nothing and slotted over the row it draws in its shadow root, so that the search's input can name it as its active descendant (SRC-50); a page's rules for anchors and buttons neither move nor paint it. The excerpt is its child content: text with <mark> elements for the matches, which is what search engines hand back, styled through ::slotted(mark); the excerpt property (an array of runs) is used while it has no child content. Inserting an engine's HTML is the product's act: the element never parses a string as markup. rel and download are forwarded to the anchor, as every link form forwards them; target="new" is target="_blank" with noopener in rel. Not built on this platform yet. TanreiSearchResult(_ headline:, excerpt: [String], leadingIcon:, value:, destination: URL?); with a destination it opens through the environment's openURL and has the .isLink trait. target and targetLabel as the platform's link forms map them. Not built on this platform yet. TanreiSearchResult(value, headline, excerpt: List<String>, leadingIcon, href); with an href it opens through LocalUriHandler. target and targetLabel as the platform's link forms map them. Not built on this platform yet. TanreiSearchResult(value:, headline:, excerpt: [...], leadingIcon:, href: Uri?, target:, targetSemanticLabel:) in the search's results: list, with Semantics(link: true). Not built on this platform yet. An element type of the results array: { value, headline, excerpt?, leadingIcon?, href? }, with accessibilityRole="link"; an href opens through Linking. target and targetLabel as the platform's link forms map them.

result-group · مجموعة — تحتوي عناصر

Results that belong together, under one heading: the sections found in one page, or the results of one kind. With an href its heading is itself a result (the page), and its results are drawn under it as its parts; without one its heading is a title.

الخاصية النوع القيمة الافتراضية الوصف
headline string "" The group's heading: the page's title, or the name of the kind ("Pages"). It names the group for assistive technology.
value string "" Identifies the heading as a result while href is not empty; select carries it.
excerpt strings While href is not empty, the heading's own excerpt, in the runs a result's excerpt has. Ignored without href.
leadingIcon string "" While href is not empty, the name of a glyph at the heading row's start. Ignored without href.
href string "" Where the heading goes. With it the heading is a result's row and a link (SRC-44, SRC-45); empty makes it a title that takes no input.
target same | new "same" Where the destination opens. same: where the person is. new: a new context — a new tab or window on the web, outside the current screen elsewhere — which targetLabel says. Ignored without href.
targetLabel string "" What assistive technology reads after the result's name while target is new ("opens in a new tab"), in the product's language. Required while target is new; ignored otherwise.
المواصفة Web SwiftUI Jetpack Compose Flutter React Native
العنصر tanrei-search-result-group TanreiSearchResultGroup TanreiSearchResultGroup TanreiSearchResultGroup SearchResultGroup
headline · الخاصية headline headline headline headline headline
value · الخاصية value value value value value
excerpt · الخاصية excerpt excerpt excerpt excerpt excerpt
leadingIcon · الخاصية leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · الخاصية href destination href href href
target · الخاصية target target target target target
targetLabel · الخاصية targetLabel targetLabel targetLabel targetLabel targetLabel
ملاحظات A child element holding <tanrei-search-result> children; with href its own heading's link is an <a> it keeps as its own child, as a result does, and its excerpt is the content of its excerpt slot, with <mark> as in a result. Not built on this platform yet. TanreiSearchResultGroup(_ headline:, destination:, …) { results }. Not built on this platform yet. TanreiSearchResultGroup(headline, href, …) { results }. Not built on this platform yet. TanreiSearchResultGroup(headline:, href:, results: [...]). Not built on this platform yet. The other element type of results: { headline, href?, …, results: [...] }.

الحالات

السلوك

متطلبات بصيغة EARS. يُختبر تنفيذ كل منصة مقابل هذه المعرّفات. يُعرض نص المتطلبات كما ورد في ملف المواصفة، بالإنجليزية.

المعرّف المتطلب
SRC-1 THE search SHALL draw its bar as wide as its layout gives it and at least comp.search.container.height high, filled with comp.search.standard.container.color, raised by comp.search.standard.container.elevation and rounded by comp.search.container.shape, and SHALL lay out in one row, each element vertically centered and comp.search.container.gap from the next, except that its action buttons — the clear button and the icon-only Buttons of the trailing slot — stand comp.search.container.button-gap from one another (SRC-34): the search glyph comp.search.container.padding-inline from the start edge (or, WHILE the leading slot is filled, the product's icon-only Button comp.search.container.padding-inline-with-button from it, in place of the glyph), the input taking the remaining width, the clear button WHILE it is shown (SRC-10), and the icon-only Buttons of the trailing slot; the last element SHALL end comp.search.container.padding-inline-with-button from the end edge when it is an icon-only Button, and comp.search.container.padding-inline when it is the input. Right-to-left layouts SHALL mirror the row.
SRC-2 THE search SHALL draw the glyph search of the system's icon set at comp.search.leading-icon.size in comp.search.standard.leading-icon.color with the family and fill of an unselected icon, sys.icon.weight and an optical size clamped between sys.icon.optical-size.min and sys.icon.optical-size.max, SHALL NOT mirror it when the layout direction is right-to-left, and SHALL hide it from assistive technology. THE search SHALL draw no mark of its own (no path, shape or character of its own) for this glyph or for the glyphs of its clear and back buttons (SRC-10, SRC-11).
SRC-3 THE search SHALL draw the value on one line in comp.search.input.typescale and comp.search.standard.input.color, scrolling it sideways inside the input when it is longer, and WHILE the value is empty the placeholder in the same text style in comp.search.standard.placeholder.color; it SHALL draw the caret in comp.search.standard.caret.color and highlight selected text in comp.input-box.selection.color, drawing it in comp.input-box.selection.content.color: the product's one selection pair for text entry.
SRC-4 THE search SHALL edit its value in the platform's native text element and SHALL follow the text field's rules for it: TXI-1 (input once per change, and none when the product sets value), TXI-4 (input-method composition), TXI-20 for the search type (a general keyboard whose action key reads as search) and TXI-24 (the typed text's own direction); it SHALL hide a clear or cancel button that the platform draws inside its native element (the web's search cancel button), because it draws its own (SRC-10).
SRC-5 WHILE collapsed and bar is field, WHEN the person presses the bar outside its slot elements and the clear button, types into the input, or presses Down Arrow in it, THE search SHALL focus the input and emit toggle once with expanded true; focus that reaches the input by Tab, or returns to it when the view closes, SHALL NOT expand it. The Down Arrow that opens the view SHALL only open it: the row the action key takes is then the one SRC-14 and SRC-49 make current as the view opens, made current by an arrow key and so announced at once (SRC-24). THE search SHALL become expanded through its binding or controller where expanded is one (SwiftUI, Flutter) and by setting its own property on the web, and by the product setting expanded to true on Compose and React Native. WHILE bar is button or icon the trigger's activation is what expands the search (SRC-36), and the product's shortcut where the search binds it (SRC-38).
SRC-6 WHILE expanded, WHEN the person presses Escape or the platform's back, activates the back button (SRC-11), chooses a suggestion (SRC-15), activates a result in place (SRC-45), submits where submitting closes (SRC-13) or presses the shortcut the search binds (SRC-38), or, WHILE presentation is dialog, presses the scrim (a modal view answers Escape, back and the scrim as its modal layer does, MDL-6), or, WHILE presentation is docked, presses outside the bar and the view, presses Tab or Shift+Tab, or moves focus out of the search, THE search SHALL emit toggle once with expanded false and that reason (escape, back, select, submit, shortcut, outside, tab or focus-out) and SHALL be collapsed as SRC-5 says it is expanded; the value SHALL stay as it is. Tab and Shift+Tab SHALL then move focus on from the input as they would have, and whether a press outside also reaches the element under it SHALL follow the platform and be stated in its README, as for the menu (MNU-5). Focus that moves between the bar's input and a result of the docked view (SRC-49) has not left the search.
SRC-7 WHILE expanded, presentation is docked and bar is field and the view has content (a suggestion, a status row, a result, a result group, or content in the default slot), THE search SHALL present the view in the platform's overlay layer, the one the menu's surface uses (MNU-1), comp.search.view.offset below the bar, as wide as the bar and aligned with it; WHERE the room below, within comp.search.view.viewport-margin of the viewport's edge and of the on-screen keyboard, is less than the view needs and the room above is more, it SHALL place the view above the bar instead; it SHALL limit the view's height to the room left and scroll its content beyond it, and keep following the bar while it moves. It SHALL fill the view with comp.search.view.container.color, raise it by comp.search.view.container.elevation, round it by comp.search.view.container.shape, clip the content to that shape and inset it by comp.search.view.padding-block and comp.search.view.padding-inline. WHILE the view has no content THE search SHALL draw no view and stay expanded.
SRC-8 WHILE presentation is docked THE search SHALL keep focus in the bar's input while the view is open, because the view is an operated overlay whose focus is the input it belongs to: it SHALL NOT move focus into the view when it opens, trap focus, make anything inert or draw a scrim; a press on a suggestion, on the status row or on the view's surface SHALL NOT take focus from the input; a result is a link and takes focus when the person presses it or reaches it by Down Arrow (SRC-49), which is still focus inside the search; and the search SHALL leave focus where the person put it when the view closes.
SRC-9 WHEN expanded becomes true WHILE presentation is full-screen THE search SHALL present the view over the whole window as a modal overlay on its modal layer without the layer's scrim (MDL-1 WHILE scrim is false, the view filling the window), filled with comp.search.view.container.color to every edge of the window and under every system inset, with its content inside the safe area and above the on-screen keyboard: at its top a header at least comp.search.header.height high holding the back button (SRC-11) comp.search.header.padding-inline from the start edge, the input with the same value, and the clear button WHILE it is shown, the last of them comp.search.header.padding-inline from the end edge, comp.search.container.gap apart and vertically centered; under the header a line of comp.search.divider.thickness in comp.search.divider.color across the window; under that the view's content in the order SRC-46 gives, scrolling. It SHALL move focus to the header's input with the caret at the end of the value, keep focus inside the view, and make everything outside it inert and hidden from assistive technology, as its modal layer does (MDL-2, MDL-4); WHEN the view closes THE search SHALL return focus to the bar's input without expanding it again (SRC-5), or to the trigger WHILE bar is button or icon.
SRC-10 WHILE value is not empty and disabled is false THE search SHALL show a clear button: an icon-only Tanrei Button of the text variant showing the glyph close of the system's icon set, not mirrored, named by clearLabel, of size small in the bar and medium in the full-screen header. WHEN it is activated THE search SHALL set value to empty, emit input once with the empty value and move focus to the input it belongs to, and SHALL NOT expand or collapse. WHILE clearLabel is empty THE search SHALL still show the button, and in debug builds report that it has no accessible name.
SRC-11 WHILE the full-screen view is open THE search SHALL draw a back button at the start of its header: an icon-only Tanrei Button of the text variant and the medium size showing the glyph arrow_back of the system's icon set, mirrored in right-to-left layouts by the icon helper, as the icon set marks it (SRC-32), named by backLabel; WHEN it is activated THE search SHALL collapse with the reason back (SRC-6). WHILE backLabel is empty THE search SHALL still draw it, and in debug builds report that it has no accessible name.
SRC-12 WHILE collapsed and the input has focus, WHEN the person presses Escape with a value that is not empty THE search SHALL set value to empty and emit input once, as a native search input does; with an empty value Escape SHALL do nothing and pass on to the enclosing element.
SRC-13 WHEN the person presses the keyboard's action key (Enter, Search, Go) in the input while the query row is active or no row is (SRC-14, SRC-57), no result is current (SRC-49) and no input method is composing, or presses the query row by pointer or touch, THE search SHALL, WHILE an inline completion is shown, first accept it (SRC-55), and SHALL emit submit once with the value and then, WHILE expanded and the view shows no result, no result group and no status row, collapse with the reason submit (SRC-6), so that toggle follows submit; WHILE the view shows one of them it SHALL stay expanded, because what the person asked for is already in front of them, and the product closes the view where its submit goes elsewhere; on the web, inside a form, it SHALL then request the form's submission unless submit was cancelled, as a native input does. The submission SHALL be requested through the form's default button (BTN-30): WHILE the form has a submit button — the platform's own or a Button of type submit — the first of them in document order SHALL be pressed, so that its click is emitted and its name and value are sent, and WHILE that button is disabled nothing SHALL be submitted; only a form with no submit button is asked directly.
SRC-14 WHILE expanded and the view holds suggestions THE search SHALL keep focus in the input, so that typing goes on editing the value, and SHALL make at most one of its rows current without moving focus, as an editable combobox with list autocomplete does. The rows the arrow keys go through are, in this order: the query row WHILE it is drawn (queryRow first and a value that is not empty, SRC-57), and otherwise the input's own place, which stands for the value as typed and makes no row current; then the suggestions, in the product's order; then the results (SRC-49). WHEN the input has focus and the view comes to show suggestions — it opens with them, the product gives or replaces them, or focus comes back to the input — and WHEN the person types, deletes or pastes, THE search SHALL make the first of those places current automatically: the query row, active, or the input's place, no row being active — either way the action key searches for the value as typed (SRC-13). Down Arrow SHALL make the next row current and Up Arrow the previous one, Down Arrow from the input's place going to the first suggestion and Up Arrow on the first suggestion back to the input's place; WHILE wrap is true Down Arrow on the last row SHALL go to the first place and Up Arrow on the first place to the last row, and WHILE wrap is false they SHALL do nothing at the ends. WHEN a suggestion becomes active by an arrow key THE search SHALL show its headline in the input in place of the value, the caret at its end, without changing value or emitting input, so that the action key chooses what the input shows (SRC-15); WHEN the query row or the input's place becomes current again, or a result takes focus, THE search SHALL show the value as typed again (and its inline completion, SRC-55); WHEN the person types, deletes or pastes while a suggestion's headline is shown, that text, edited, SHALL become the value (input, SRC-4); and WHEN the view closes or the input loses focus without a choice THE search SHALL show the value as typed. Moving the caret SHALL leave the current row as it is, except that it accepts an inline completion (SRC-55). WHILE the person types on an on-screen keyboard THE search SHALL make no row current by itself — neither as the suggestions show nor as the person types — so that the keyboard's action key (Search, Go) submits the value as typed (SRC-13), as a search field on a phone does, and the person chooses a suggestion by touching it. The person types on an on-screen keyboard from the moment the input takes focus from a touch or a pen (or a touch or a pen presses the focused input), and no longer once they press Down Arrow, Up Arrow or a key that moves the caret — keys only a hardware keyboard has — or a mouse presses the input, which make the first place current as after typing: whether a device has a touch screen, or a coarse primary pointer, does not tell which keyboard is in use on a laptop with a touch screen or a tablet with a keyboard attached. WHILE no row is current because of an on-screen keyboard, Down Arrow SHALL make the first row current (the query row, or the first suggestion where the input's place comes first) and Up Arrow the last row WHILE wrap is true. WHILE an input method is composing no row SHALL be current and Enter, Escape and the arrow keys SHALL be the input method's (TXI-4), so that the Enter that confirms a conversion chooses nothing; WHEN the composition ends THE search SHALL make the first place current as after typing. WHILE the input does not have focus no row SHALL be current. WHEN a row becomes current while part of it is scrolled out of view THE search SHALL scroll it into view. Enter with an active suggestion SHALL choose it (SRC-15). A row made current automatically is announced once typing pauses, and one an arrow key moves to at once (SRC-24).
SRC-15 WHEN the person activates a suggestion (by pointer or touch, or by Enter while it is active) THE search SHALL emit select once with the suggestion's value and then collapse with the reason select (SRC-6), so that toggle follows select; it SHALL NOT change value itself: the product sets the value it wants, the suggestion's text for a query. The query row is not a suggestion: activating it submits the value (SRC-13, SRC-57).
SRC-16 THE search SHALL lay out each suggestion as one row, at least comp.search.suggestion.container.height.regular tall and at least sys.target.touch tall for touch input, in both densities, and for fine pointers at least sys.target.pointer tall WHILE density is regular and as tall as its density gives WHILE density is compact (SRC-53) (rows that touch cannot extend a hit area over each other): comp.search.suggestion.container.padding-inline.regular from each edge, the leading icon column as SRC-52 says, then the headline with the supporting text under it, comp.search.suggestion.container.gap.regular after the icon column, padded by comp.search.suggestion.container.padding-block.regular above and below. It SHALL draw the headline in comp.search.suggestion.headline.typescale and the supporting text in comp.search.suggestion.supporting-text.typescale, both wrapping and growing the row rather than being cut; the leading icon at comp.search.suggestion.leading-icon.size.regular with the family and fill of an unselected icon, sys.icon.weight and an optical size clamped between sys.icon.optical-size.min and sys.icon.optical-size.max; and the row's highlight rounded by comp.search.suggestion.container.shape. Right-to-left layouts SHALL mirror the row, and the whole row SHALL be the suggestion's hit area.
SRC-17 WHILE a suggestion — the query row included — is hovered, active or pressed THE search SHALL render its container, leading icon, headline, supporting text and opacity from the component tokens of its highest-precedence state, with precedence pressed over active over hovered and the active suggestion taking the focused tokens; WHEN a suggestion becomes active THE search SHALL show the focus ring inside its row without animation, whether an arrow key or the search made it active. A pointer over a suggestion SHALL NOT make it active.
SRC-18 WHILE the bar is hovered, focused or pressed THE search SHALL render its container, outline, outline width, glyph, input, placeholder, caret and opacity from the component tokens of the highest-precedence active state, with precedence pressed over focused over hovered; unlike a button, focus gained by pointer or touch SHALL select the focused state, because a field shows where typing will go however it was focused. THE search SHALL show the bar's focus by its focused outline, drawn inside the bar's edge, and SHALL NOT draw the focus ring around the bar; WHERE sys.behavior.focus-style is glow it SHALL also draw the glow around the bar while it is focused. WHEN colors or widths change between states THE search SHALL animate them over comp.search.motion.state-duration with comp.search.motion.state-easing, and at once where motion is reduced.
SRC-19 WHEN the bar is pressed by pointer or touch, or a suggestion by pointer, touch or Enter, THE search SHALL show that element's pressed state without delay and SHALL keep it visible for at least sys.motion.duration.press-hold, even when the press ends sooner.
SRC-20 WHILE pressed THE search SHALL answer as sys.behavior.pressed-feedback names: overlay applies the pressed tokens to the whole container at once; ripple grows the pressed state layer from the point of contact (from the center for keyboard activation); dim applies the pressed opacity to the whole control and draws no state layer; none draws no answer to the press. Under ripple and dim only the container color stays with the state under the press; outline, glyph, input, placeholder, caret, leading icon, headline, supporting text, opacity and shape still come from the pressed tokens. Under none every part stays with the state under the press. The ripple grows over comp.search.motion.feedback-duration with comp.search.motion.state-easing, fades over comp.search.motion.state-duration with comp.search.motion.state-easing once the press has ended and press-hold has passed, and appears whole where motion is reduced. The container is the bar for a press on the bar and the row for a press on a suggestion; the control a dim applies to is the bar or the row.
SRC-21 THE search SHALL ease its bar, view and suggestion corners by sys.shape.corner-smoothing (0 is a quarter circle, 0.6 the iOS continuous corner; a platform with only the OS curve draws it for any amount above 0) and show its keyboard focus as sys.behavior.focus-style names (ring or glow); a platform that cannot draw a choice SHALL fall back to the first value and state that in its README.
SRC-22 WHERE the bar is shorter than the minimum target THE search SHALL extend its hit area vertically to sys.target.touch for touch input and sys.target.pointer for fine pointers, without changing its visual size; a platform that cannot tell the input type SHALL use sys.target.touch.
SRC-23 WHEN the view opens THE search SHALL fade it in over comp.search.motion.open-duration with comp.search.motion.open-easing, a docked view also growing from its edge that faces the bar, and WHEN it closes SHALL fade it out over comp.search.motion.close-duration with comp.search.motion.close-easing; WHERE motion is reduced it SHALL appear and disappear at once. Focus SHALL move (SRC-9) when the view opens or closes, not when the motion ends.
SRC-24 THE search SHALL expose its input as a search field named by label and never by placeholder, with the platform's search role where it has one (a search box, the search-field trait, the search input type); WHILE the view shows suggestions, the web's input SHALL be a combobox with aria-autocomplete list (both WHILE an inline completion can be shown, SRC-55), aria-expanded true and aria-controls naming the suggestions' listbox. THE search SHALL announce the active row, as the input's active descendant on the web: at once WHEN an arrow key makes it active; and WHEN the search made it active automatically (the query row, SRC-14) only once it has stayed active for 500 milliseconds with nothing typed, each edit taking the active descendant away until then, as React Aria's autocomplete does, so that a screen reader reads the character typed first and then what the action key takes, and not a row after every key. The active option SHALL be selected (aria-selected true) and every other one not, from the moment it is active. THE search SHALL expose the suggestions on the web as a listbox named by label whose options — the query row first where it is drawn (SRC-57), then the suggestions — are named by their headline and described by their supporting text, and on the other platforms as buttons named and described the same way, with their position in the list; icons and the divider SHALL be hidden; WHILE the view shows no suggestion the web's input SHALL be a search box without the combobox role, whatever else the view holds; results SHALL never be options (SRC-50); the dialog and full-screen views SHALL each be exposed as their modal layer's modal dialog (MDL-10) named by label; the clear and back buttons SHALL be named by clearLabel and backLabel.
SRC-25 THE search SHALL NOT restyle the icon-only Buttons in its leading and trailing slots: each SHALL render from its own tokens and keep its own semantics and its own focus stop in reading order (the leading one before the input, the trailing ones after the clear button), and the search SHALL draw neither slot in the full-screen header. The hit areas of two neighbouring elements of the bar or the full-screen header SHALL stop at the middle of comp.search.container.gap, those of two neighbouring action buttons where the lengths SRC-34 keeps for them meet, and an icon-only Button's at the bar's edge. The gap, the length of SRC-34 and comp.search.container.padding-inline-with-button are what keep each icon-only Button's target whole: under the default system every icon-only Button of the bar and the header, the small clear button included, keeps a target at least sys.target.touch wide; a layer that narrows the gap or the padding narrows those targets.
SRC-26 WHILE disabled is true THE search SHALL NOT be focusable, editable or expandable, SHALL NOT emit input, submit, select or toggle, SHALL hide the clear button, SHALL expose the disabled state to assistive technology, and SHALL render the bar's container, outline, glyph, input, placeholder and opacity from the disabled component tokens; the slot icon-only Buttons keep their own state.
SRC-27 WHILE label is not empty THE search SHALL expose it as its accessible name, over a name the product gives it on the element (aria-label or aria-labelledby); WHILE label is empty and the product gives the search a name of its own on the element — aria-label, or aria-labelledby naming an element — THE search SHALL expose that name as its accessible name; WHILE label is empty and the product gives it none THE search SHALL still render, and in debug builds report that it has no accessible name; WHEN presentation, bar or status names a value the component does not define THE search SHALL render as docked, field or idle and in debug builds report the value; WHEN a result's headline is empty, or a result's or linked group heading's value is empty or repeats that of another suggestion, result or group, or a result group holds anything but results, THE search SHALL still render what it can and in debug builds report it; WHEN a suggestion's value is empty or repeats another's, or its headline is empty, THE search SHALL still render it and in debug builds report it; IF the trailing slot holds more than two elements THE search SHALL still lay them out and in debug builds report it.
SRC-28 WHILE the text size is enlarged THE search SHALL grow the bar and the full-screen header to hold one line of the input (their heights are minimums) and keep the value on one line, SHALL let suggestion rows grow and wrap, and SHALL NOT scale the icon-only Buttons it holds.
SRC-29 THE search SHALL hand the default slot's content comp.search.standard.suggestion.headline.color as the platform's inherited foreground (the web's inherited color, SwiftUI's foreground style, Compose's content color, Flutter's default text and icon style, React Native's Tanrei text context), inset by comp.search.suggestion.container.padding-inline.regular at the sides, and plain text given as that content, where the platform must style it, SHALL take sys.typescale.body.
SRC-30 IF the icon set cannot draw a glyph of the search yet (search, close or arrow_back; its font is still loading or failed to load) THE search SHALL draw nothing in that glyph's place, never the glyph's name as text, SHALL keep the glyph's box so that the bar's layout does not change, SHALL keep the clear and back buttons operable and named by clearLabel and backLabel, and SHALL draw the glyph once the icon set can.
SRC-31 THE search SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the search is shown THE search SHALL draw itself for the new direction at once, without a motion of its own, keeping its value, whether it is expanded, and its focus.
SRC-32 WHERE the layout direction is right-to-left THE search SHALL draw a suggestion's leading icon and the arrow_back of its back button (SRC-11) mirrored left to right exactly when the system's icon set marks that glyph's name as mirrored or the product forces mirroring for that use, and unmirrored when the product forbids it: the icon helper mirrors the glyph inside its own box, about the box's vertical centre line, changing neither its place, size, color and fill nor the order SRC-1 and SRC-16 gives. THE search SHALL NOT mirror a glyph itself, and SHALL NOT mirror content the product gives as an image or a view of its own rather than by a glyph's name. The search glyph and the clear button's close are not marked and are never mirrored (SRC-2, SRC-10); the icon-only Buttons of the leading and trailing slots mirror their own glyphs (BTN-19).
SRC-33 THE search SHALL lay out its placeholder and a suggestion's headline and supporting text as text of its own direction, isolated from the text around it: each takes the base direction of its first strong character, or the layout direction where it has none, so that a left-to-right word, a number with its sign or unit, a telephone number and an address keep their own order in a right-to-left layout and reorder nothing beside them; THE search SHALL still place each and align its lines by the layout direction, not by the text's own.
SRC-34 THE search SHALL lay out the bar's action buttons — the clear button WHILE it is shown (SRC-10) and the icon-only Buttons of the trailing slot — comp.search.container.button-gap from one another, measured between their visible bounds, and SHALL move two of them further apart only as far as each needs in order to keep, centred on itself, a length of sys.target.touch along the row that its neighbour's does not reach into, because buttons that stand this close cannot extend a hit area over each other (as BGR-3): where the token is 0, as in the default system, a button at least sys.target.touch wide touches its neighbour, and a narrower one stands half of what it lacks away from it. The first action button SHALL still stand comp.search.container.gap after the input and the last comp.search.container.padding-inline-with-button from the bar's end edge (SRC-1). THE search SHALL NOT widen, resize or restyle a button to do so (SRC-25), and SHALL space the buttons the same whatever the input type, so that the bar does not change with the pointer.
SRC-35 WHILE bar is button THE search SHALL draw a trigger in place of the bar of SRC-1: one button as wide as its layout gives it and at least comp.search.trigger.container.height high, filled, raised and rounded as the bar is (comp.search.standard.container.color, comp.search.standard.container.elevation, comp.search.container.shape), holding in one row, vertically centered and comp.search.trigger.container.gap apart, the glyph search drawn as SRC-2 says at comp.search.trigger.leading-icon.size, comp.search.trigger.container.padding-inline from the start edge; then the placeholder — or the label WHILE placeholder is empty — on one line in comp.search.trigger.label.typescale and comp.search.standard.placeholder.color, taking the remaining width and cut at its own end where it does not fit (SRC-33); then the shortcut hint WHILE shortcut is not empty (SRC-37); the last of them ending comp.search.trigger.container.padding-inline from the end edge. WHILE bar is icon THE search SHALL draw in the bar's place one icon-only Tanrei Button of the text variant and the medium size showing the glyph search of the system's icon set, rendered from the Button's own tokens, and no hint. In either form THE search SHALL draw no input, no clear button and neither slot in the trigger, and SHALL NOT show the value while collapsed. Right-to-left layouts SHALL mirror the row.
SRC-36 WHILE bar is button or icon THE search SHALL treat its trigger as a button: WHEN it is activated by pointer, touch, Enter or Space THE search SHALL emit toggle once with expanded true and become expanded as SRC-5 says, presenting its view as a modal one — dialog WHILE presentation is dialog or docked, and full-screen WHILE it is full-screen — and in debug builds SHALL report presentation docked with a trigger, because a docked view has no input of its own. WHILE the button trigger is hovered, keyboard-focused or pressed THE search SHALL render its container, outline, outline width, glyph, text and opacity from the bar's component tokens of the highest-precedence state, with precedence pressed over focused over hovered, showing keyboard focus by the focused outline as the bar does (SRC-18); focus gained by pointer or touch SHALL NOT select the focused state, as for a Button; a press SHALL be answered as SRC-19 and SRC-20 say for the bar, and its hit area extended on both axes as SRC-22 says. THE search SHALL expose the trigger as a button named by label that opens a dialog, with whether its view is open (aria-haspopup with the value dialog and aria-expanded on the web), and with the search glyph hidden; WHILE disabled is true the trigger SHALL NOT be focusable or pressable, SHALL expose the disabled state and SHALL render from the disabled tokens (SRC-26).
SRC-37 WHILE shortcut is not empty THE search SHALL draw it with the keyboard shortcut component, hosted as KBS-13 says: in its plain form, at size small, with convention auto, disabled while the search is disabled, its legends and separators in comp.search.shortcut.typescale and comp.search.shortcut.color; it SHALL draw no cap, fill or edge (KBS-7), because the bar's fill may be the cap's own. It SHALL draw the hint at the end of a button trigger (SRC-35) and, WHILE bar is field, after the bar's input and comp.search.container.gap from it, only while the value is empty and the input does not have focus; it SHALL NOT draw it WHILE bar is icon, nor in a view's header. THE search SHALL expose the shortcut as the keyboard shortcut of its trigger, or of its input WHILE bar is field, in the platform's form (KBS-12: aria-keyshortcuts on the web), SHALL hide the drawn keys from assistive technology, and SHALL give the hint no press of its own: a press on it is a press on the trigger or the bar.
SRC-38 WHILE bindShortcut is true, shortcut holds exactly one chord and disabled is false, WHEN the person presses that chord anywhere in the window (read as KBS-1 reads it: mod is Command on Apple platforms and Control elsewhere) THE search SHALL, WHILE collapsed, open as an activation of its trigger does (SRC-36) or, WHILE bar is field, focus its input and expand (SRC-5), and WHILE expanded SHALL collapse with the reason shortcut (SRC-6); and it SHALL keep that press from doing anything else. THE search SHALL NOT act on a press that something else has already taken (a cancelled key event on the web), on a key repeating while held, during an input-method composition, or — for a chord without mod, ctrl or alt — while focus is in an element that takes text, its own input included, so that such a key types there. THE search SHALL listen only while it is part of what is shown (connected to the document, in the view tree) and SHALL stop when it is removed, disabled, or bindShortcut becomes false.
SRC-39 WHILE bindShortcut is false THE search SHALL NOT listen for any key outside itself: the hint and the exposed shortcut say what the product has bound, and the product opens the search by setting expanded. IF bindShortcut is true while shortcut is empty or holds more than one chord, or while another shown search binds the same chord, THE search SHALL bind nothing for itself — the search shown first keeps a chord two of them name — and in debug builds SHALL report it.
SRC-40 WHEN expanded becomes true WHILE presentation is dialog THE search SHALL present the view as a modal overlay on its modal layer (MDL-1, MDL-2, MDL-4): the layer's scrim in comp.search.view.scrim.color and comp.search.view.scrim.blur over the whole window, and above it a container centered between the window's side edges, its top comp.search.view.dialog.offset below the top of the safe area, as wide as the window allows up to comp.search.view.dialog.max-width while keeping comp.search.view.viewport-margin from each side edge, and as tall as its content up to the room left above comp.search.view.viewport-margin from the bottom of the safe area or from the on-screen keyboard; WHERE the window is too short to keep the offset and one row of content, it SHALL give up the offset down to comp.search.view.viewport-margin. It SHALL fill the container with comp.search.view.container.color, raise it by comp.search.view.container.elevation, round it by comp.search.view.container.shape and clip its content to that shape. At the container's top it SHALL draw a header at least comp.search.header.height high: the back button the full-screen view's header draws, drawn, mirrored, named by backLabel, reported and answered as SRC-11 says, comp.search.header.padding-inline from the start edge, where the full-screen header has it and in the search glyph's place, the input with the same value, and the clear button WHILE it is shown (SRC-10, at the medium size), comp.search.container.gap apart and vertically centered, the last ending comp.search.header.padding-inline from the end edge when it is the clear button and comp.search.container.padding-inline when it is the input; it SHALL draw no search glyph in the header. The back button SHALL be a stop of the view's focus order, so that a person can leave the view without Escape, a pointer or the scrim. WHILE the view has content under the header THE search SHALL draw a line of comp.search.divider.thickness in comp.search.divider.color across the container under it, then the content in the order SRC-46 gives, inset by comp.search.view.padding-block and comp.search.view.padding-inline and scrolling under the header when it is taller than the room. It SHALL move focus, keep it inside, make everything outside inert and hidden from assistive technology, and return focus when the view closes, all as SRC-9 says for the full-screen view; and it SHALL keep the container's top where it is while its content changes, so that the input does not move under the person's typing.
SRC-41 WHEN the dialog view opens THE search SHALL fade its scrim and its container in together (MDL-7, with the search's own motion, which its docked view shares) over comp.search.motion.open-duration with comp.search.motion.open-easing, and WHEN it closes SHALL fade both out over comp.search.motion.close-duration with comp.search.motion.close-easing, as SRC-23 says of the other views; WHEN the container's height changes with its content THE search SHALL draw the new height at once, without a motion of its own.
SRC-42 THE search SHALL lay out a result as a suggestion's row is laid out (SRC-16), from the same tokens: the leading icon column, then the headline in comp.search.suggestion.headline.typescale with the excerpt under it in comp.search.suggestion.supporting-text.typescale, both wrapping and growing the row rather than being cut, the row at least comp.search.suggestion.container.height.regular tall and at least the minimum target, and the whole row the result's hit area. The leading icon column SHALL be kept as SRC-52 says, the suggestions and the results of the view decided together, so that they align. WHILE a result is hovered, focused, current (SRC-49) or pressed THE search SHALL render its row from the suggestion tokens of that state (comp.search.standard.suggestion.container.color and the leading icon, headline and supporting-text colors, the excerpt taking the supporting-text color) with the precedence, the focus ring inside the row and the press answer that SRC-17, SRC-19 and SRC-20 give a suggestion, focused and current standing where active stands there.
SRC-43 THE search SHALL read an excerpt as runs of text in order, the second, fourth and every further even run being a match, SHALL draw the runs as one continuous text that wraps as one, and SHALL draw each match in comp.search.result.mark.color with its weight raised by comp.search.result.mark.emphasis, over a fill of comp.search.result.mark.container.color that covers the match's own line boxes, with square corners and no padding, so that the fill moves no text. A match SHALL be told from the excerpt around it by all three — color, weight and fill — because a match must not depend on color alone, and the reader's font, which the product does not choose, may have no weight between regular and bold, so that the raised weight draws as the regular one (an Arabic font often has none); the fill shows a match in every script, as the platform's own marked text is filled. A result is a destination, so what is marked in it is what matched; a query suggestion marks what it adds (SRC-56). THE search SHALL NOT look for the query in a result's text, mark a result's headline, or change, trim or shorten an excerpt: what matched and how long the passage is are the product's. It SHALL expose the excerpt to assistive technology as one text, the result's description, read without a pause or an announcement at a mark, and SHALL lay the whole excerpt out as text of its own direction (SRC-33).
SRC-44 THE search SHALL draw a result group as its heading followed by its results in order, comp.search.group.gap below whatever stands above it in the view and above whatever follows it. WHILE the group's href is empty its heading SHALL be the headline in comp.search.group-title.typescale and comp.search.group-title.color, wrapping, inset by comp.search.suggestion.container.padding-inline.regular at the sides and padded by comp.search.suggestion.container.padding-block.regular above and below, taking no input and no state. WHILE href is not empty the heading SHALL be a result's row (SRC-42, SRC-45) made of the group's headline, excerpt and leading icon, and the group's results SHALL be inset at the start by comp.search.group.indent, their hit areas and highlights with them, so that they read as parts of it. A group SHALL hold results only, and SHALL NOT hold a group. Right-to-left layouts SHALL mirror the inset.
SRC-45 THE search SHALL make each result, and each group heading, whose href is not empty a link and not an option or a button: the platform's own link to href (the web's anchor element; elsewhere an element with the platform's link semantics whose address the platform's opener opens), so that whatever the platform gives a link — on the web following it by Enter or a press, opening it in a new tab by a modifier key or the middle button, its context menu, dragging and copying its address, the address shown before it is followed — is the platform's and not the search's to imitate; it SHALL activate a link by pointer, touch or Enter and not by Space, SHALL open it in a new context WHILE target is new (on the web one that is given no handle to the page that opened it) and expose targetLabel as its description after the excerpt, and SHALL draw no mark of its own for a new context. WHEN a result is activated in place (by Enter, touch or a primary press, without a modifier key, target being same) THE search SHALL emit select once with the result's value and then let the platform open href, unless the product cancelled that select, in which case it SHALL open nothing because the product's router has taken it; and SHALL then collapse with the reason select (SRC-6), so that toggle follows select. WHEN a result is opened any other way (a modifier key, the middle button, the context menu, target new) THE search SHALL emit nothing and stay expanded, so that a person can open several results from one search. WHILE a result's href is empty, or names a script rather than a place, it SHALL be a button, activated by pointer, touch, Enter or Space, for which select is all that happens.
SRC-46 WHILE expanded THE search SHALL lay out the content of its view from top to bottom in this order: the suggestions, the status row (SRC-47), the results and result groups in the order the product gives them, and the default slot's content; a part that is absent takes no room.
SRC-47 WHILE statusText is not empty or status is loading THE search SHALL draw a status row: inset by comp.search.suggestion.container.padding-inline.regular at the sides and padded by comp.search.suggestion.container.padding-block.regular above and below, taking no input and no state. WHILE status is idle it SHALL draw statusText, wrapping, in comp.search.status.typescale and comp.search.status.color; WHILE status is error it SHALL draw it in comp.search.status.error.color; WHILE status is loading it SHALL draw, in the text's place and at the row's start, one Tanrei loading indicator of size small named by statusText, which waits its own show delay and enters as the loading indicator does (LDG-11 to LDG-14), and no text, and the row SHALL keep the height of one line of text whether or not the indicator is shown yet. The results the product leaves in the view WHILE status is loading SHALL stay drawn and usable.
SRC-48 THE search SHALL expose the status row as a live region that is present from the moment the view opens: WHILE status is idle, WHEN statusText changes THE search SHALL have assistive technology read the new text politely, after what it is saying (the status role on the web); WHILE status is error it SHALL have it read at once (the alert role); WHILE status is loading it SHALL announce nothing — the loading indicator does not announce itself (LDG-6) — and SHALL mark the results as busy (aria-busy on the web) until status leaves loading. THE search SHALL NOT compose, count or translate the text: the number of results and the words around it are the product's.
SRC-49 WHILE expanded, the input has focus and the view holds a result and no suggestion THE search SHALL make the first result current automatically, focus staying in the input, as SRC-14 makes its first place current and, as there, not WHILE the person types on an on-screen keyboard or an input method is composing: WHEN the view comes to show results — it opens with them, the product gives or replaces them, or focus comes back to the input — and WHEN the person types, deletes or pastes. It SHALL draw the current result as a focused one (SRC-42), and the action key in the input SHALL activate it as Enter on it does (SRC-45), so that one press of Enter goes to what the search found first, as a documentation search does. With the modifier that opens a link elsewhere — Command under the Apple keyboard convention and Control under the others for a new tab, Shift for a new window — the action key in the input SHALL open the current result's destination there, as that press on the link does: nothing emitted and the view kept open (SRC-45); a current result without a destination takes no such press. WHILE the input does not have focus no result SHALL be current. The results SHALL be the last rows of the arrow keys' cycle (SRC-14), in view order, across groups, a linked group heading counting as a result and a title not, and an arrow key that reaches a result SHALL move focus to it: WHEN the person presses Down Arrow in the input while the first result is current THE search SHALL move focus to the second result, and to the first WHILE no result is current and there is no suggestion to go to (none in the view, or the last one active). WHILE a result has focus THE search SHALL move focus to the next result with Down Arrow and to the previous one with Up Arrow; Up Arrow on the first SHALL go back to the input with the last suggestion active, where the view holds suggestions; and at the ends of the cycle, WHILE wrap is true, Down Arrow on the last result SHALL go to the first place of the cycle — focus going back to the input, to the query row or the input's place, or, with no suggestion, to the first result — and, with no suggestion in the view, Up Arrow on the first result, whether it has focus or is current in the input, SHALL move focus to the last result; WHILE wrap is false they SHALL do nothing there. WHEN a result takes focus or becomes current while part of it is scrolled out of view THE search SHALL scroll it into view, and SHALL show the focus ring inside its row (SRC-42). WHILE a result has focus, WHEN the person types a character, deletes or pastes THE search SHALL move focus to the input so that the key edits the value there, and Escape SHALL close the view as from the input (SRC-6). Tab and Shift+Tab SHALL move through the results as through any links WHILE the view is modal, and SHALL leave the search and close the view WHILE it is docked (SRC-6). A pointer over a result SHALL NOT move focus, and the arrows SHALL NOT reach the status row or the default slot's content.
SRC-50 THE search SHALL expose its results as links in a list, outside the suggestions' listbox: one list named by label holding the results in order, each result a link named by its headline and described by its excerpt, with its position in the list where the platform gives one; a result group as a group named by its headline holding its own list of its results, and a linked heading as a link before that list; a result without href as a button in the same place. A result SHALL never carry the option role: an option cannot be a link, and a result must be one. The result current while focus stays in the input (SRC-49) SHALL be announced as the query row is (SRC-24) — on the web the input names the result's link as its active descendant once it has stayed current for 500 milliseconds with nothing typed —, the input staying a search box; what the search found is also said by the status row (SRC-48), and the result takes real focus as soon as the person moves to it. On the platforms without a link element THE search SHALL expose a result as a button with the link trait or role where the platform has one, named and described the same way. Leading icons SHALL be hidden, and the status row is exposed as SRC-48 says.
SRC-51 THE search SHALL NOT run a query, fetch, wait, debounce, cache, sort or filter anything itself: it emits input once per change (SRC-4) and draws the suggestions, the results, the status and the statusText the product gives it, replacing them when the product does, at once and without a motion of its own. WHEN the result that has focus is removed or replaced, or the product replaces its content whole so that the element that held the focus goes with it, THE search SHALL move focus to the input rather than let it fall out of the view; WHEN the product sets results or status while the view is collapsed THE search SHALL keep them for the next time it opens and SHALL NOT expand.
SRC-52 THE search SHALL decide the leading icon column for its view as a whole — its suggestions, its query row, its results and the linked headings of its result groups (SRC-16, SRC-42, SRC-44, SRC-57) — as iconSpace says. WHILE iconSpace is auto every row SHALL keep the column, empty where it has no icon, WHERE any suggestion or result of the view has a leading icon — the query row, drawn with the search glyph, counting as one that has —, so that the headlines of the view start on one line, and no row SHALL keep it WHERE none has one; WHILE iconSpace is always every row SHALL keep it, whether or not any has an icon; WHILE iconSpace is never a row SHALL have the column only where it has a leading icon itself. The column kept is comp.search.suggestion.leading-icon.size.regular wide with comp.search.suggestion.container.gap.regular after it, draws nothing and is nothing to assistive technology. WHEN a suggestion or a result is added or removed, or its leadingIcon changes, or the query row is drawn or taken away, THE search SHALL decide again; WHEN iconSpace names a value the search does not define THE search SHALL treat it as auto and in debug builds report the unknown value.
SRC-53 THE search SHALL draw every row of its view — a suggestion, a result, a result group's linked heading — at its density. WHILE density is regular a row SHALL take the regular value of every token of the density axis this spec names (comp.search.suggestion.container.height.regular, comp.search.suggestion.container.padding-block.regular, comp.search.suggestion.container.padding-inline.regular, comp.search.suggestion.container.gap.regular, comp.search.suggestion.leading-icon.size.regular); WHILE density is compact it SHALL take the compact value of each in its place (comp.search.suggestion.container.height.compact, comp.search.suggestion.container.padding-block.compact, comp.search.suggestion.container.padding-inline.compact, comp.search.suggestion.container.gap.compact, comp.search.suggestion.leading-icon.size.compact), so that a compact row is lower, set in less from its edges and draws a smaller glyph, the room kept for an empty leading icon column (SRC-52) shrinking with it. The text styles, the group titles, the status row, the view's surface, its header and the bar SHALL be the same in both. WHEN density names a value the active design system does not have THE search SHALL draw the default density's rows and in debug builds report the unknown value; a density a design system added SHALL be drawn from that density's tokens, as the core values are. WHEN density changes while the view is shown THE search SHALL draw the new rows at once, without a motion, keeping the active row.
SRC-54 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 search 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 search is invalid — except those the search owns (aria-haspopup, aria-expanded, aria-controls, aria-keyshortcuts, aria-disabled), which it SHALL move and not expose. 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 search SHALL take it off that element. WHEN the product sets an aria- attribute the search owns THE search SHALL report it in debug builds.
SRC-55 WHILE inlineCompletion is true and the query row is drawn (SRC-57), WHEN the person inserts text at the end of the value — by typing, or as an input method commits its composition — or the product gives or replaces the suggestions after such an insertion, THE search SHALL complete the value in the input from the first suggestion, in the product's order, whose headline begins with the value and is longer than it, compared as the combobox compares a label with what was typed (CMB-25): it SHALL write the rest of that headline after the value, selected, with the caret before it, without changing value or emitting input, and the query row SHALL show the completed text and stay active. THE search SHALL NOT complete after the person deleted (Backspace, Delete, a cut) or pasted, until they insert text again; WHILE an input method is composing; WHILE the person types on an on-screen keyboard (SRC-14); WHILE the caret is not at the end of the value or the person has selected text; or WHERE no suggestion's headline begins with the value. WHEN the person moves the caret or the selection — an arrow key, Home, End, a press in the input — THE search SHALL accept the completion: the completed text SHALL become the value, input SHALL be emitted once, and the caret SHALL move as the key or the press moves it. WHEN the person presses Backspace or Delete while a completion is shown THE search SHALL take the completion away and nothing else: the value stays as typed, no input is emitted, and nothing is completed again until the person inserts text. Typing a character SHALL replace the completion and go on from the value as typed, which may be completed again; WHEN an input method begins to compose while a completion is shown, its first inserted text SHALL replace the completion as a typed character does, and WHEN the composition is cancelled before it inserted anything THE search SHALL take the completion away as Backspace does: the value stays as typed and no input is emitted. The action key SHALL accept the completion and then submit (SRC-13). WHEN an arrow key makes a suggestion active the input SHALL show that suggestion (SRC-14), and WHEN the query row becomes current again THE search SHALL show the completion again as it was. WHEN the view closes or the input loses focus THE search SHALL take an unaccepted completion away. WHILE inlineCompletion is false or queryRow is none THE search SHALL complete nothing.
SRC-56 WHILE the value is not empty THE search SHALL draw, in the headline of each suggestion that begins with the value — compared as SRC-55 compares —, the rest of the headline, its completion, with its weight raised by comp.search.suggestion.completion.emphasis over the weight of comp.search.suggestion.headline.typescale, in the headline's own color and with no fill, as a web search draws what each suggestion would add to what was typed: the person knows what they typed, and tells the suggestions apart by what each adds. A headline that does not begin with the value SHALL be drawn without emphasis; the query row's headline is the value itself, and only an inline completion shown after it is emphasised (SRC-57, SRC-55). The completion SHALL wrap with the headline as one text, move no letter of it, and be read as part of the headline, without a pause or an announcement. THE search SHALL NOT emphasise anything in a suggestion's supporting text, and the excerpt of a result marks what matched instead (SRC-43).
SRC-57 WHILE queryRow is first, the view shows suggestions and the value is not empty THE search SHALL draw a query row above the first suggestion: a suggestion's row (SRC-16, SRC-17, SRC-19, SRC-20, SRC-53), drawn from the suggestion tokens, holding in its leading icon column the glyph search of the system's icon set, drawn as a suggestion's leading icon and never mirrored (SRC-2), the value as typed as its headline — followed by the inline completion WHILE one is shown, emphasised as SRC-56 says —, and queryRowText as its supporting text WHILE queryRowText is not empty. It is the search's own row and holds no word of the search's own: what it says beside the query is the product's, and the glyph and the query alone are a whole row. It SHALL be the row the search makes active automatically (SRC-14), so that the action key always searches for the value as typed (SRC-13), as the first row of a browser's address bar does; WHEN the person presses it by pointer or touch, or presses the action key while it is active, THE search SHALL submit as SRC-13 says, focus staying in the input, and SHALL NOT emit select. It is never a query of its own to fill the input with: WHEN it becomes current again the input shows the value as typed (SRC-14). THE search SHALL expose it as the first option of the suggestions' listbox, named by its headline and described by queryRowText, counted in the options' positions. WHILE queryRow is none THE search SHALL draw no query row; WHEN queryRow names a value the search does not define THE search SHALL draw the query row as for first and in debug builds report the value.

مطابقة الأسماء بين المنصات

التكافؤ لا يعني واجهات برمجية متطابقة. تعبّر كل منصة عن العقد نفسه بأسلوبها.

المواصفة Web SwiftUI Jetpack Compose Flutter React Native
المكوّن tanrei-search TanreiSearch TanreiSearch TanreiSearch Search
presentation · الخاصية presentation presentation presentation presentation presentation
bar · الخاصية bar bar bar bar bar
value · الخاصية value text value controller value
label · الخاصية label label label semanticLabel accessibilityLabel
placeholder · الخاصية placeholder prompt placeholder hintText placeholder
expanded · الخاصية expanded isExpanded expanded controller expanded
disabled · الخاصية disabled disabled enabled enabled disabled
clearLabel · الخاصية clearLabel clearLabel clearLabel clearLabel clearLabel
backLabel · الخاصية backLabel backLabel backLabel backLabel backLabel
shortcut · الخاصية shortcut shortcut shortcut shortcut shortcut
bindShortcut · الخاصية bindShortcut bindsShortcut bindShortcut bindShortcut bindShortcut
status · الخاصية status status status status status
statusText · الخاصية statusText statusText statusText statusText statusText
queryRow · الخاصية queryRow queryRow queryRow queryRow queryRow
queryRowText · الخاصية queryRowText queryRowText queryRowText queryRowText queryRowText
inlineCompletion · الخاصية inlineCompletion inlineCompletion inlineCompletion inlineCompletion inlineCompletion
wrap · الخاصية wrap wrap wrap wrap wrap
iconSpace · الخاصية iconSpace iconSpace iconSpace iconSpace iconSpace
density · الخاصية density density density density density
input · الحدث input text onValueChange onChanged onChangeText
submit · الحدث submit onSubmit onSearch onSubmitted onSubmitEditing
select · الحدث select onSelect onSelect onSelected onSelect
toggle · الحدث toggle isExpanded onExpandedChange onExpandedChanged onExpandedChange
ملاحظات A form-associated custom element, as the text field is: it takes name and submits its value. It renders an <input type="search" enterkeyhint="search"> in its shadow root, with the web's own cancel button hidden. Attributes are kebab-case (clear-label, back-label, query-row, query-row-text, inline-completion); wrap defaults to true, so its attribute is the inverse, no-wrap, as a boolean attribute cannot default to true. The suggestions are <tanrei-search-suggestion> children; the leading and trailing slots are named slots, and other children are the view's default content. The docked view is a manual popover in the top layer, placed with CSS anchor positioning and a script fallback, with the search's own light dismiss so that toggle carries a reason; a press outside also reaches the element under it. The full-screen view is a <dialog> opened with showModal(). The element sets its own expanded before firing toggle, which is a CustomEvent whose detail holds expanded and reason; submit is cancelable. The inline attribute, for tests, draws the open view in place. The leading glyph is the icon helper's search; the clear and back buttons show close and arrow_back (SRC-2, SRC-10, SRC-11). Not built yet: bar="button" and bar="icon" render a <button> (the icon form a <tanrei-button icon-only>) with aria-haspopup="dialog", aria-expanded and aria-keyshortcuts; the dialog view is a <dialog> opened with showModal(), its scrim the ::backdrop, a press on which closes it with the reason outside; shortcut is an attribute of chords separated by spaces, as the keyboard shortcut's keys; bind-shortcut adds one keydown listener on the window while the element is connected. The status row is a role="status" element that exists from the first render (role="alert" while status="error"). Results are <tanrei-search-result> and <tanrei-search-result-group> children; focus moves to their anchors with focus(), and select on a result is cancelable. The query row is an option of the search's own in its shadow root, first in the listbox (id="query-row"). A suggestion an arrow key reaches is written into the input element without setting value or firing input; the element is written back from value when the person returns. The inline completion is a selection range after the typed text; the input a Backspace fires to take it away, which changes no value, is stopped in the shadow root. An automatic row is named by aria-activedescendant 500 ms after it became current, from a timer each edit restarts and clears. A result's link is its own light-DOM child (the <a>, or the <button> without href), slotted over the row the result draws in its shadow root and drawn as nothing itself, so that the input reaches it as its active descendant by element reflection (ariaActiveDescendantElement): an id cannot cross a shadow root, and reflection reaches out into the document, never into another shadow root. An on-screen keyboard (SRC-14) is told by the pointerType of the press that focused the input — touch or pen — and a hardware keyboard by its arrow and caret keys; (pointer: coarse) describes only the primary pointer, and the VirtualKeyboard API is Chromium's alone. TanreiSearch(_ label:, text: Binding<String>, isExpanded: Binding<Bool>, presentation:, prompt:, clearLabel:, backLabel:, onSubmit:, onSelect:) { suggestions } leading: { … } trailing: { … } content: { … }. Every edit writes the text binding, which is the input event; opening and closing write isExpanded, which is toggle (the reason is passed to an optional onToggle). SwiftUI's .searchable is not used: its field and suggestions cannot take the tokens. The docked view is drawn in an overlay above the window's content, anchored to the bar, not with .popover, which is modal at compact widths and would take focus from the field (SRC-8). The full-screen view is presented with .fullScreenCover, with the system transition off, as the dialog is. The input has the search-field trait. disabled follows .disabled(_:). Snapshot harness: renders the bar and the open view in place, as the menu and the dialog do. Without an installed icon font it strokes the search and back glyphs as shapes of its own (TanreiSearchMagnifierShape, TanreiSearchBackArrowShape) instead of drawing nothing (SRC-2, SRC-30). Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut (where bindsShortcut would be .keyboardShortcut on the trigger), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Compose idiom, as Material's SearchBar with its input field: TanreiSearch(value, onValueChange, expanded, onExpandedChange, label, modifier, presentation, placeholder, enabled, clearLabel, backLabel, onSearch, onSelect, leading, trailing) { suggestions and content }. State hoisting: the caller keeps value and expanded and moves them from onValueChange and onExpandedChange, which receives the new value and the reason. enabled is the inverse flag. Built on BasicTextField with the search IME action. The docked view is a Popup that does not take focus; the full-screen view is a Dialog window with usePlatformDefaultWidth = false and the window's own dim off, as the dialog's. Compose has no combobox or listbox role: the suggestions are buttons in a column with collection semantics. Snapshot harness: renders the bar and the open view in place. Without an installed icon font it strokes the clear button's close as a vector of its own (TanreiDrawnGlyph), and draws search and arrow_back as their names in the platform font, clipped to the box (TanreiNamedGlyph), instead of drawing nothing (SRC-2, SRC-30). Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, bindShortcut (a key handler on the window's root, where a hardware keyboard exists), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Flutter idiom, as Material's SearchAnchor and SearchController but without Material: TanreiSearch(controller: TanreiSearchController, semanticLabel:, presentation:, hintText:, enabled:, clearLabel:, backLabel:, onChanged:, onSubmitted:, onSelected:, onExpandedChanged:, leading:, trailing: [...], suggestions: [...], child:). TanreiSearchController is a TextEditingController that also holds isExpanded with expand() and collapse(); the search updates it itself and calls onExpandedChanged with the value and the reason. The input is EditableText with TextInputAction.search and SemanticsInputType.search (Flutter 3.32, the oldest version supported, asserts on SemanticsRole.searchBox). The docked view is drawn through an OverlayPortal; the full-screen view is a modal route that scopes semantics, as the dialog's. Snapshot harness: a golden of the bar and the open view. Lagging behind SRC-30: it writes the built-in glyphs as Material Symbols code points (tanreiSearchGlyph, tanreiCloseGlyph, tanreiArrowBackGlyph), and without the icon font it draws whatever the fallback face has at those code points instead of nothing. Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, bindShortcut (a HardwareKeyboard handler), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Controlled, in TextInput's idiom: <Search value onChangeText expanded onExpandedChange accessibilityLabel placeholder presentation clearLabel backLabel onSubmitEditing onSelect suggestions={[…]} leading trailing insets>{content}</Search>; the caller moves value and expanded from onChangeText and onExpandedChange, which receives the new value and the reason. The input is a TextInput with returnKeyType="search" and accessibilityRole="search". The docked view is on the overlay layer that TanreiProvider renders, not a Modal (which would take focus from the field); the full-screen view is a transparent Modal with statusBarTranslucent and navigationBarTranslucent, its insets from the insets prop or TanreiProvider's. Android's back button (BackHandler) closes the view. Snapshot harness: renders the bar and the open view in place. Lagging behind SRC-30: without the icon font the built-in glyphs print their ligature names. Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds; bindShortcut does nothing where there is no hardware keyboard event to listen to, and the README says so.

الرموز

الرمز يشير إلى القيمة المحلولة (فاتح)
--tanrei-comp-search-container-button-gap sys.space.space0 0px
--tanrei-comp-search-container-gap — 16px
--tanrei-comp-search-container-height — 56px
--tanrei-comp-search-container-padding-inline sys.space.space200 16px
--tanrei-comp-search-container-padding-inline-with-button sys.space.space100 8px
--tanrei-comp-search-container-shape sys.shape.corner.full 9999px
--tanrei-comp-search-disabled-opacity — 1
--tanrei-comp-search-disabled-outline-width — 1px
--tanrei-comp-search-divider-color sys.color.outline-variant #000000 · 8%
--tanrei-comp-search-divider-thickness sys.border.hairline 1px
--tanrei-comp-search-focused-opacity — 1
--tanrei-comp-search-focused-outline-width — 2px
--tanrei-comp-search-group-title-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-group-gap sys.space.space100 8px
--tanrei-comp-search-group-indent sys.space.space300 24px
--tanrei-comp-search-header-height — 72px
--tanrei-comp-search-header-padding-inline sys.space.space100 8px
--tanrei-comp-search-hovered-opacity — 1
--tanrei-comp-search-hovered-outline-width — 1px
--tanrei-comp-search-leading-icon-size sys.icon.medium 24px
--tanrei-comp-search-motion-close-duration sys.motion.role.appear.anchored.exit 250ms
--tanrei-comp-search-motion-close-easing sys.motion.easing.exit cubic-bezier(0.3, 0, 1, 1)
--tanrei-comp-search-motion-feedback-duration sys.motion.role.feedback 450ms
--tanrei-comp-search-motion-open-duration sys.motion.role.appear.anchored.enter 300ms
--tanrei-comp-search-motion-open-easing sys.motion.easing.enter cubic-bezier(0.2, 0, 0, 1)
--tanrei-comp-search-motion-state-duration sys.motion.role.state.default 250ms
--tanrei-comp-search-motion-state-easing sys.motion.easing.state cubic-bezier(0.2, 0, 0, 1)
--tanrei-comp-search-outline-width sys.border.hairline 1px
--tanrei-comp-search-pressed-opacity — 1
--tanrei-comp-search-pressed-outline-width — 1px
--tanrei-comp-search-result-mark-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-result-mark-container-color sys.color.secondary-container #eeeeee
--tanrei-comp-search-result-mark-emphasis sys.typescale.emphasis.body 100
--tanrei-comp-search-shortcut-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-caret-color sys.color.primary #1b1b1b
--tanrei-comp-search-standard-container-color sys.color.surface-container-highest #eeeeee
--tanrei-comp-search-standard-container-elevation sys.elevation.level0
--tanrei-comp-search-standard-disabled-caret-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-container-color — #eeeeee
--tanrei-comp-search-standard-disabled-container-elevation —
--tanrei-comp-search-standard-disabled-input-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-leading-icon-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-outline-color — #000000 · 0%
--tanrei-comp-search-standard-disabled-placeholder-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-state-layer-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-container-color — #000000 · 0%
--tanrei-comp-search-standard-disabled-suggestion-headline-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-leading-icon-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-state-layer-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-supporting-text-color — #1b1b1b · 38%
--tanrei-comp-search-standard-focused-caret-color — #1b1b1b
--tanrei-comp-search-standard-focused-container-color — #eeeeee
--tanrei-comp-search-standard-focused-container-elevation —
--tanrei-comp-search-standard-focused-input-color — #1b1b1b
--tanrei-comp-search-standard-focused-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-focused-outline-color — #0070ac
--tanrei-comp-search-standard-focused-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-focused-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-container-color — #1b1b1b · 10%
--tanrei-comp-search-standard-focused-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-focused-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-hovered-caret-color — #1b1b1b
--tanrei-comp-search-standard-hovered-container-color — #dddddd
--tanrei-comp-search-standard-hovered-container-elevation —
--tanrei-comp-search-standard-hovered-input-color — #1b1b1b
--tanrei-comp-search-standard-hovered-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-hovered-outline-color — #000000 · 0%
--tanrei-comp-search-standard-hovered-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-hovered-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-container-color — #1b1b1b · 8%
--tanrei-comp-search-standard-hovered-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-hovered-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-input-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-standard-leading-icon-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-outline-color — #000000 · 0%
--tanrei-comp-search-standard-placeholder-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-pressed-caret-color — #1b1b1b
--tanrei-comp-search-standard-pressed-container-color — #d9d9d9
--tanrei-comp-search-standard-pressed-container-elevation —
--tanrei-comp-search-standard-pressed-input-color — #1b1b1b
--tanrei-comp-search-standard-pressed-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-pressed-outline-color — #000000 · 0%
--tanrei-comp-search-standard-pressed-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-pressed-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-container-color — #1b1b1b · 10%
--tanrei-comp-search-standard-pressed-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-pressed-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-state-layer-color comp.search.standard.input.color #1b1b1b
--tanrei-comp-search-standard-suggestion-container-color — #000000 · 0%
--tanrei-comp-search-standard-suggestion-headline-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-standard-suggestion-leading-icon-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-suggestion-state-layer-color comp.search.standard.suggestion.headline.color #1b1b1b
--tanrei-comp-search-standard-suggestion-supporting-text-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-status-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-status-error-color sys.color.error #cd262f
--tanrei-comp-search-suggestion-completion-emphasis — 300
--tanrei-comp-search-suggestion-container-gap-compact comp.tree-view.container.gap.compact 8px
--tanrei-comp-search-suggestion-container-gap-regular sys.space.space200 16px
--tanrei-comp-search-suggestion-container-height-compact comp.tree-view.container.height.compact 32px
--tanrei-comp-search-suggestion-container-height-regular — 56px
--tanrei-comp-search-suggestion-container-padding-block-compact — 4px
--tanrei-comp-search-suggestion-container-padding-block-regular — 8px
--tanrei-comp-search-suggestion-container-padding-inline-compact comp.tree-view.container.padding-inline.compact 8px
--tanrei-comp-search-suggestion-container-padding-inline-regular sys.space.space200 16px
--tanrei-comp-search-suggestion-container-shape — 4px
--tanrei-comp-search-suggestion-leading-icon-size-compact sys.icon.small 20px
--tanrei-comp-search-suggestion-leading-icon-size-regular sys.icon.medium 24px
--tanrei-comp-search-trigger-container-gap sys.space.space100 8px
--tanrei-comp-search-trigger-container-height — 40px
--tanrei-comp-search-trigger-container-padding-inline sys.space.space150 12px
--tanrei-comp-search-trigger-leading-icon-size sys.icon.small 20px
--tanrei-comp-search-view-container-color sys.color.surface-bright #ffffff
--tanrei-comp-search-view-container-elevation sys.elevation.level2 0px 0px 0px 1px rgb(0 0 0 / 0.08), 0px 1px 2px 0px rgb(0 0 0 / 0.04)
--tanrei-comp-search-view-container-shape sys.shape.corner.medium 8px
--tanrei-comp-search-view-dialog-max-width — 640px
--tanrei-comp-search-view-dialog-offset sys.space.space800 64px
--tanrei-comp-search-view-offset sys.space.space50 4px
--tanrei-comp-search-view-padding-block sys.space.space50 4px
--tanrei-comp-search-view-padding-inline sys.space.space50 4px
--tanrei-comp-search-view-scrim-blur comp.modal-layer.scrim.blur 0px
--tanrei-comp-search-view-scrim-color comp.modal-layer.scrim.color #000000 · 40%
--tanrei-comp-search-view-viewport-margin sys.space.space100 8px
--tanrei-comp-search-group-title-typescale sys.typescale.label-small 500 12px/1.3333
--tanrei-comp-search-input-typescale sys.typescale.body-large 400 16px/1.625
--tanrei-comp-search-shortcut-typescale sys.typescale.label-small 500 12px/1.3333
--tanrei-comp-search-status-typescale sys.typescale.body-small 400 13px/1.5385
--tanrei-comp-search-suggestion-headline-typescale sys.typescale.body 400 14px/1.5714
--tanrei-comp-search-suggestion-supporting-text-typescale sys.typescale.body-small 400 13px/1.5385
--tanrei-comp-search-trigger-label-typescale sys.typescale.body 400 14px/1.5714

نماذج الاختبار

عروض مرجعية. تلتقط كل المنصات لقطة لكل نموذج بالمعرّف نفسه حتى يمكن مقارنة النتائج.

مولَّد من specs/search.spec.json, tokens/comp/search.tokens.json, design/tokens/

الإرشادات

متى يُستخدم

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

واستخدمه بحثًا في موقع أيضًا: مشغِّل في الترويسة يفتح مربع حوار، والصفحات والأقسام التي وُجدت روابط فيه.

لتصفية قائمة قصيرة موجودة على الشاشة سلفًا، أو لإدخال عبارة بحث في نموذج، يكفي حقل نص قيمة type فيه search. واختيار قيمة واحدة من قائمة ثابتة مهمة قائمة خيارات أو قائمة، لا مهمة بحث.

الشريط أو مشغِّل

bar ما الذي يقف في الصفحة يفتح يُستخدم لـ
field (الافتراضي) الشريط مع حقل إدخاله أي طريقة عرض منتج يكون البحث فيه طريقًا رئيسيًّا، وللشريط مكان خاص به
button مشغِّل في هيئة الشريط: الرسم والنص النائب وتلميح الاختصار عرضًا نمطيًّا: مربع الحوار أو ملء الشاشة ترويسة فيها متسع، والبحث فيها واحد من عدة أشياء
icon زر بأيقونة فقط فيه رسم البحث عرضًا نمطيًّا: مربع الحوار أو ملء الشاشة ترويسة لا متسع فيها، كما في نافذة ضيقة

المشغِّل تسمّيه label، والمشغِّل الذي في هيئة زر يعرض النص النائب، أو التسمية حيث لا نص نائب. وحين يُغلق عرضه يعود التركيز إلى المشغِّل.

مُرسى أم مربع حوار أم ملء الشاشة

طريقة العرض أين يُفتح العرض التركيز يُستخدم لـ
المُرسى (الافتراضي) تحت الشريط، بعرضه، فوق المحتوى يبقى في حقل إدخال الشريط. لا شيء آخر يصير خاملًا (inert)، ولا حجاب النوافذ الكبيرة، حيث يستطيع العرض أن يُفتح من دون أن يحجب الشاشة كلها
مربع الحوار قرب أعلى النافذة، متوسطًا، حتى عرض أقصى، فوق حجاب. يبقى أعلاه في مكانه ومحتواه يتغيّر ينتقل إلى حقل الإدخال في الترويسة، ويبقى في العرض، ويعود إلى المشغِّل أو الشريط حين يُغلق النوافذ الكبيرة، مفتوحًا من مشغِّل: بحث في موقع
ملء الشاشة فوق النافذة كلها، بترويسته وزر الرجوع والفاصل الخاصة به ينتقل إلى حقل الإدخال في الترويسة، ويبقى في العرض، ويعود إلى الشريط أو المشغِّل حين يُغلق النوافذ الصغيرة، حيث لا تترك الاقتراحات ولوحة المفاتيح التي على الشاشة متسعًا لشيء آخر

الاستعلام واحد في الثلاثة. وتبديل presentation عند نقطة تحوّل لا يغيّره.

زرّا المسح والرجوع

كلاهما مبني في المكوّن، لأن سلوكهما من شأن البحث: المسح يفرّغ الاستعلام ويُبقي العرض والتركيز حيث هما، والرجوع يغلق عرض ملء الشاشة. ويجب أن يكون اسماهما بلغة منتجك، فأنت تعطيهما: clearLabel («مسح البحث»)، ثم backLabel («رجوع») لمربع الحوار وملء الشاشة. على iOS زر الرجوع هو المخرج الوحيد من عرض ملء الشاشة. وترويسة مربع الحوار فيها زر الرجوع أيضًا، ليستطيع من ليس عنده المفتاح Escape ولا مؤشر أن يغادره.

الاقتراحات والنتائج ومحتواك

  • الاقتراح استعلام؛ والنتيجة مكان يُذهب إليه. الاقتراح يساعد على إتمام الاستعلام، ومفاتيح الأسهم تجعله نشطًا والتركيز باقٍ في حقل الإدخال. والنتيجة شيء وجده بحثك: رابط يأخذ التركيز بنفسه.
  • لا تضف الاستعلام كما كُتب إلى اقتراحاتك: فهذا هو صف الاستعلام. وقدّم queryRowText بلغة منتجك حين ينبغي أن يقول الصف ماذا يفعل Enter (“البحث في كل البريد”، “اسأل المساعد”).
  • اختر الشكل بحسب طبيعة البحث. أبقِ صف الاستعلام (الافتراضي) حيث ينبغي أن يبحث Enter دائمًا عمّا كُتب، كما في شريط العناوين أو البحث في البريد. واستخدم queryRow="none" لصفحة بحث تظهر اقتراحاتها تحت الحقل، كصفحة محرك البحث على الويب. أما البحث الذي صفوفه كلها نتائج، كالبحث داخل التوثيق، فلا يحتاج إلى أيّ منهما: نتيجته الأولى هي التي يفتحها Enter.
  • استخدم inlineCompletion فقط حيث يكتب الناس أشياء معروفة حتى آخرها، كالعناوين أو الأسماء، ويوفّر عليهم الإكمال ضغطات. فصفحات البحث لا تُكمل داخل الحقل.
  • استخدم الأيقونة التي في البداية للتفريق بين الأنواع: السجل لاستعلام سابق، ومجلد، وصفحة، وقسم.
  • حين لا تكون الأيقونة إلا لبعض الصفوف، تقرر الخاصية iconSpace من أين تبدأ الصفوف الأخرى عنوانها. تحتفظ auto (الافتراضية) بمساحة الأيقونة فارغةً في كل صف من العرض ما دام لأي اقتراح أو نتيجة أيقونة، لتصطف العناوين؛ وتحتفظ بها always في كل صف، وnever في الصف الذي له أيقونة فقط. وفي قائمة الخيارات الخاصية iconSpace نفسها، بالقيم نفسها والقيمة الافتراضية نفسها.
  • تحدد density المساحة التي يأخذها صف في العرض: regular (الافتراضية، بارتفاع 56) أو compact (بارتفاع 32 ورمز بحجم 20)، للوحة أوامر أو لأداة تُستخدم بالفأرة ولوحة المفاتيح. لا يتغير الشريط ولا النص. باللمس لا يكون الصف أبدًا أقل من هدف اللمس.
  • أبقِ العناوين الرئيسية قصيرة وضع التفاصيل في النص المساعد أو المقتطف: «الفواتير»، ثم «مجلد · 24 رسالة». وهي تلتفّ ولا تُقتطع.
  • ميِّز في المقتطف ما طابق. والتمييز من النظام، لون ووزن أثقل وتعبئة هادئة خلف المطابقة، فتظهر المطابقات بالمظهر نفسه في كل مكان وتُوجد في كل نظام كتابة، حتى حيث لا يملك الخط وزنًا بين العادي والعريض.
  • اجمع النتائج حين تنتمي إلى بعضها: الأقسام تحت صفحتها، والرسائل تحت «الرسائل». وعنوان المجموعة رابط حين تكون المجموعة نفسها مكانًا.
  • أعطِ النتيجة href كلما كان لها عنوان. يستطيع الشخص عندئذ أن يفتحها في تبويب جديد، وأن ينسخ عنوانها، وأن يرى إلى أين تقود. استخدم select من دون href فقط لنتيجة يفتحها منتجك بنفسه.
  • ترتيب العرض ثابت: الاقتراحات، ثم صف الحالة، ثم النتائج، ثم محتواك أنت، كزر «تحميل نتائج أخرى» أو رابط إلى صفحة نتائج كاملة.
  • العرض المُرسى الذي ليس فيه ما يُعرض لا يرسم شيئًا، ويبقى البحث مفتوحًا، فيظهر ثانية ما إن يوجد شيء.

الحالة

  • عيِّن statusText مرة واحدة لكل جواب: «12 نتيجة عن الرموز»، «لا نتائج عن الرمزو». فهو يُعلَن حين يتغيّر، وتغييره عند كل ضغطة مفتاح ضجيج.
  • عيِّن status بالقيمة loading ما دام استعلام يجري. مؤشر التحميل لا يظهر إلا بعد مهلة قصيرة، فالجواب السريع لا يعرضه.
  • عيِّن status بالقيمة error مع نص يقول ما حدث. يُرسم خطأً ويُعلَن فورًا.
  • أهمِل الأجوبة التي تصل على غير ترتيبها. البحث يرسم آخر ما عيّنته أيًّا كان.

الاختصار

  • استخدم اختصارًا يعرفه الناس سلفًا للبحث في نوع منتجك، واكتبه بالمفتاح mod ليكون صحيحًا على كل لوحة مفاتيح.
  • عيِّن bindShortcut على بحث واحد في الشاشة. من بين بحثين يربطان المفاتيح نفسها يحتفظ بها الذي عُرض أولًا، وتبلّغ بنيات التنقيح (debug) عن الآخر.
  • الاختصار الذي بلا مفتاح تعديل، مثل /، يُتجاهل ما دام التركيز في حقل إدخال نصي، ليستطيع الشخص كتابة المحرف.
  • إذا ربطت مفتاح محرف واحدًا بلا مفتاح تعديل، مثل /، فوفّر طريقة لإيقافه أو لتغييره (WCAG 2.1.4، اختصارات مفاتيح المحارف). وbindShortcut معطَّل افتراضيًا.
  • من دون bindShortcut يعرض التلميح المفاتيح فقط: اربطها بنفسك، أو اترك shortcut فارغة.

افعل

  • اكتب نصًّا نائبًا يقول ما الذي يمكن البحث فيه: «ابحث في البريد». وعيِّن label أيضًا: النص النائب ليس الاسم أبدًا.
  • حدِّث الاقتراحات كلما تغيّر الاستعلام، وأبقِها في ترتيب ثابت والشخص يتنقل بينها. وضع أقربها إلى المطلوب أولًا: ضغطة واحدة على مفتاح السهم للأسفل تصل إليه، ومع inlineCompletion يُكمَل الاستعلام منه.
  • عند select افعل ما يعد به الاقتراح: افتح نتيجة، أو ضع استعلامًا في الشريط وأجرِه.
  • اقصر منفذ النهاية على زرَّي أيقونة على الأكثر.
  • أعطِ targetLabel («يُفتح في تبويب جديد») للنتيجة التي قيمة target فيها new.

لا تفعل

  • لا تفتح العرض لمجرد أن الشريط تلقّى التركيز. البحث يتجنب ذلك سلفًا؛ فلا تُعده أنت.
  • لا تضع في عرض مُرسى عناصر تحكم تحتاج إلى تركيز خاص بها، كحقل نص. الضغط على العرض المُرسى يترك التركيز في حقل الإدخال.
  • لا تغيّر الاستعلام حين يصير اقتراح نشطًا. فالبحث يعرضه في حقل الإدخال دون أن يغيّر value أو يُصدر input؛ ولا يغيّر الاستعلام إلا اختيار (select) أو كتابة الشخص أو إكمال مقبول.
  • لا تستخدم بحثًا لاختيار قيمة في نموذج.
  • لا تضع عنوان النتيجة في select وحده. الصف الذي بلا href زر، ولا يستطيع الشخص أن يفتحه في تبويب جديد.
  • لا تميّز المطابقات بنفسك باللون وحده، ولا تضع في مقتطف ترميزًا مجهول المصدر. على الويب محتوى المقتطف لك: ما تضعه فيه يُعرض كما هو.

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

الدور
searchbox
التسمية
label names the search field, the trigger, the suggestions' list, the results' list and the modal views; it is never the placeholder. A suggestion is named by its headline and described by its supporting text; a result by its headline and its excerpt, read as one text with no mention of the marks; a result group by its headline. The status text is announced when it changes, and the loading indicator is named by it. The clear and back buttons are named by clearLabel and backLabel; the slots' icon-only Buttons by their own labels. The search glyph, the leading icons, the drawn shortcut keys, the scrim and the divider are decorative; the shortcut is exposed as the trigger's or the input's keyboard shortcut.
الحد الأدنى للهدف
تستوفي مساحة اللمس الحد الأدنى لحجم الهدف حتى لو كان الحجم المرئي أصغر. minimum 32px · pointer 44px · spacing 8px · touch 48px

لوحة المفاتيح

المفاتيح الإجراء
Tab / Shift+Tab Moves focus to the leading icon-only Button, the input, the clear button and the trailing icon-only Buttons in turn, or to the trigger. With the docked view open, leaves the search and closes the view. In a modal view (dialog, full-screen) focus stays inside it and Tab goes through the header's controls, the results and the product's own content.
Enter / Space on the trigger Opens the modal view and moves focus to its input.
The shortcut Where the search binds it (bindShortcut): opens the search from anywhere in the window, and closes it again while it is open.
Typing Edits the value and opens the view while it is closed. With suggestions, the first row is the one Enter takes: the query row — the query as typed, so that Enter searches for it — or, with queryRow none, no row, so that Enter does the same. With results and no suggestions, the first result is current, so that Enter opens it. On an on-screen keyboard (the input focused by a touch or a pen) nothing is, so that its Search or Go key submits the query as typed. With inlineCompletion, the query is completed in the input from the first suggestion that begins with it. While a result has focus, returns focus to the input and edits there.
Down Arrow / Up Arrow Opens the view while it is closed. While it is open, moves through the rows in order: the query row (with queryRow none, the input's own place), the suggestions, then the results, across groups; on a suggestion focus stays in the input, and a result takes focus. Down Arrow goes on from the row Enter takes now, so the first press reaches the second row. A suggestion an arrow key reaches is shown in the input without changing the query, and the query as typed comes back on the query row or the input's place. At the ends they go round — Down on the last row to the first, Up on the first to the last — unless wrap is false, which stops them. The row an arrow key moves to is read out at once; a row the search made current is read once typing pauses for half a second.
Left Arrow, Right Arrow, Home, End Move the caret, and leave the row Enter takes as it is. With an inline completion shown, accept it: the completed query becomes the value.
Backspace / Delete, an inline completion shown Takes the completion away and leaves the query as typed; nothing is completed again until the person types.
Enter In the input: chooses the active suggestion (select) or opens the current result; on the query row, or with no row active, submits the value (submit) — completed first where an inline completion is shown — which closes the view unless it shows results or a status. On an on-screen keyboard nothing is made current by itself, so its Search or Go key submits the value as typed. While an input method is composing, Enter confirms the conversion and does nothing else. With Command (Control off Apple keyboards) or Shift, Enter in the input opens the current result in a new tab or a new window, as the link would with that modifier: nothing is emitted and the view stays. On a result: follows the link, as the platform does, modifier keys included.
Enter / Space on the back button Closes the modal view (dialog, full-screen) and returns focus to the bar's input or the trigger: the way out for a person who has neither Escape nor a pointer.
Escape Closes the view and returns focus to the bar's input or the trigger; while the view is closed, clears the value.

ملاحظات

  • Two patterns, by what a row is. Suggestions are queries, in the WAI-ARIA combobox pattern with a listbox popup on the web, in every view: focus stays in the input, and the query as typed is always what Enter takes until the person moves. By default (queryRow first) it is a row of its own, first and active, as the first row of a browser's address bar is (list autocomplete with automatic selection); with queryRow none the input itself is that place and nothing is active, as on a web search page (list autocomplete with manual selection). The arrow keys move through the suggestions and show each in the input without changing the query, and go round at the ends unless wrap is false. inlineCompletion completes the query in the input from a suggestion that begins with it, as an address bar does (list and inline autocomplete). A query suggestion draws what it adds to the query heavier; a result marks what matched. Results are destinations: links in a list, never options, in every view: an option cannot be a link, and a result has to be one (open in a new tab, copy the address, the visited color). Where the view holds results and no suggestion, the first result is current while focus stays in the input, drawn as focused and opened by Enter, as a documentation search does; a result takes real focus once the person moves to it, and the input is a combobox only while the view shows suggestions. A row the search made current by itself — the query row, the first result — is announced once typing pauses for half a second, as React Aria's autocomplete does, so that a screen reader reads the typed character first and then what Enter takes, and not a row after every key; a row an arrow key moves to is announced at once. The dialog and full-screen views are modal dialogs that hold the search field and those links, the pattern of a site search; the docked view with suggestions only is the combobox it was. SwiftUI, Compose, Flutter and React Native have no combobox role: their input is a search field, suggestions are buttons and results are buttons with the link trait or role, each with its position in its list.
  • Overlays: the docked view is an operated overlay that is not modal, and its focus is the input it belongs to until an arrow key takes it to a result; the dialog and full-screen views are modal overlays that take focus, keep it and return it to the bar's input or the trigger.
  • The search never runs a query (SRC-51). The product listens to input, waits as long as its index needs before asking (nothing for an index in memory; a few hundred milliseconds for one over the network), drops an answer that arrives after a newer question, sets status to loading only while it truly waits, and sets statusText once per answer, so that the count is announced once.
  • A shortcut is the product's unless bindShortcut is true. The keyboard shortcut component never listens (KBS-14); the search may, because the command the keys perform is its own: open me.
  • Who closes the view: the search emits toggle; where expanded is a binding or controller (SwiftUI, Flutter) or the element's own property (the web) the search closes it itself, and on Compose and React Native the product sets expanded from toggle, as for the menu.
  • The input edits text as the text field does (TXI-1, TXI-4, TXI-20, TXI-24), and its selection is the text field's pair: comp.input-box.selection.color behind the text, comp.input-box.selection.content.color for it.
  • Heights are minimums: at 200% text size the bar and the header grow, the value stays on one line, and suggestion rows wrap.
  • 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.
  • WCAG 2.5.8 (target size): for touch every row of the view is at least the touch target high in both densities (SRC-16). The compact density is lower than the pointer target for a fine pointer, by design: it is the density of a tool used with a mouse and the keyboard, it stays above the 24 by 24 the criterion asks, and its rows reach across the view's whole width. A product that cannot accept that uses regular.

مولَّد من specs/search.spec.json, tokens/sys/measure.tokens.json

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

  • حقل الإدخال حقل بحث تسمّيه label، لا النص النائب أبدًا، وله دور البحث الخاص بالمنصة حيث يكون لها دور كهذا.
  • على الويب يتبع العرض المُرسى نمط WAI-ARIA لمربع التحرير والسرد (combobox). ما دامت الاقتراحات معروضة يكون حقل الإدخال مربع تحرير وسرد مع aria-autocomplete="list" (و both مع inlineCompletion) و aria-expanded، و aria-controls تسمّي القائمة، و aria-activedescendant تسمّي الخيار النشط. والاقتراحات مربع قائمة (listbox) تسمّيه label: أولًا صف الاستعلام، يسمّيه الاستعلام ويصفه queryRowText، ثم كل اقتراح، يسمّيه عنوانه الرئيسي ويصفه نصه المساعد. والخيار النشط هو الخيار المحدَّد.
  • الصف الذي يجعله البحث نشطًا بنفسه، أي صف الاستعلام، تسمّيه aria-activedescendant حين تتوقف الكتابة نصف ثانية، كما يفعل الإكمال التلقائي في React Aria: فيقرأ قارئ الشاشة الحرف المكتوب أولًا، ثم ما سيأخذه Enter، ولا يقرأ صفًّا بعد كل مفتاح. أما الصف الذي ينتقل إليه مفتاح سهم فيُسمّى في الحال. والجزء المرسوم بخط أثقل في الاقتراح يُقرأ جزءًا من عنوانه الرئيسي.
  • التركيز في العرض المُرسى يبقى في حقل الإدخال. يصبح صف الاستعلام نشطًا ما إن يعرض العرض اقتراحات، ويعود نشطًا كلما تغيّر الاستعلام أو الاقتراحات؛ ومع queryRow="none" لا يكون شيء نشطًا، ويكون حقل الإدخال نفسه الموضع الذي يسبق الاقتراح الأول. وأول ضغطة على مفتاح السهم للأسفل تنتقل إلى الصف الذي يلي الصف النشط. وعند الطرفين تدور المفاتيح، ما لم تكن wrap بالقيمة false. وحين يكون صف نشط خارج المنظور جزئيًّا يمرّره العرض إلى الداخل.
  • على لوحة مفاتيح الشاشة لا يصبح شيء نشطًا من تلقاء نفسه، لا صف الاستعلام ولا نتيجة، ولا يُكمَل شيء، فيرسل مفتاح البحث أو الانتقال في اللوحة الاستعلام كما كُتب، كما يفعل حقل البحث على الهاتف، ويختار الشخص الاقتراح بلمسه. ويَعُدّ البحث اللوحة لوحة شاشة حين يمنح لمسٌ أو قلم حقلَ الإدخال التركيز، ويعدّها لوحة مفاتيح فعلية من جديد بعد مفتاح سهم أو مفتاح يحرّك المؤشر أو ضغطة بالفأرة على الحقل. فوجود شاشة لمس في الجهاز لا يدل على اللوحة المستخدمة في حاسوب محمول بشاشة لمس أو جهاز لوحي موصول بلوحة مفاتيح.
  • ما دام أسلوب الإدخال يركّب النص، فالمفاتيح Enter و Escape والأسهم له، ولا يكون شيء نشطًا ولا يُكمَل شيء. والمفتاح Enter الذي يؤكد التحويل لا يختار شيئًا، ويصبح صف الاستعلام نشطًا بعد تثبيت النص.
  • عرض ملء الشاشة وعرض مربع الحوار مربعا حوار نمطيان تسمّيهما label. ينتقل التركيز إلى حقل الإدخال في الترويسة ومؤشر الكتابة (caret) في نهاية الاستعلام، ويبقى داخل العرض، ويصير كل ما هو خارجه خاملًا (inert) ومخفيًّا. وحين يُغلق العرض يعود التركيز إلى حقل إدخال الشريط أو إلى المشغِّل، ولا يُفتح العرض ثانية.
  • المشغِّل زر تسمّيه label، يقول إنه يفتح مربع حوار وما إذا كان عرضه مفتوحًا. ويعرض تركيز لوحة المفاتيح كما يعرضه الشريط.
  • الضغط على حجاب مربع الحوار يغلقه ولا يصل إلى شيء تحته. وتبدأ ترويسته بزر الرجوع، ويبلغه المفتاح Tab.
  • النتائج قائمة تسمّيها label، والمجموعة يسمّيها عنوانها الرئيسي. النتيجة التي لها href رابط، وليست خيارًا أبدًا؛ ولا يكون حقل الإدخال مربع تحرير وسرد إلا ما دام العرض يعرض اقتراحات. والنتيجة يسمّيها عنوانها الرئيسي ويصفها مقتطفها، ثم targetLabel حين تُفتح في سياق جديد.
  • حين تكون هناك نتائج ولا اقتراحات، تكون النتيجة الأولى هي النتيجة الحالية ما دام التركيز في حقل الإدخال. تُرسم كما تُرسم النتيجة التي عليها التركيز، والمفتاح Enter في حقل الإدخال يفتحها كما يفتحها Enter على الرابط نفسه. وحين تتوقف الكتابة نصف ثانية يصبح رابطها العنصر الفرعي النشط لحقل الإدخال، فيقرأ قارئ الشاشة ما سيفتحه Enter؛ ويبقى الحقل مربع بحث. ومفتاح السهم للأسفل ينقل التركيز إلى النتيجة الثانية، ثم عبر النتائج التالية، مرورًا بالمجموعات. ومع Command (أو Control في لوحات المفاتيح الأخرى) أو Shift يفتح Enter في حقل الإدخال النتيجة الحالية في علامة تبويب جديدة أو نافذة جديدة، كما تفعل تلك الضغطة على الرابط؛ ولا يُرسل شيء ويبقى العرض مفتوحًا ليفتح الشخص نتيجة أخرى.
  • حين تكون في العرض اقتراحات، فمفتاح السهم للأسفل على الاقتراح الأخير ينقل التركيز إلى النتيجة الأولى، ومفتاح السهم للأعلى على النتيجة الأولى يعود إلى حقل الإدخال والاقتراح الأخير نشط. والكتابة أو الحذف أو اللصق على نتيجة ينقل التركيز إلى حقل الإدخال، وهناك يعمل المفتاح. وفي العرض النمطي يمرّ المفتاح Tab على النتائج كما يمرّ على أي روابط.
  • صف الحالة منطقة حيّة (live region). تُعلَن statusText حين تتغيّر، وتُعلَن فورًا تنبيهًا (alert) ما دامت status بالقيمة error. وفي أثناء التحميل توسَم النتائج بأنها مشغولة (busy) ويسمّي مؤشرَ التحميل النصُّ statusText.
  • الاختصار يُعرض على أنه اختصار لوحة المفاتيح للمشغِّل أو لحقل الإدخال. وتلميحه لا يأخذ ضغطًا ولا تركيزًا.
  • وصول التركيز إلى حقل الإدخال لا يفتح العرض أبدًا، سواء بالمفتاح Tab أو بالعودة من عرض ملء الشاشة.
  • المفتاح Escape وإجراء الرجوع الخاص بالمنصة وزر الرجوع تغلق العرض. والعرض المُرسى يُغلق أيضًا بالمفتاح Tab أو Shift+Tab، أو بضغط في الخارج، أو بمغادرة التركيز للبحث.
  • زرّا المسح والرجوع زرّا أيقونة من Tanrei تسمّيهما clearLabel و backLabel. وبعد المسح يعود التركيز إلى حقل الإدخال.
  • أزرار الأيقونات التي من عندك في المنفذين leading و trailing تحتفظ بأسمائها وأدوارها ومواضع توقف التركيز الخاصة بها، بترتيب القراءة. ولا تُعرض في ترويسة ملء الشاشة.
  • الكتابة، والتركيب في أسلوب الإدخال (input-method composition)، والإملاء، والنص من اليمين إلى اليسار تعمل كما في حقل النص. ومفتاح الإجراء في لوحة مفاتيح البحث يأخذ الاقتراح النشط أو النتيجة الحالية، ويرسل الاستعلام على صف الاستعلام أو حين لا يكون أيّ منهما.
  • يعرض الشريط التركيز بحافته هو، سواء جاء التركيز من لوحة المفاتيح أو من مؤشر، كما يفعل الحقل. وصفوف الاقتراحات تعرض حلقة التركيز داخل الصف ما دامت نشطة. وكل صف والشريط يستوفيان الحد الأدنى للهدف.
  • رسم البحث والأيقونات التي في البداية والفاصل مخفيّة عن التقنيات المساعدة.
  • مع أحجام النص الأكبر يكبر الشريط والترويسة، ويبقى الاستعلام في سطر واحد، وتلتفّ صفوف الاقتراحات.
  • تبلّغ بنيات التنقيح (debug) عن label أو clearLabel أو backLabel الناقصة، وعن قيمة اقتراح فارغة أو مكررة، وعن عنوان رئيسي فارغ، وعن طريقة عرض أو قيمة bar أو حالة غير معروفة، وعن مشغِّل مع طريقة العرض المُرسى، وعن بحث ثانٍ يربط المفاتيح نفسها، وعن أكثر من زرَّين في النهاية.

فجوات معروفة في المنصات:

  • ليس في SwiftUI و Compose و Flutter و React Native المشغِّل ولا عرض مربع الحوار ولا النتائج ولا صف الحالة ولا الاختصار بعد. على هذه المنصات اعرض النتائج في محتوى العرض الخاص بك وأعلن عددها بنفسك.
  • ليس في SwiftUI و Compose و Flutter و React Native حتى الآن صف الاستعلام ولا الإكمال داخل الحقل ولا دوران المفاتيح عند الطرفين. فهناك لا يكون شيء نشطًا إلى أن ينتقل الشخص إلى اقتراح بمفاتيح الأسهم، ويرسل Enter الاستعلام إلى ذلك الحين، وتتوقف الأسهم عند الطرفين.
  • الويب: الاختصار المربوط يقرأ mod بالاصطلاح الذي كُتب به تلميحه، وهو الذي يعيّنه عنصر سلف وإلا فاصطلاح المنصة، في حين تسمّي المواصفة اصطلاح المنصة وحده.
  • ليس في SwiftUI و Compose و Flutter و React Native دور مربع تحرير وسرد ولا دور مربع قائمة. حقل الإدخال فيها حقل بحث، وكل اقتراح زر مع موضعه في القائمة، يبلغه قارئ الشاشة بالسحب. والاقتراح النشط لا يُعلَن هناك على أنه الفرع النشط (active descendant) لحقل الإدخال. واقتراحات Flutter ليس لها موضع في القائمة كذلك، و SwiftUI و React Native يذكران الموضع بالإنجليزية («2 of 3»؛ والخاصية positionText في React Native تغيّره).
  • يعرض Flutter حقل الإدخال نوعَ إدخال للبحث، لا دور مربع البحث، لأن Flutter 3.32، وهو أقدم إصدار مدعوم، يرفض ذلك الدور.
  • الضغط خارج العرض المُرسى يغلقه. على الويب و SwiftUI و Compose و Flutter يصل الضغط أيضًا إلى ما تحته؛ وعلى React Native لا يصل، كما في قائمة الخيارات.
  • الويب: حقل الإدخال في ترويسة ملء الشاشة مربع تحرير وسرد أيضًا، فيُعلَن الاقتراح النشط هناك كذلك. والمواصفة تسمّي مربع التحرير والسرد للعرض المُرسى فقط.
  • الويب: العرض المُرسى لا يُغلق بطلب الإغلاق الخاص بالمنصة، كإيماءة الرجوع في Android. ويوضع بسكربت، لا بخاصية CSS anchor positioning كما تقول ملاحظة الويب في المواصفة.
  • التعطيل يصل إلى أزرار الأيقونات التي في المنافذ، والمواصفة تتركها في حالتها هي: .disabled(true) في SwiftUI يعطّلها أيضًا، وعلى الويب عتامة تعطيل أقل من 1 كانت ستُبهتها. وعتامة التعطيل في كل نظام مضمَّن هي 1.
  • يرسم SwiftUI العرض المُرسى فوق ما تحمله حاوية البحث نفسها بعده، لا فوق كل عرض في النافذة. أبقِ البحث متأخرًا في حاويته، أو ارفعه بالمُعدِّل zIndex. وعلى macOS لا يُقرأ ارتفاع النافذة، فيُفتح العرض دائمًا في الأسفل بارتفاعه الطبيعي، وعرض ملء الشاشة لوحة (sheet) بحجم النافذة.
  • في SwiftUI: تظليل التحديد يتبع صبغة مؤشر الكتابة، لا لون التحديد الخاص بحقل النص. والنقرة الأولى على حقل إدخال ليس عليه التركيز تضع مؤشر الكتابة في نهاية الاستعلام، لا حيث وقعت النقرة. والمفاتيح مختبَرة على macOS فقط، لا بلوحة مفاتيح فعلية على iOS.
  • لا يستطيع Compose التفريق بين مؤشر دقيق ولمس، فارتفاع صفوف الاقتراحات فيه 48 دائمًا حيث هو على الويب 44 تحت الفأرة. والضغط خارج العرض المُرسى لا تبلغه اختباراته.
  • في Flutter: العرض المُرسى الذي يفتحه المنتج بالدالة expand() وحقل الإدخال ليس عليه التركيز لا يغلقه ضغط في الخارج. وعرض ملء الشاشة يحتاج إلى Navigator؛ ومن دونه يكون العرض مُرسى.
  • في React Native: يوضع العرض المُرسى حين يُفتح وحين تتغيّر النافذة أو لوحة المفاتيح، لكنه لا يتبع الشريط وهو يُمرَّر. والمفتاح Escape ومفاتيح الأسهم والمفتاح Tab تصل فقط حيث يوصلها TextInput، والتراكب وانتقالات التركيز في عرض ملء الشاشة لم تُفحص بعد على جهاز.
  • تحت cupertino لا يرسم الشريط حافة تركيز، كما أن حقل البحث في iOS يعرض التركيز بمؤشر الكتابة ولوحة المفاتيح فقط.
  • تحت m3-like يرسم البحث قيم النظام الافتراضي: قيم البحث في Material تنتظر أن يغطيه مرجع المطابقة. والعرض المُرسى في Material الذي يكبر من الشريط سطحًا واحدًا يُرسم سطحًا مستقلًّا تحته (فجوة المحاكاة search-docked-view-joins-bar).

ما عليك فعله

  • أعطِ البحث label، وأعطِه clearLabel، ثم backLabel لمربع الحوار وملء الشاشة، بلغة منتجك.
  • قدِّم اقتراحات للاستعلام الحالي، بعناوين رئيسية مفهومة حين تُقرأ وحدها.
  • قل ما وجده بحثك في statusText، بلغة منتجك، مرة واحدة لكل جواب. البحث يُعلِنه؛ ولا يعدّ النتائج بنفسه.
  • أجرِ الاستعلام بنفسك، وأهمِل الأجوبة التي تصل على غير ترتيبها.
  • أعطِ كل نتيجة لها عنوان href، وأعطِها targetLabel حين تُفتح في سياق جديد.
  • اربط مفاتيح الاختصار، أو عيِّن bindShortcut. التلميح بمفاتيح لا تفعل شيئًا مضلِّل.
  • قرِّر ما يفعله select، وعيِّن الاستعلام بنفسك إن كان الاختيار ينبغي أن يملأه.
  • على Compose و React Native عيِّن expanded من دالة رد النداء، وإلا لم يُفتح العرض ولم يُغلق.
  • على الويب أعطِ البحث name ليرسل استعلامه مع نموذج.