On this page

Handoff to a human

Khách thấy xác nhận đã gửi form liên hệ; nhân viên thấy tóm tắt vì sao hội thoại được bàn giao.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Classic: sau khi gửi form bàn giao, HandoverSubmitStatus thay form; icon 16px và nhãn Submitted.
  • AI Mode: cùng HandoverSubmitStatus; icon 16px, màu chữ lấy từ --vib-2.
  • Admin: HandoffCard nằm đầu chi tiết hội thoại và trả null khi không có ngữ cảnh bàn giao.
  • Chỉ lần gửi thành công hiện tại được đọc bằng role status; lịch sử im lặng.
On this page

Use when / Avoid

Dùng pattern này cho xác nhận sau khi khách gửi form liên hệ khi bàn giao và cho tóm tắt bàn giao ở phía nhân viên. Thu thông tin liên hệ theo nhóm field xem Contact / email form; ca ngoài giờ xem Offline / after hours.

Use instead

Component Use when
HandoverSubmitStatus Xác nhận Submitted sau khi gửi form bàn giao ở Classic và AI Mode.
HandoverContactForm Form liên hệ bàn giao của Classic.
HandoffCard Admin: tóm tắt lý do, đơn và sản phẩm của lần bàn giao.

Entry points

Surface Owner
Classic HandoverContactForm v1
AI Mode HandoverContactForm v2 trong ChatBlocks
Admin HandoffCard trong chi tiết hội thoại

Flow

Surface Step Trigger UI shown Component Copy + i18n key Timing
Classic Mở form Chọn dòng liên hệ Form field thay danh sách phương thức HandoverContactForm AI handover contact form button / AI handover contact form button Tức thì
Classic Gửi Bấm Send Nút Send chuyển sang Spinner small HandoverContactForm Send / Send Theo vòng đời async của caller
Classic Xác nhận Gửi thành công HandoverSubmitStatus thay form HandoverContactForm Submitted / Submitted Ngay sau khi thành công
AI Mode Mở form Bấm nút liên hệ Card form với dòng dẫn đầu HandoverContactForm Leave your details and our team will get back to you. / Leave your details and our team will get back to you. Tức thì
AI Mode Gửi Bấm Send Send hiện BusyLabel và aria-busy HandoverContactForm Send / Send Theo vòng đời async của caller
AI Mode Xác nhận Gửi thành công HandoverSubmitStatus thay form HandoverContactForm Submitted / Submitted Ngay sau khi thành công
Admin Xem tóm tắt Hội thoại có handoffContext Card Hand-off với Badge, lý do, đơn và sản phẩm HandoffCard Hand-off / Hand-off Khi dữ liệu hội thoại có

Edge cases

Surface Case Behaviour
Classic Xem trong admin preview Bấm dòng liên hệ không mở form
AI Mode Gửi thất bại Dòng lỗi role alert với nội dung Couldn't send. Please try again.
AI Mode Form đã gửi rồi mở lại panel Hiện Submitted nhờ khóa cục bộ
AI Mode Có nhiều form chưa gửi Chỉ form mới nhất mở sẵn
Admin Không có handoffContext Card trả null
Admin Số đơn khách nhập chưa xác minh Hiện tên đơn kèm Badge Order number not verified

Live preview

Classic: bubble thu gọn là fixture từ chatty-icon-button; Current: FloatButtonWidget, chưa có element. Bag và menu (…) ở header: N/A trong preview.

AI Mode: SignIn, EmailContinue, Reset và Bag ở header: N/A trong preview.

Standard
LightDarkDesktopMobile

Standard: complete widget, fixture conversation and surface dimensions.

Show code
chatty-pattern-handoff-to-a-human.element.jsWrap code linesCopy
import '@avada/chatty-ui/tokens/tokens.css';
import {IconCopy} from '@avada/chatty-ui/elements/icon-glyphs.js';
import {html} from 'lit';
import '@avada/chatty-ui/elements/toast.js';
import '@avada/chatty-ui/elements/link.js';
import {IconClose, IconMessage} from '@avada/chatty-ui/elements/icon-glyphs.js';
import '@avada/chatty-ui/elements/surface.js';
import '@avada/chatty-ui/elements/avatar.js';
import '@avada/chatty-ui/elements/badge.js';
import '@avada/chatty-ui/elements/icon-button.js';
import '@avada/chatty-ui/elements/launcher.js';
import '@avada/chatty-ui/elements/button.js';
import {sameGroup} from '@avada/chatty-ui/behaviors/messages.js';

// Reference viewport: 1280 × 900 desktop, 390 × 900 mobile.
const sizes = {
  classic: {width: 400, height: 700},
  'ai-mode': {width: 820, height: 657},
  admin: {width: 527, height: 842}
};
const question = {
  id: 'question',
  senderType: 'customer',
  text: 'Can you help me?',
  createdAt: '2026-01-15T10:00:00Z'
};

/** Viewport-relative sizing survives the initial hidden iframe layout. */
function widgetSize(surface) {
  const mode = new URLSearchParams(location.search).get('mobile');
  const isMobile = mode === null ? innerWidth < 900 : mode === 'true';
  const width = `min(${sizes[surface].width}px, max(0px, 100vw - 40px))`;
  const height = isMobile
    ? `min(${surface === 'admin' ? 848 : 888}px, round(down, calc(${width} * 2.2), 1px))`
    : `${sizes[surface].height}px`;
  return {...sizes[surface], height, mobile: isMobile};
}

/** Local immutable message state with real subscriptions for live previews. */
function fixtureStore(initial) {
  let state = {messages: initial};
  const listeners = new Set();
  return {
    getState: () => state,
    subscribe(listener) {
      listeners.add(listener);
      return () => listeners.delete(listener);
    },
    setMessages(messages) {
      state = {messages};
      listeners.forEach(listener => listener());
    }
  };
}

/** Appends the viewer message without replacing the existing conversation. */
function appendViewer(store, surface, text) {
  const message = {
    id: `viewer-${store.getState().messages.length}`,
    senderType: surface === 'admin' ? 'agent' : 'customer',
    senderMeta: {name: surface === 'admin' ? 'Alex' : 'You'},
    text,
    createdAt: new Date().toISOString()
  };
  store.setMessages([...store.getState().messages, message]);
}

/**
 * One shell owns surface sizing, header, thread and composer for every pattern.
 * @param {string} surface
 * @param {Object} store
 * @param {Object} strings
 * @param {Object} content
 * @param {Function} renderMessage
 * @param {Function} onSend
 * @param {Object} registry
 * @param {boolean} composerHidden
 * @param {string} title
 * @param {Object} headerStart
 * @param {Object} headerActions
 * @param {boolean} sheet
 * @param {string | null} status
 * @returns {Object}
 */
function patternShell({
  surface,
  store,
  strings = {header: 'Store assistant', message: 'Message', send: 'Send'},
  content,
  renderMessage,
  onSend,
  registry,
  title,
  headerStart,
  headerActions,
  status = 'online',
  sheet = false,
  composerHidden = false
}) {
  const size = widgetSize(surface);
  const mobileSheet = sheet && size.mobile;
  if (mobileSheet) {
    size.width = 'none';
    size.height = 'calc(100dvh - 12px)';
  }
  const toggle = (event, closed) => {
    const frame = event.currentTarget.closest('[data-pattern-frame]');
    const panel = frame.querySelector('chatty-surface');
    const launcher = frame.querySelector('[data-pattern-launcher]');
    panel.hidden = closed;
    frame.dataset.closed = String(closed);
    const background = frame.querySelector('[data-sheet-page]');
    if (background) background.inert = !closed && surface === 'ai-mode';
    launcher.hidden = !closed;
    if (closed) {
      launcher.style.insetBlockEnd = `${Math.max(surface === 'ai-mode' ? 40 : 16, frame.getBoundingClientRect().bottom - innerHeight + 20)}px`;
      launcher.focus({preventScroll: true});
    } else {
      const composer = panel.querySelector('chatty-composer');
      const input = !composer.hidden
        ? composer.renderRoot.querySelector('textarea')
        : (panel
            .querySelector('chatty-contact-form:not([hidden])')
            ?.renderRoot.querySelector('chatty-text-field') ??
          panel.querySelector('form chatty-text-field') ??
          panel.querySelector('[data-welcome-invitation]:not([hidden]) chatty-button') ??
          panel
            .querySelector('chatty-pre-chat:not([hidden])')
            ?.renderRoot.querySelector('chatty-button'));
      input?.focus({preventScroll: true});
    }
  };
  const sender = message => {
    const content = renderMessage?.(message) ?? {};
    const messages = store.getState().messages;
    const previous = messages[messages.indexOf(message) - 1];
    if (message.senderType !== 'bot' || sameGroup(message, previous)) return content;
    return {
      ...content,
      sender: html`<span style="display:inline-flex;align-items:center;gap:6px"
        ><chatty-avatar size="sm" label="Assistant">A</chatty-avatar
        >${content.sender ?? message.senderName ?? message.senderMeta?.name ?? 'Assistant'}</span
      >`
    };
  };
  return html`<style>
      [data-pattern-frame] {
        display: flex;
        position: relative;
        justify-content: center;
        inline-size: 100%;
        min-inline-size: 0;
      }
      [data-pattern-frame='classic'] {
        justify-content: flex-end;
      }
      [data-pattern-frame] chatty-surface::part(header) {
        padding: 0;
      }
      [data-pattern-frame='classic'] chatty-surface::part(header),
      [data-pattern-frame='ai-mode'] chatty-surface::part(header) {
        border-bottom-width: 0;
      }
      [data-pattern-frame] [hidden] {
        display: none !important;
      }
      [data-pattern-header] {
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
        min-inline-size: 0;
        block-size: 52px;
        padding: 0 16px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] {
        block-size: 56px;
        background: var(--chatty-color-accent);
        color: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-icon-button {
        --chatty-color-border-focus: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='admin'] [data-pattern-header] {
        block-size: 68px;
        padding: 8px 12px;
      }
      [data-pattern-header] chatty-avatar {
        --chatty-avatar-size: 32px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar {
        --chatty-avatar-background: #fff;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar::part(base) {
        color: #303030;
        border: 1px solid #767676;
      }
      [data-pattern-actions] {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      [data-pattern-title] {
        flex: 1;
        min-inline-size: 0;
        display: flex;
        flex-direction: column;
      }
      [data-pattern-frame='admin'] [data-pattern-title] {
        gap: 4px;
      }
      [data-pattern-frame='admin'] [data-pattern-title] strong {
        display: flex;
        align-items: center;
        min-block-size: 28px;
        font: var(--p-font-weight-semibold, 650) var(--p-text-heading-md-font-size, 14px) /
          var(--p-text-heading-md-font-line-height, 20px) var(--p-font-family-sans, system-ui);
      }
      [data-pattern-title] strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      [data-pattern-header] chatty-icon-button {
        --chatty-icon-button-size: 32px;
        --chatty-icon-button-color: currentColor;
      }
      @media (max-width: 899px), (pointer: coarse) {
        [data-pattern-header] chatty-icon-button {
          --chatty-icon-button-size: 44px;
        }
      }
      [data-pattern-launcher] {
        position: absolute;
        inset-inline-end: 0;
        inset-block-end: 0;
      }
      [data-pattern-frame='ai-mode'] [data-pattern-launcher] {
        inset-inline-end: auto;
        inset-inline-start: 50%;
        transform: translateX(-50%);
      }
      [data-pattern-frame='classic'] [data-pattern-launcher] {
        --chatty-icon-button-size: 56px;
        border-radius: 50%;
        background: var(--chatty-color-accent);
        --chatty-icon-button-color: var(--chatty-color-on-accent);
      }
      [data-sheet-mobile='true'] {
        position: fixed;
        inset: 0;
        inline-size: 100vw;
      }
      [data-sheet-mobile='true'] chatty-surface::part(base) {
        border-radius: 16px 16px 0 0;
      }
      [data-sheet-mobile='true'] chatty-surface {
        position: relative;
        z-index: 2;
        margin-block-start: 12px;
      }
      [data-sheet-page],
      [data-sheet-scrim] {
        position: absolute;
        inset: 0;
        box-sizing: border-box;
      }
      [data-sheet-page] {
        padding: 20px;
        background: var(--chatty-color-bg-surface);
        color: var(--chatty-color-text);
      }
      [data-sheet-scrim] {
        z-index: 1;
        border: 0;
        background: rgb(0 0 0 / 40%);
        animation: sheet-scrim 400ms ease;
      }
      [data-sheet-mobile='true'][data-closed='true'] [data-sheet-scrim] {
        display: none;
      }
      [data-sheet-mobile='true'] [data-pattern-launcher] {
        z-index: 3;
      }
      @keyframes sheet-scrim {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        [data-sheet-scrim] {
          animation: none;
        }
      }
    </style>
    <div
      data-pattern-frame=${surface}
      data-sheet-mobile=${String(mobileSheet)}
      data-closed="false"
      style=${`block-size:calc(${size.height} + ${mobileSheet ? 12 : 0}px)`}
    >
      ${
        mobileSheet
          ? html`<div data-sheet-page .inert=${surface === 'ai-mode'}>
                <p>Example storefront</p>
                <chatty-button
                  variant="secondary"
                  type="button"
                  @click=${event => {
                    event.currentTarget.textContent = 'Products opened';
                  }}
                >
                  Browse products
                </chatty-button>
              </div>
              ${surface === 'ai-mode' ? html`<button type="button" data-sheet-scrim tabindex="-1" aria-label="Close chat background" @click=${event => toggle(event, true)}></button>` : ''}`
          : ''
      }
      <chatty-surface
        data-chatty-surface=${surface}
        data-chatty-theme=${surface === 'admin' ? 'light' : (document.documentElement.dataset.chattyTheme ?? document.documentElement.dataset.theme ?? 'light')}
        style=${`inline-size:100%;max-inline-size:${mobileSheet ? 'none' : `${size.width}px`};--chatty-surface-height:${size.height}`}
        .store=${store}
        .registry=${registry ?? null}
        viewer-type=${surface === 'admin' ? 'agent' : 'customer'}
        .selfTypes=${surface === 'admin' ? ['agent', 'bot'] : null}
        .renderMessage=${sender}
      >
        <div slot="header" data-pattern-header>
          ${headerStart ?? ''}
          ${surface === 'admin' ? '' : html`<chatty-avatar label="Store" .status=${status}>S</chatty-avatar>`}
          <span data-pattern-title
            ><strong
              >${title ?? (surface === 'admin' ? 'Customer conversation' : strings.header)}</strong
            >${surface === 'admin' ? html`<chatty-badge size="sm" variant="secondary" style="align-self:flex-start">Customer</chatty-badge>` : status == null ? '' : html`<small data-pattern-status>${status === 'online' ? 'Open' : 'Closed'}</small>`}</span
          >
          <span data-pattern-actions>${headerActions ?? ''}</span>
          ${
            surface === 'admin'
              ? ''
              : html`<chatty-icon-button label="Close panel" @click=${event => toggle(event, true)}
                  >${IconClose()}</chatty-icon-button
                >`
          }
        </div>
        <chatty-thread .strings=${{bot: 'Assistant', ...strings}}></chatty-thread>${content ?? ''}
        <chatty-composer
          slot="footer"
          ?hidden=${composerHidden}
          .label=${strings.message}
          .sendLabel=${strings.send}
          @chatty-send=${event => {
            appendViewer(store, surface, event.detail.text);
            if (onSend) onSend(event.detail.text, event.currentTarget);
            else if (surface !== 'admin')
              store.setMessages([
                ...store.getState().messages,
                {
                  id: `fixture-${store.getState().messages.length}`,
                  senderType: 'bot',
                  text: `You asked: “${event.detail.text}”. I can help with that.`,
                  hasEventTime: false
                }
              ]);
          }}
        ></chatty-composer> </chatty-surface
      >${
        surface === 'admin'
          ? ''
          : surface === 'ai-mode'
            ? html`<chatty-launcher
                data-pattern-launcher
                hidden
                label="Open chat"
                @chatty-open=${event => toggle(event, false)}
                >${IconMessage({size: 20, slot: 'icon'})}Ask a question</chatty-launcher
              >`
            : html`<chatty-icon-button
                data-pattern-launcher
                hidden
                size="lg"
                label="Open chat"
                @click=${event => toggle(event, false)}
                >${IconMessage({size: 24})}</chatty-icon-button
              >`
      }
    </div>`;
}

import {createBlockRegistry} from '@avada/chatty-ui/behaviors/block-registry.js';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
import '@avada/chatty-ui/elements/chatty-block-contact-methods.js';
const strings = {
  header: 'Store assistant',
  message: 'Message',
  send: 'Send',
  handoff: 'Hand-off',
  verified: 'Verified by email code at hand-off',
  reason: 'Return or refund request',
  origin: 'Handed off by the AI assistant',
  order: 'Order number',
  inTransit: 'In transit',
  late: 'Running late',
  viewing: 'Viewing'
};
const adminPreview = () => {
  const store = fixtureStore([{...question, text: 'I would like to return order #1001.'}]);
  const mode = new URLSearchParams(location.search).get('mobile');
  const mobile = mode === null ? innerWidth < 768 : mode === 'true';
  return html`<style>
      [data-handoff-admin] {
        display: flex;
        gap: 6px;
        max-inline-size: 793px;
        inline-size: 100%;
        margin: auto;
        min-inline-size: 0;
        position: relative;
        box-sizing: border-box;
      }
      [data-handoff-admin]:has([data-admin-detail]) {
        padding-block-end: 64px;
      }
      [data-handoff-chat] {
        min-inline-size: 0;
        flex: 1;
      }
      [data-admin-detail] {
        --chatty-color-text-link: #005bd3;
        box-sizing: border-box;
        flex: 0 0 260px;
        height: 842px;
        overflow: auto;
        scrollbar-gutter: stable;
        padding: 12px;
        background: #fff;
        border: 1px solid #e3e3e3;
        font: 13px/20px system-ui;
        color: #303030;
      }
      [data-admin-detail] section {
        padding-block: 12px;
        border-bottom: 1px solid #e3e3e3;
      }
      [data-admin-detail] h2 {
        font: 650 14px/20px system-ui;
        margin: 0 0 8px;
      }
      [data-admin-detail] p {
        margin: 8px 0;
      }
      [data-admin-detail] [hidden] {
        display: none !important;
      }
      [data-order-id] {
        padding: 12px 0;
        border-bottom: 1px solid #e3e3e3;
        scroll-margin: 12px;
      }
      [data-order-heading] {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
      }
      [data-order-heading] chatty-icon-button {
        --chatty-icon-button-size: 28px;
      }
      [data-handoff-admin] chatty-toast {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        inline-size: max-content;
        max-inline-size: calc(100% - 32px);
        z-index: 2;
      }
      [data-handoff-admin] chatty-toast::part(base) {
        min-inline-size: 0;
        max-inline-size: 100%;
      }
    </style>
    <div data-handoff-admin>
      <div data-handoff-chat>${patternShell({surface: 'admin', store, title: 'Alex Morgan'})}</div>
      ${
        mobile
          ? ''
          : html`<aside data-admin-detail aria-label="Conversation details">
                <section aria-label="Hand-off">
                  <h2>Hand-off</h2>
                  <chatty-badge data-verified tone="neutral" data-admin-tone="info"
                    >Verified by email code at hand-off</chatty-badge
                  >
                  <chatty-badge data-unverified tone="caution" data-admin-tone="attention" hidden
                    >Not verified at hand-off</chatty-badge
                  >
                  <p>Return or refund request</p>
                  <p style="font-size:12px;color:#616161">Handed off by the AI assistant</p>
                  <div data-verified>
                    <chatty-button
                      variant="plain"
                      @click=${event => {
                        event.currentTarget.focus({preventScroll: true});
                        const detail = event.currentTarget.closest('[data-admin-detail]');
                        const row = detail
                          .querySelector('[data-order-id="1001"]')
                          .getBoundingClientRect();
                        const box = detail.getBoundingClientRect();
                        const top =
                          row.top < box.top + 12
                            ? row.top - box.top - 12
                            : Math.max(0, row.bottom - box.bottom + 12);
                        detail.scrollBy({
                          top,
                          behavior: matchMedia('(prefers-reduced-motion: reduce)').matches
                            ? 'instant'
                            : 'smooth'
                        });
                      }}
                      >#1001</chatty-button
                    >
                    · In transit
                    <chatty-badge tone="caution" data-admin-tone="warning"
                      >Running late</chatty-badge
                    >
                  </div>
                  <p data-unverified hidden>
                    <strong>#1001</strong>
                    <chatty-badge tone="caution" data-admin-tone="attention"
                      >Order number not verified</chatty-badge
                    >
                  </p>
                  <p style="font-size:12px;color:#616161">Viewing Canvas tote</p>
                </section>
                <section aria-label="Customer">
                  <h2>Customer</h2>
                  <p>Alex Morgan</p>
                  <p>alex@example.com</p>
                  <p>United States</p>
                </section>
                <section aria-label="Shopping activity">
                  <h2>Shopping activity</h2>
                  <p>Viewed Canvas tote</p>
                  <p>Added Canvas tote to cart</p>
                  <p>Visited return policy</p>
                </section>
                <section aria-label="Recent orders">
                  <h2>Recent orders</h2>
                  ${[1003, 1002, 1001].map(
                    id =>
                      html`<article data-order-id=${id}>
                        <div data-order-heading>
                          <strong>#${id}</strong
                          ><chatty-icon-button
                            label="Copy order status page"
                            @click=${async event => {
                              const root = event.currentTarget.closest('[data-handoff-admin]');
                              const toast = root.querySelector('chatty-toast');
                              try {
                                await navigator.clipboard.writeText(
                                  `https://shopify.com/123456/account/orders/${id}`
                                );
                                toast.textContent = 'Copied to clipboard';
                                toast.tone = 'neutral';
                              } catch {
                                toast.textContent = 'Could not copy. Please try again.';
                                toast.tone = 'critical';
                              }
                              toast.open = true;
                            }}
                            >${IconCopy({size: 16})}</chatty-icon-button
                          >
                        </div>
                        <p>In transit · $48.00</p>
                        <p>Canvas tote × 1</p>
                        <chatty-link
                          href=${`https://admin.shopify.com/store/example/orders/${id}`}
                          target="_blank"
                          >View order</chatty-link
                        >
                      </article>`
                  )}
                </section>
              </aside>
              <chatty-toast>Copied to clipboard</chatty-toast>`
      }
    </div>`;
};

export function Standard({surface}) {
  if (surface === 'admin') return adminPreview();
  const store = fixtureStore([question]);
  const registry = createBlockRegistry({
    'contact-form': 'chatty-block-contact-form',
    'contact-methods': 'chatty-block-contact-methods'
  });
  const fields = [
    {
      key: 'issue',
      type: 'textarea',
      label: 'Describe your issue',
      placeholder: 'Tell us about your problem',
      required: true
    },
    {
      key: 'email',
      type: 'email',
      label: 'Email address',
      placeholder: 'you@example.com',
      required: true
    },
    {key: 'order', label: 'Order number', placeholder: '#1001'}
  ];
  store.setMessages([
    ...store.getState().messages,
    {
      id: 'handoff',
      senderType: 'bot',
      blocks: [{type: 'contact-methods', data: {methods: [{id: 'form', label: 'Contact form'}]}}]
    }
  ]);
  const update = data =>
    store.setMessages(
      store.getState().messages.map(m =>
        m.id === 'handoff'
          ? {
              ...m,
              blocks: [
                {
                  type: 'contact-form',
                  data: {
                    fields,
                    description: 'Leave your details and our team will get back to you.',
                    strings: {
                      submit: 'Send',
                      invalidEmail: 'Enter a valid email address.',
                      requiredField: 'Complete this field.',
                      requiredEmail: 'Enter your email address.'
                    },
                    ...data
                  }
                }
              ]
            }
          : m
      )
    );
  return html`<div
    style="inline-size:100%;min-inline-size:0"
    @chatty-contact=${() => update({focus: true})}
    @chatty-submit=${event => {
      update({loading: true, values: event.detail.values});
      const finish = () => update({submitted: true});
      if (matchMedia('(prefers-reduced-motion: reduce)').matches) finish();
      else setTimeout(finish, 450);
    }}
  >
    ${patternShell({surface, store, strings, registry})}
  </div>`;
}

S2 Standard: Classic chọn Contact form từ danh sách phương thức; form issue → email → order nằm trong tin bot qua registry opt-in, có placeholder và dấu * critical. Submitted có ✓, chữ secondary và không viền. Request là fixture. Admin có chat và cột chi tiết riêng: số đơn verified cuộn tới Recent orders, unverified là text và badge. Copy trên hàng đơn sao chép URL trạng thái; cột chi tiết Mobile: N/A trong preview.

Current: chưa có story cho form Classic; các story Current bên dưới giữ nguyên.

Classic

Current (React), being replaced
LightDarkDesktopMobile

HandoverSubmitStatus thật: bản có role status và bản im lặng.

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function Status() {
  return (
    <div>
      <HandoverSubmitStatus label="Submitted" announce />
      <HandoverSubmitStatus label="Submitted" />
    </div>
  );
}

const open = {formId: 'guide-form-open', submitted: false, formFields: ['description', 'email', 'order']};
const sent = {formId: 'guide-form-sent', submitted: true};

Import / element

HandoverSubmitStatus

Component / element Import / file Scope root
HandoverSubmitStatus @avada/chatty-ui/primitives/HandoverSubmitStatus.jsx .Avada-Faqs_Popup

Anatomy

HandoverSubmitStatus

Part Element
1 Icon IconCheck, aria-hidden; CSS đặt 16px.
2 Nhãn trong span do caller dịch.

Placement / order

HandoverSubmitStatus

Context Order
Sau khi gửi form HandoverContactForm Classic trả HandoverSubmitStatus khi form ở trạng thái submitted.
Bên trong component Icon rồi nhãn trên một hàng.

Props

HandoverSubmitStatus

Prop Type Values Default Notes
label string Cụm Submitted đã dịch None Caller truyền t hoặc i18n của surface.
announce boolean true / false false true đặt role status; false cho lịch sử hoặc form khôi phục.

Sizes

HandoverSubmitStatus

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Status Theo line-height của body-small Không khai báo 6px Không khai báo body-small 14pxDerived(14px = type(body-small, desktop, size)) / 20pxDerived(20px = type(body-small, desktop, line)) desktop → 15pxDerived(15px = type(body-small, mobile, size)) / 22pxDerived(22px = type(body-small, mobile, line)) mobile Không tương tác JS .mobile khi mobileMaxWidth 899px
Icon 16px Không khai báo Không khai báo Không khai báo Không có chữ Không tương tác Không có override theo viewport

Tokens

HandoverSubmitStatus

Part Token Light Dark
Nhãn chữ --chatty-color-text-secondary #616161 Giống Light nếu popup không override

States

HandoverSubmitStatus

State Trigger Visual change (values) ARIA/attribute
Có thông báo announce là true Không đổi giao diện role status
Im lặng announce là false Không đổi giao diện Không có role

Behaviour

HandoverSubmitStatus

Interaction Result
Hiển thị Thay form liên hệ khi trạng thái là submitted.
Thông báo Chỉ lần gửi thành công hiện tại được đọc; lịch sử và khóa khôi phục thì im lặng.

Copy

HandoverSubmitStatus

String i18n key Where
Submitted Submitted label của caller

Source

HandoverSubmitStatus

File Evidence
API và ARIA
Kích thước và màu

AI Mode

Current (React), being replaced
LightDarkDesktopMobile

HandoverContactForm thật của AI Mode ở bước form mở sẵn (form mới nhất mở mặc định).

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function AiForm() {
  return <HandoverContactForm messageId="guide-handover" contactForm={open} />;
}
Current (React), being replaced
LightDarkDesktopMobile

Cùng component khi `contactForm.submitted` là true: HandoverSubmitStatus thay form.

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function AiSubmitted() {
  return <HandoverContactForm messageId="guide-handover" contactForm={sent} />;
}

const verified = {
  source: 'ai_tool',
  trigger: 'customer_request',
  issueType: 'returnRefund',
  verified: true,
  order: {id: '1001', name: '#1001', status: 'in_transit', issue: 'late'},
  products: [{title: 'Trail Shell jacket', url: 'https://example.com/products/trail-shell'}]
};
const unverified = {
  source: 'menu',
  trigger: 'customer_request',
  verified: false,
  claimedOrderName: '#1002'
};
Current (React), being replaced
LightDarkDesktopMobile

HandoverSubmitStatus thật: bản có role status và bản im lặng.

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function Status() {
  return (
    <div>
      <HandoverSubmitStatus label="Submitted" announce />
      <HandoverSubmitStatus label="Submitted" />
    </div>
  );
}

const open = {formId: 'guide-form-open', submitted: false, formFields: ['description', 'email', 'order']};
const sent = {formId: 'guide-form-sent', submitted: true};

Import / element

HandoverSubmitStatus

Component / element Import / file Scope root
HandoverSubmitStatus @avada/chatty-ui/primitives/HandoverSubmitStatus.jsx .chatty-ai-mode

Anatomy

HandoverSubmitStatus

Part Element
1 Icon IconCheck, aria-hidden; CSS đặt 16px.
2 Nhãn trong span do caller dịch.

Placement / order

HandoverSubmitStatus

Context Order
Sau khi gửi form HandoverContactForm AI Mode trả HandoverSubmitStatus khi stage là submitted.
Bên trong component Icon rồi nhãn trên một hàng.

Props

HandoverSubmitStatus

Prop Type Values Default Notes
label string Cụm Submitted đã dịch None Caller truyền t hoặc i18n của surface.
announce boolean true / false false true đặt role status; false cho lịch sử hoặc form khôi phục.

Sizes

HandoverSubmitStatus

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Status Theo line-height của body-small Không khai báo 6px Không khai báo body-small 14pxDerived(14px = type(body-small, desktop, size)) / 20pxDerived(20px = type(body-small, desktop, line)) desktop → 15pxDerived(15px = type(body-small, mobile, size)) / 22pxDerived(22px = type(body-small, mobile, line)) mobile Không tương tác JS .is-mobile ≤899px; hoặc media (hover: none) and (pointer: coarse)
Icon 16px Không khai báo Không khai báo Không khai báo Không có chữ Không tương tác Không có override theo viewport

Tokens

HandoverSubmitStatus

Part Token Light Dark
Nhãn chữ --vib-2 rgba(20, 19, 24, 0.74) rgba(255, 255, 255, 0.74)

States

HandoverSubmitStatus

State Trigger Visual change (values) ARIA/attribute
Có thông báo announce là true Không đổi giao diện role status
Im lặng announce là false Không đổi giao diện Không có role

Behaviour

HandoverSubmitStatus

Interaction Result
Hiển thị Thay form liên hệ khi trạng thái là submitted.
Thông báo Chỉ lần gửi thành công hiện tại được đọc; lịch sử và khóa khôi phục thì im lặng.

Copy

HandoverSubmitStatus

String i18n key Where
Submitted Submitted label của caller

Source

HandoverSubmitStatus

File Evidence
API và ARIA
Kích thước và màu

Admin

Current (React), being replaced
LightDarkDesktopMobile

HandoffCard thật với handoffContext đã xác minh: lý do, nguồn, đơn và sản phẩm đang xem.

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function AdminCard() {
  const [ready] = useState(() => {
    chatStore.setState({conversation: {handoffContext: verified}});
    return true;
  });
  return ready ? (
    <AppProvider i18n={{}}>
      <HandoffCard />
    </AppProvider>
  ) : null;
}
Current (React), being replaced
LightDarkDesktopMobile

HandoffCard thật với số đơn khách nhập chưa xác minh.

Show code
handoff-to-a-human.jsxWrap code linesCopy
import React, {useState} from 'react';
import {AppProvider} from '@shopify/polaris';
import {HandoverSubmitStatus} from '@avada/chatty-ui/primitives/HandoverSubmitStatus.jsx';
import {HandoverContactForm} from '@scripttag/v2/components/ChatBlocks/HandoverContactForm.jsx';
import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';

export function AdminCardUnverified() {
  const [ready] = useState(() => {
    chatStore.setState({conversation: {handoffContext: unverified}});
    return true;
  });
  return ready ? (
    <AppProvider i18n={{}}>
      <HandoffCard />
    </AppProvider>
  ) : null;
}
Standard
LightDarkDesktopMobile

Cột chi tiết Admin, hai ca Verified và Unverified; Orders chứa URL fixture.

Show code
chatty-pattern-handoff-to-a-human.element.jsWrap code linesCopy
import '@avada/chatty-ui/tokens/admin.css';
import {IconCopy} from '@avada/chatty-ui/elements/icon-glyphs.js';
import {html} from 'lit';
import '@avada/chatty-ui/elements/toast.js';
import '@avada/chatty-ui/elements/link.js';
import {IconClose, IconMessage} from '@avada/chatty-ui/elements/icon-glyphs.js';
import '@avada/chatty-ui/elements/surface.js';
import '@avada/chatty-ui/elements/avatar.js';
import '@avada/chatty-ui/elements/badge.js';
import '@avada/chatty-ui/elements/icon-button.js';
import '@avada/chatty-ui/elements/launcher.js';
import '@avada/chatty-ui/elements/button.js';
import {sameGroup} from '@avada/chatty-ui/behaviors/messages.js';

// Reference viewport: 1280 × 900 desktop, 390 × 900 mobile.
const sizes = {
  classic: {width: 400, height: 700},
  'ai-mode': {width: 820, height: 657},
  admin: {width: 527, height: 842}
};
const question = {
  id: 'question',
  senderType: 'customer',
  text: 'Can you help me?',
  createdAt: '2026-01-15T10:00:00Z'
};

/** Viewport-relative sizing survives the initial hidden iframe layout. */
function widgetSize(surface) {
  const mode = new URLSearchParams(location.search).get('mobile');
  const isMobile = mode === null ? innerWidth < 900 : mode === 'true';
  const width = `min(${sizes[surface].width}px, max(0px, 100vw - 40px))`;
  const height = isMobile
    ? `min(${surface === 'admin' ? 848 : 888}px, round(down, calc(${width} * 2.2), 1px))`
    : `${sizes[surface].height}px`;
  return {...sizes[surface], height, mobile: isMobile};
}

/** Local immutable message state with real subscriptions for live previews. */
function fixtureStore(initial) {
  let state = {messages: initial};
  const listeners = new Set();
  return {
    getState: () => state,
    subscribe(listener) {
      listeners.add(listener);
      return () => listeners.delete(listener);
    },
    setMessages(messages) {
      state = {messages};
      listeners.forEach(listener => listener());
    }
  };
}

/** Appends the viewer message without replacing the existing conversation. */
function appendViewer(store, surface, text) {
  const message = {
    id: `viewer-${store.getState().messages.length}`,
    senderType: surface === 'admin' ? 'agent' : 'customer',
    senderMeta: {name: surface === 'admin' ? 'Alex' : 'You'},
    text,
    createdAt: new Date().toISOString()
  };
  store.setMessages([...store.getState().messages, message]);
}

/**
 * One shell owns surface sizing, header, thread and composer for every pattern.
 * @param {string} surface
 * @param {Object} store
 * @param {Object} strings
 * @param {Object} content
 * @param {Function} renderMessage
 * @param {Function} onSend
 * @param {Object} registry
 * @param {boolean} composerHidden
 * @param {string} title
 * @param {Object} headerStart
 * @param {Object} headerActions
 * @param {boolean} sheet
 * @param {string | null} status
 * @returns {Object}
 */
function patternShell({
  surface,
  store,
  strings = {header: 'Store assistant', message: 'Message', send: 'Send'},
  content,
  renderMessage,
  onSend,
  registry,
  title,
  headerStart,
  headerActions,
  status = 'online',
  sheet = false,
  composerHidden = false
}) {
  const size = widgetSize(surface);
  const mobileSheet = sheet && size.mobile;
  if (mobileSheet) {
    size.width = 'none';
    size.height = 'calc(100dvh - 12px)';
  }
  const toggle = (event, closed) => {
    const frame = event.currentTarget.closest('[data-pattern-frame]');
    const panel = frame.querySelector('chatty-surface');
    const launcher = frame.querySelector('[data-pattern-launcher]');
    panel.hidden = closed;
    frame.dataset.closed = String(closed);
    const background = frame.querySelector('[data-sheet-page]');
    if (background) background.inert = !closed && surface === 'ai-mode';
    launcher.hidden = !closed;
    if (closed) {
      launcher.style.insetBlockEnd = `${Math.max(surface === 'ai-mode' ? 40 : 16, frame.getBoundingClientRect().bottom - innerHeight + 20)}px`;
      launcher.focus({preventScroll: true});
    } else {
      const composer = panel.querySelector('chatty-composer');
      const input = !composer.hidden
        ? composer.renderRoot.querySelector('textarea')
        : (panel
            .querySelector('chatty-contact-form:not([hidden])')
            ?.renderRoot.querySelector('chatty-text-field') ??
          panel.querySelector('form chatty-text-field') ??
          panel.querySelector('[data-welcome-invitation]:not([hidden]) chatty-button') ??
          panel
            .querySelector('chatty-pre-chat:not([hidden])')
            ?.renderRoot.querySelector('chatty-button'));
      input?.focus({preventScroll: true});
    }
  };
  const sender = message => {
    const content = renderMessage?.(message) ?? {};
    const messages = store.getState().messages;
    const previous = messages[messages.indexOf(message) - 1];
    if (message.senderType !== 'bot' || sameGroup(message, previous)) return content;
    return {
      ...content,
      sender: html`<span style="display:inline-flex;align-items:center;gap:6px"
        ><chatty-avatar size="sm" label="Assistant">A</chatty-avatar
        >${content.sender ?? message.senderName ?? message.senderMeta?.name ?? 'Assistant'}</span
      >`
    };
  };
  return html`<style>
      [data-pattern-frame] {
        display: flex;
        position: relative;
        justify-content: center;
        inline-size: 100%;
        min-inline-size: 0;
      }
      [data-pattern-frame='classic'] {
        justify-content: flex-end;
      }
      [data-pattern-frame] chatty-surface::part(header) {
        padding: 0;
      }
      [data-pattern-frame='classic'] chatty-surface::part(header),
      [data-pattern-frame='ai-mode'] chatty-surface::part(header) {
        border-bottom-width: 0;
      }
      [data-pattern-frame] [hidden] {
        display: none !important;
      }
      [data-pattern-header] {
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
        min-inline-size: 0;
        block-size: 52px;
        padding: 0 16px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] {
        block-size: 56px;
        background: var(--chatty-color-accent);
        color: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-icon-button {
        --chatty-color-border-focus: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='admin'] [data-pattern-header] {
        block-size: 68px;
        padding: 8px 12px;
      }
      [data-pattern-header] chatty-avatar {
        --chatty-avatar-size: 32px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar {
        --chatty-avatar-background: #fff;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar::part(base) {
        color: #303030;
        border: 1px solid #767676;
      }
      [data-pattern-actions] {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      [data-pattern-title] {
        flex: 1;
        min-inline-size: 0;
        display: flex;
        flex-direction: column;
      }
      [data-pattern-frame='admin'] [data-pattern-title] {
        gap: 4px;
      }
      [data-pattern-frame='admin'] [data-pattern-title] strong {
        display: flex;
        align-items: center;
        min-block-size: 28px;
        font: var(--p-font-weight-semibold, 650) var(--p-text-heading-md-font-size, 14px) /
          var(--p-text-heading-md-font-line-height, 20px) var(--p-font-family-sans, system-ui);
      }
      [data-pattern-title] strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      [data-pattern-header] chatty-icon-button {
        --chatty-icon-button-size: 32px;
        --chatty-icon-button-color: currentColor;
      }
      @media (max-width: 899px), (pointer: coarse) {
        [data-pattern-header] chatty-icon-button {
          --chatty-icon-button-size: 44px;
        }
      }
      [data-pattern-launcher] {
        position: absolute;
        inset-inline-end: 0;
        inset-block-end: 0;
      }
      [data-pattern-frame='ai-mode'] [data-pattern-launcher] {
        inset-inline-end: auto;
        inset-inline-start: 50%;
        transform: translateX(-50%);
      }
      [data-pattern-frame='classic'] [data-pattern-launcher] {
        --chatty-icon-button-size: 56px;
        border-radius: 50%;
        background: var(--chatty-color-accent);
        --chatty-icon-button-color: var(--chatty-color-on-accent);
      }
      [data-sheet-mobile='true'] {
        position: fixed;
        inset: 0;
        inline-size: 100vw;
      }
      [data-sheet-mobile='true'] chatty-surface::part(base) {
        border-radius: 16px 16px 0 0;
      }
      [data-sheet-mobile='true'] chatty-surface {
        position: relative;
        z-index: 2;
        margin-block-start: 12px;
      }
      [data-sheet-page],
      [data-sheet-scrim] {
        position: absolute;
        inset: 0;
        box-sizing: border-box;
      }
      [data-sheet-page] {
        padding: 20px;
        background: var(--chatty-color-bg-surface);
        color: var(--chatty-color-text);
      }
      [data-sheet-scrim] {
        z-index: 1;
        border: 0;
        background: rgb(0 0 0 / 40%);
        animation: sheet-scrim 400ms ease;
      }
      [data-sheet-mobile='true'][data-closed='true'] [data-sheet-scrim] {
        display: none;
      }
      [data-sheet-mobile='true'] [data-pattern-launcher] {
        z-index: 3;
      }
      @keyframes sheet-scrim {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        [data-sheet-scrim] {
          animation: none;
        }
      }
    </style>
    <div
      data-pattern-frame=${surface}
      data-sheet-mobile=${String(mobileSheet)}
      data-closed="false"
      style=${`block-size:calc(${size.height} + ${mobileSheet ? 12 : 0}px)`}
    >
      ${
        mobileSheet
          ? html`<div data-sheet-page .inert=${surface === 'ai-mode'}>
                <p>Example storefront</p>
                <chatty-button
                  variant="secondary"
                  type="button"
                  @click=${event => {
                    event.currentTarget.textContent = 'Products opened';
                  }}
                >
                  Browse products
                </chatty-button>
              </div>
              ${surface === 'ai-mode' ? html`<button type="button" data-sheet-scrim tabindex="-1" aria-label="Close chat background" @click=${event => toggle(event, true)}></button>` : ''}`
          : ''
      }
      <chatty-surface
        data-chatty-surface=${surface}
        data-chatty-theme=${surface === 'admin' ? 'light' : (document.documentElement.dataset.chattyTheme ?? document.documentElement.dataset.theme ?? 'light')}
        style=${`inline-size:100%;max-inline-size:${mobileSheet ? 'none' : `${size.width}px`};--chatty-surface-height:${size.height}`}
        .store=${store}
        .registry=${registry ?? null}
        viewer-type=${surface === 'admin' ? 'agent' : 'customer'}
        .selfTypes=${surface === 'admin' ? ['agent', 'bot'] : null}
        .renderMessage=${sender}
      >
        <div slot="header" data-pattern-header>
          ${headerStart ?? ''}
          ${surface === 'admin' ? '' : html`<chatty-avatar label="Store" .status=${status}>S</chatty-avatar>`}
          <span data-pattern-title
            ><strong
              >${title ?? (surface === 'admin' ? 'Customer conversation' : strings.header)}</strong
            >${surface === 'admin' ? html`<chatty-badge size="sm" variant="secondary" style="align-self:flex-start">Customer</chatty-badge>` : status == null ? '' : html`<small data-pattern-status>${status === 'online' ? 'Open' : 'Closed'}</small>`}</span
          >
          <span data-pattern-actions>${headerActions ?? ''}</span>
          ${
            surface === 'admin'
              ? ''
              : html`<chatty-icon-button label="Close panel" @click=${event => toggle(event, true)}
                  >${IconClose()}</chatty-icon-button
                >`
          }
        </div>
        <chatty-thread .strings=${{bot: 'Assistant', ...strings}}></chatty-thread>${content ?? ''}
        <chatty-composer
          slot="footer"
          ?hidden=${composerHidden}
          .label=${strings.message}
          .sendLabel=${strings.send}
          @chatty-send=${event => {
            appendViewer(store, surface, event.detail.text);
            if (onSend) onSend(event.detail.text, event.currentTarget);
            else if (surface !== 'admin')
              store.setMessages([
                ...store.getState().messages,
                {
                  id: `fixture-${store.getState().messages.length}`,
                  senderType: 'bot',
                  text: `You asked: “${event.detail.text}”. I can help with that.`,
                  hasEventTime: false
                }
              ]);
          }}
        ></chatty-composer> </chatty-surface
      >${
        surface === 'admin'
          ? ''
          : surface === 'ai-mode'
            ? html`<chatty-launcher
                data-pattern-launcher
                hidden
                label="Open chat"
                @chatty-open=${event => toggle(event, false)}
                >${IconMessage({size: 20, slot: 'icon'})}Ask a question</chatty-launcher
              >`
            : html`<chatty-icon-button
                data-pattern-launcher
                hidden
                size="lg"
                label="Open chat"
                @click=${event => toggle(event, false)}
                >${IconMessage({size: 24})}</chatty-icon-button
              >`
      }
    </div>`;
}

import {createBlockRegistry} from '@avada/chatty-ui/behaviors/block-registry.js';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
import '@avada/chatty-ui/elements/chatty-block-contact-methods.js';
const strings = {
  header: 'Store assistant',
  message: 'Message',
  send: 'Send',
  handoff: 'Hand-off',
  verified: 'Verified by email code at hand-off',
  reason: 'Return or refund request',
  origin: 'Handed off by the AI assistant',
  order: 'Order number',
  inTransit: 'In transit',
  late: 'Running late',
  viewing: 'Viewing'
};
const adminPreview = () => {
  const store = fixtureStore([{...question, text: 'I would like to return order #1001.'}]);
  const mode = new URLSearchParams(location.search).get('mobile');
  const mobile = mode === null ? innerWidth < 768 : mode === 'true';
  return html`<style>
      [data-handoff-admin] {
        display: flex;
        gap: 6px;
        max-inline-size: 793px;
        inline-size: 100%;
        margin: auto;
        min-inline-size: 0;
        position: relative;
        box-sizing: border-box;
      }
      [data-handoff-admin]:has([data-admin-detail]) {
        padding-block-end: 64px;
      }
      [data-handoff-chat] {
        min-inline-size: 0;
        flex: 1;
      }
      [data-admin-detail] {
        --chatty-color-text-link: #005bd3;
        box-sizing: border-box;
        flex: 0 0 260px;
        height: 842px;
        overflow: auto;
        scrollbar-gutter: stable;
        padding: 12px;
        background: #fff;
        border: 1px solid #e3e3e3;
        font: 13px/20px system-ui;
        color: #303030;
      }
      [data-admin-detail] section {
        padding-block: 12px;
        border-bottom: 1px solid #e3e3e3;
      }
      [data-admin-detail] h2 {
        font: 650 14px/20px system-ui;
        margin: 0 0 8px;
      }
      [data-admin-detail] p {
        margin: 8px 0;
      }
      [data-admin-detail] [hidden] {
        display: none !important;
      }
      [data-order-id] {
        padding: 12px 0;
        border-bottom: 1px solid #e3e3e3;
        scroll-margin: 12px;
      }
      [data-order-heading] {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
      }
      [data-order-heading] chatty-icon-button {
        --chatty-icon-button-size: 28px;
      }
      [data-handoff-admin] chatty-toast {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        inline-size: max-content;
        max-inline-size: calc(100% - 32px);
        z-index: 2;
      }
      [data-handoff-admin] chatty-toast::part(base) {
        min-inline-size: 0;
        max-inline-size: 100%;
      }
    </style>
    <div data-handoff-admin>
      <div data-handoff-chat>${patternShell({surface: 'admin', store, title: 'Alex Morgan'})}</div>
      ${
        mobile
          ? ''
          : html`<aside data-admin-detail aria-label="Conversation details">
                <section aria-label="Hand-off">
                  <h2>Hand-off</h2>
                  <chatty-badge data-verified tone="neutral" data-admin-tone="info"
                    >Verified by email code at hand-off</chatty-badge
                  >
                  <chatty-badge data-unverified tone="caution" data-admin-tone="attention" hidden
                    >Not verified at hand-off</chatty-badge
                  >
                  <p>Return or refund request</p>
                  <p style="font-size:12px;color:#616161">Handed off by the AI assistant</p>
                  <div data-verified>
                    <chatty-button
                      variant="plain"
                      @click=${event => {
                        event.currentTarget.focus({preventScroll: true});
                        const detail = event.currentTarget.closest('[data-admin-detail]');
                        const row = detail
                          .querySelector('[data-order-id="1001"]')
                          .getBoundingClientRect();
                        const box = detail.getBoundingClientRect();
                        const top =
                          row.top < box.top + 12
                            ? row.top - box.top - 12
                            : Math.max(0, row.bottom - box.bottom + 12);
                        detail.scrollBy({
                          top,
                          behavior: matchMedia('(prefers-reduced-motion: reduce)').matches
                            ? 'instant'
                            : 'smooth'
                        });
                      }}
                      >#1001</chatty-button
                    >
                    · In transit
                    <chatty-badge tone="caution" data-admin-tone="warning"
                      >Running late</chatty-badge
                    >
                  </div>
                  <p data-unverified hidden>
                    <strong>#1001</strong>
                    <chatty-badge tone="caution" data-admin-tone="attention"
                      >Order number not verified</chatty-badge
                    >
                  </p>
                  <p style="font-size:12px;color:#616161">Viewing Canvas tote</p>
                </section>
                <section aria-label="Customer">
                  <h2>Customer</h2>
                  <p>Alex Morgan</p>
                  <p>alex@example.com</p>
                  <p>United States</p>
                </section>
                <section aria-label="Shopping activity">
                  <h2>Shopping activity</h2>
                  <p>Viewed Canvas tote</p>
                  <p>Added Canvas tote to cart</p>
                  <p>Visited return policy</p>
                </section>
                <section aria-label="Recent orders">
                  <h2>Recent orders</h2>
                  ${[1003, 1002, 1001].map(
                    id =>
                      html`<article data-order-id=${id}>
                        <div data-order-heading>
                          <strong>#${id}</strong
                          ><chatty-icon-button
                            label="Copy order status page"
                            @click=${async event => {
                              const root = event.currentTarget.closest('[data-handoff-admin]');
                              const toast = root.querySelector('chatty-toast');
                              try {
                                await navigator.clipboard.writeText(
                                  `https://shopify.com/123456/account/orders/${id}`
                                );
                                toast.textContent = 'Copied to clipboard';
                                toast.tone = 'neutral';
                              } catch {
                                toast.textContent = 'Could not copy. Please try again.';
                                toast.tone = 'critical';
                              }
                              toast.open = true;
                            }}
                            >${IconCopy({size: 16})}</chatty-icon-button
                          >
                        </div>
                        <p>In transit · $48.00</p>
                        <p>Canvas tote × 1</p>
                        <chatty-link
                          href=${`https://admin.shopify.com/store/example/orders/${id}`}
                          target="_blank"
                          >View order</chatty-link
                        >
                      </article>`
                  )}
                </section>
              </aside>
              <chatty-toast>Copied to clipboard</chatty-toast>`
      }
    </div>`;
};

export function StandardAdmin() {
  return adminPreview();
}

Các block khác: N/A trong preview. Cột chi tiết: N/A trong preview Mobile.

Import / element

HandoffCard

Component / element Import / file Scope root
HandoffCard import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard.js'; .Avada-Faq_Conversation-Detail_Handoff

Anatomy

HandoffCard

Part Element
1 Tiêu đề Hand-off kèm Badge trạng thái xác minh.
2 Lý do bàn giao ở Text cỡ bodyMd.
3 Nguồn bàn giao ở Text cỡ bodySm khi khác lý do.
4 Đơn liên quan: nút đơn đã xác minh hoặc số đơn khách nhập kèm Badge chưa xác minh.
5 Dòng sản phẩm khách đang xem, là link khi url là http.

Placement / order

HandoffCard

Context Order
Chi tiết hội thoại Đầu phần chi tiết; thứ tự: tiêu đề và Badge, lý do, nguồn, đơn, sản phẩm.

Props

HandoffCard

Prop Type Values Default Notes
handoffContext object source, trigger, issueType, order, claimedOrderName, products, verified, authMethod undefined Đọc từ useInboxConversation; không có thì card trả null.

Sizes

HandoffCard

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Card Theo nội dung Theo class của trang chi tiết 200 (BlockStack) Không khai báo headingSm / bodyMd / bodySm (Polaris Text) Nút đơn là Polaris Button plain Polaris, không có override theo viewport

Tokens

HandoffCard

Part Token Light Dark
Badge đã xác minh bằng tài khoản shop tone Tone success của Polaris No Dark skin
Badge đã xác minh bằng mã email tone Tone info của Polaris No Dark skin
Badge chưa xác minh tone="attention" Tone attention của Polaris No Dark skin
Badge vấn đề đơn tone="warning" Tone warning của Polaris No Dark skin

States

HandoffCard

State Trigger Visual change (values) ARIA/attribute
Verified at hand-off verified và đăng nhập tài khoản shop Badge tone success Không thêm ARIA
Verified by email code verified và không phải tài khoản shop Badge tone info Không thêm ARIA
Not verified at hand-off verified sai Badge tone attention Không thêm ARIA
Đơn khách nhập chưa xác minh claimedOrderName và không có order Tên đơn kèm Badge tone attention Không thêm ARIA
Ẩn Không có handoffContext Card trả null Không có node

Behaviour

HandoffCard

Interaction Result
Chọn lý do Ưu tiên issueType, rồi trigger, rồi source.
Dòng nguồn Chỉ hiện khi lý do không phải nhãn source.
Nút đơn Cuộn tới đơn tương ứng trong khối Orders khi có id.
Link sản phẩm Chỉ là link khi url là http hoặc https; mở tab mới.

Copy

HandoffCard

String i18n key Where
Hand-off Hand-off Tiêu đề, namespace inbox-management
Customer asked for a person Customer asked for a person Nhãn trigger customer_request
The AI could not answer The AI could not answer Nhãn trigger ai_cannot_answer
Handed off by the AI assistant Handed off by the AI assistant Nhãn source ai_tool
Verified at hand-off Verified at hand-off Badge xác minh bằng tài khoản shop
Not verified at hand-off Not verified at hand-off Badge chưa xác minh

Source

HandoffCard

File Evidence
Cấu trúc, state và hành vi
Nhãn staff-facing

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Classic Hàng gồm icon aria-hidden và nhãn chữ; chỉ có role status khi announce. Không tương tác; nút Send của form trước đó bị thay nên focus không được chuyển tới dòng xác nhận. role status chỉ cho lần gửi hiện tại; lịch sử im lặng. Không đo: màu nhãn lấy từ token và nền do popup
AI Mode Hàng gồm icon aria-hidden và nhãn chữ; chỉ có role status khi announce. Không tương tác; focus không được chuyển tới dòng xác nhận sau khi gửi. Khi gửi lỗi, focus không đổi và không có control Retry riêng: bấm Send lại. role status cho lần gửi hiện tại; lỗi nằm trong role alert. Không đo vì nền glass có alpha
Admin Polaris Badge và Text; nút đơn là Button native. Nút đơn nhận Tab và Enter; link sản phẩm mở tab mới. HandoffCard không quản lý focus. Không có live region. Không đo: màu do Polaris tone