ナビゲーション

v2.1.0
フォーム

インライン編集

テキストとして表示され、その場で入力フィールドに切り替わる値。

このページの内容

インライン編集は、テキストとして表示され、その場で入力フィールドに切り替わる値です。タイトル、名前、セルなどに使います。通常時は、囲んでいる要素の書体で表示されるただのテキストです。ポインターを重ねると周囲に淡いくぼみが現れ、末尾に鉛筆アイコンが表示されます。押すと、くぼみがフォーカスされた入力フィールドに変わり、値が選択された状態になります。プレビューとフィールドは同じグリッドセル、フォント、パディング、角丸を共有するため、切り替わってもテキストは 1px も動きません。editable のビヘイビアが表示の切り替えと保存を行います。

インライン編集

<div class="max-w(420) mx-auto">  <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>  <h2 class="heading heading-xl">    <span class="editable">      <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">        Quarterly report<svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" />        </svg>      </button>      <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>    </span>  </h2>  <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-react/native/16/soft/pencil'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="max-w(420) mx-auto">      <span className="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>      <h2 className="heading heading-xl">        <span className="editable">          <button type="button" className="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">            Quarterly report<PencilIcon className="icon editable-pencil" />          </button>          <input className="editable-field" defaultValue="Quarterly report" aria-labelledby="doc-title-label" required maxLength={80} hidden />        </span>      </h2>      <span className="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PencilIcon from '@master/icons-svelte/native/16/soft/pencil'</script><div class="max-w(420) mx-auto" {@attach attach}>  <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>  <h2 class="heading heading-xl">    <span class="editable">      <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">        Quarterly report<PencilIcon class="icon editable-pencil" />      </button>      <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>    </span>  </h2>  <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-vue/native/16/soft/pencil'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="max-w(420) mx-auto">    <span class="block mb-xs text-xs fg-text-muted" id="doc-title-label">Title</span>    <h2 class="heading heading-xl">      <span class="editable">        <button type="button" class="editable-preview" id="doc-title-preview" aria-labelledby="doc-title-label doc-title-preview">          Quarterly report<PencilIcon class="icon editable-pencil" />        </button>        <input class="editable-field" value="Quarterly report" aria-labelledby="doc-title-label" required maxlength="80" hidden>      </span>    </h2>    <span class="block mt-xs text-sm fg-text-muted">Last edited by Ada, 2 minutes ago</span>  </div></template>
タイトルを押して入力し、Enter キーで保存するか、Escape キーで元に戻します。

#テキストの位置

値は、置かれている列の位置に揃います。ルート要素は左右に --editable-padding-x だけはみ出すため、くぼみはテキストを内側に押し込まず、テキストの周りに広がります。パディングは em 単位なので、見出しのくぼみは見出しの大きさに、セルのくぼみはセルの大きさに見合ったゆとりを持ちます。

  • 通常時 プレビューはただのテキストです。ボタンなのでフォーカスを受け取り、テキストの後ろに置いた editable-pencil アイコンの鉛筆が、フォーカスリングとともに表示されます。
  • ポインターを重ねたとき テキストの周りにくぼみの色調と 0.5px の輪郭が現れ、最後の単語の後ろに鉛筆アイコンが表示されます。ホバーできるポインターがない画面では、鉛筆アイコンが少し控えめな色で常に表示されます。テキストを変更できることを示す唯一の手がかりだからです。
  • 編集中 フィールドは、フォーカスされた入力欄と同様に、シートの高さまで持ち上がったくぼみになり、インク色の輪郭 1 本とハローが付きます。プレビューは非表示になってもセルの大きさを保つため、下にある要素は動きません。ブラウザーが field-sizing: content に対応していれば、値に合わせてフィールドがプレビューより広がります。対応していない場合は、プレビューの幅の中でテキストがスクロールします。
  • 保存待ち 値の送信中は、ルート要素に aria-busy="true" を設定します。プレビューは控えめな色になり、押しても反応しなくなります。

#複数行

フィールドに <textarea> を使うと、複数行の値を扱えます。その中では Enter で改行するため、保存するには、Control または Command を押しながら Enter を押します。値が空の間、プレビューにはフィールドの placeholder が editable-placeholder で表示されます。

複数行

<div class="max-w(420) mx-auto text-sm fg-text-body">  <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>  <div class="editable w-full">    <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">      <span class="editable-placeholder">Add a summary for the team</span><svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" />      </svg>    </button>    <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>  </div></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-react/native/16/soft/pencil'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="max-w(420) mx-auto text-sm fg-text-body">      <span className="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>      <div className="editable w-full">        <button type="button" className="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">          <span className="editable-placeholder">Add a summary for the team</span><PencilIcon className="icon editable-pencil" />        </button>        <textarea className="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows={3} hidden>{``}</textarea>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PencilIcon from '@master/icons-svelte/native/16/soft/pencil'</script><div class="max-w(420) mx-auto text-sm fg-text-body" {@attach attach}>  <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>  <div class="editable w-full">    <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">      <span class="editable-placeholder">Add a summary for the team</span><PencilIcon class="icon editable-pencil" />    </button>    <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PencilIcon from '@master/icons-vue/native/16/soft/pencil'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="max-w(420) mx-auto text-sm fg-text-body">    <span class="block mb-xs text-xs fg-text-muted" id="doc-summary-label">Summary</span>    <div class="editable w-full">      <button type="button" class="editable-preview" id="doc-summary-preview" aria-labelledby="doc-summary-label doc-summary-preview">        <span class="editable-placeholder">Add a summary for the team</span><PencilIcon class="icon editable-pencil" />      </button>      <textarea class="editable-field" aria-labelledby="doc-summary-label" placeholder="Add a summary for the team" rows="3" hidden></textarea>    </div>  </div></template>

#ビヘイビア

editable は、editable クラスを持つルート要素を受け取り、ビヘイビアを解除する関数を返します。

app.js
import { editable } from '@master/ui/behaviors/editable.js'const title = editable(document.querySelector('.editable'))title.edit() // open the fieldtitle.value // the saved value
  • 編集の開始 プレビューを押すとプレビューが非表示になり、保存済みの値を入れたフィールドが表示され、そのテキストが選択されます。
  • 保存 Enter を押すか、フィールドからフォーカスが外れると保存されます。フィールド自体の制約(required、maxlength、pattern)を満たさない値は保存されません。Enter の場合はフィールドが開いたままになり、ブラウザーが理由を表示します。フォーカスが外れた場合は保存済みの値に戻ります。フォーカスが外れたときに編集を取り消すには、blur: 'cancel' を渡します。
  • 取り消し Escape を押すと保存済みの値に戻ります。
  • フォーカス Enter と Escape のあとはプレビューに戻ります。利用者がフォーカスをほかの場所に移した場合は戻しません。
  • イベント 異なる値を保存すると、その値をプレビューに書き込み、フィールドから input と change を発行します。返される関数は、保存済みの値を表す value と edit() を持ちます。value に代入するとプレビューとフィールドに書き込まれますが、イベントは発行されません。

その後に値をどこへ送るかは、ページ側で決めます。送信中はルート要素に aria-busy="true" を設定します。サーバーが値を受け付けなかった場合は、値を元に戻してその横に理由を表示するか、edit() を呼び出してフィールドに aria-invalid="true" を設定します。後者では危険を示す色の縁が表示され、入力した内容は利用者が修正できるように保持されます。

ビヘイビアを適用しない場合、プレビューは何もしないボタンになり、値はそのまま読めます。

#使いどころ

インライン編集は、変更されるよりも読まれることがはるかに多く、その場で 1 つずつ変更される値に適しています。複数の値をまとめて変更し、一度に保存する場合は、入力フィールドと保存ボタンを備えたフォームのほうが、何がいつ保存されるかを明確に伝えられます。

#キーボード操作

キー操作
Enter, Spaceプレビューにフォーカスがあるときは、値を選択した状態でフィールドを開きます。
Enterフィールドでは、値を保存してプレビューに戻ります。textarea では Control または Command と Enter を使います。
Escape保存済みの値に戻し、プレビューに戻ります。
Tabフィールドから移動します。値は保存されますが、フィールドの制約を満たさない場合は保存済みの値に戻ります。

入力メソッドで文字が未確定の間は、Enter と Escape を入力メソッドが処理します。

#アクセシビリティ

  • 値とフィールドには、それが何の値かがわかる名前を付けます。例では、表示されたラベルでフィールドに名前を付け、プレビューには aria-labelledby でラベルとプレビュー自身を参照させています。そのため、「Title, Quarterly report, button」のように読み上げられます。
  • スクリプトがなくても保存済みの値を読めるようにします。保存済みの値はプレビューのテキストです。
  • 保存に失敗したことは、危険を示す色の縁だけに頼らず、値の横に言葉で伝えます。

#React、Svelte、Vue

editable コンポーネントは、最初の描画で初期値を表示し、ビヘイビアを適用します。それ以降のプレビューはビヘイビアが書き込みます。外部に渡される値は保存済みの値で、入力途中の値は渡されません。npx master-ui add editable でプロジェクトにコピーできます。コンポーネントの構成と使い方は React、Svelte、Vue を参照してください。

ui/editable.tsx
'use client'import { useId, useState, type ComponentProps } from 'react'import { editable } from '@master/ui/behaviors/editable.js'import { useBehavior } from './use-behavior'type Field = Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'hidden'> & Omit<ComponentProps<'textarea'>, 'value' | 'defaultValue' | 'hidden'>export interface EditableProps extends Omit<Field, 'children'> {  /** The saved value. */  value?: string  defaultValue?: string  onValueChange?: (value: string) => void  /** What the value is, read with it by assistive technology: the field's name. */  label: string  /** A textarea, for a value of several lines. */  multiline?: boolean  /** The value is on its way: the preview waits. */  busy?: boolean  /** What leaving the field does. `'save'` by default. */  blur?: 'save' | 'cancel'}/** * An editable value. Every prop of a field goes to the field, so `required`, `maxLength` and `placeholder` * are its constraints and what the preview says while the value is empty. *//** The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes. */const fielded = (root: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(root, { blur: options?.blur })export function Editable({ value, defaultValue, onValueChange, label, multiline, busy, blur, disabled, className, ...field }: EditableProps) {  const id = useId()  // The first value is drawn into the first render; after that the behavior writes the preview and the field.  const [first] = useState(() => value ?? defaultValue ?? '')  const ref = useBehavior(fielded, { blur, multiline }, { value, defaultValue, onValueChange })  const shared = { className: 'editable-field', 'aria-label': label, disabled, hidden: true }  return (    <div className={className ? `editable ${className}` : 'editable'} ref={ref} aria-busy={busy || undefined}>      <button type="button" className="editable-preview" id={`${id}preview`} aria-labelledby={`${id}name ${id}preview`} disabled={disabled}>        {first || (field.placeholder ? <span className="editable-placeholder">{field.placeholder}</span> : null)}        <svg className="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>      </button>      <span id={`${id}name`} hidden>{label}</span>      {multiline        ? <textarea {...(field as ComponentProps<'textarea'>)} {...shared} defaultValue={first} />        : <input {...(field as ComponentProps<'input'>)} {...shared} defaultValue={first} />}    </div>  )}
ui/Editable.svelte
<script lang="ts" module>  import type { HTMLInputAttributes } from 'svelte/elements'  export interface EditableProps extends Omit<HTMLInputAttributes, 'value' | 'hidden' | 'children'> {    /** The saved value. Bind it, or leave it out. */    value?: string    onValueChange?: (value: string) => void    /** What the value is, read with it by assistive technology: the field's name. */    label: string    /** A textarea, for a value of several lines. */    multiline?: boolean    /** The value is on its way: the preview waits. */    busy?: boolean    /** What leaving the field does. `'save'` by default. */    blur?: 'save' | 'cancel'  }</script><script lang="ts">  import { untrack } from 'svelte'  import { editable } from '@master/ui/behaviors/editable.js'  import { behavior } from './behavior.svelte.js'  let { value = $bindable(), onValueChange, label, multiline, busy, blur, disabled, class: className, ...field }: EditableProps = $props()  const id = $props.id()  // The first value is drawn into the first render; after that the behavior writes the preview and the field.  const first = untrack(() => value) ?? ''  // The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes.  const fielded = (root: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(root, { blur: options?.blur })  const attach = behavior(fielded, () => ({ blur, multiline }), {    value: () => value,    change: (next) => { value = next; onValueChange?.(next) },  })</script><!--  @component  An editable value. Every other prop of a field goes to the field, so `required`, `maxlength` and  `placeholder` are its constraints and what the preview says while the value is empty.--><div class={['editable', className]} aria-busy={busy || undefined} {@attach attach}>  <button type="button" class="editable-preview" id="{id}preview" aria-labelledby="{id}name {id}preview" {disabled}>    {#if first}{first}{:else if field.placeholder}<span class="editable-placeholder">{field.placeholder}</span>{/if}<svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>  </button>  <span id="{id}name" hidden>{label}</span>  {#if multiline}    <textarea class="editable-field" aria-label={label} {disabled} hidden {...field as Record<string, unknown>} value={first}></textarea>  {:else}    <input class="editable-field" aria-label={label} {disabled} hidden {...field} value={first} />  {/if}</div>
ui/Editable.vue
<script setup lang="ts">import { useAttrs, useId, useTemplateRef } from 'vue'import { editable } from '@master/ui/behaviors/editable.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { blur, multiline } = defineProps<{  /** What the value is, read with it by assistive technology: the field's name. */  label: string  /** A textarea, for a value of several lines. */  multiline?: boolean  /** The value is on its way: the preview waits. */  busy?: boolean  /** What leaving the field does. `'save'` by default. */  blur?: 'save' | 'cancel'  disabled?: boolean}>()/** The saved value: `v-model`. */const model = defineModel<string>()/* * An editable value. Every attribute but the class goes to the field, so `required`, `maxlength` and * `placeholder` are its constraints and what the preview says while the value is empty. */const id = useId()const attrs = useAttrs()const field = () => {  const { class: _, ...rest } = attrs  return rest}// The first value is drawn into the first render; after that the behavior writes the preview and the field.const first = model.value ?? ''const placeholder = attrs.placeholder as string | undefinedconst root = useTemplateRef<HTMLDivElement>('root')// The behavior finds its field as it attaches. One line and several are two elements, so it attaches again when `multiline` changes.const fielded = (element: HTMLElement, options?: { blur?: 'save' | 'cancel', multiline?: boolean }) => editable(element, { blur: options?.blur })useBehavior(root, fielded, () => ({ blur, multiline }), model)</script><template>  <div class="editable" :class="$attrs.class" :aria-busy="busy || undefined" ref="root">    <button type="button" class="editable-preview" :id="`${id}-preview`" :aria-labelledby="`${id}-name ${id}-preview`" :disabled="disabled">      <template v-if="first">{{ first }}</template>      <span v-else-if="placeholder" class="editable-placeholder">{{ placeholder }}</span>      <svg class="icon editable-pencil" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.6556 12.4849L3.2844 10.1793A0.7 0.7 0 0 1 3.4647 9.8686L10.505 2.8283A0.7 0.7 0 0 1 11.495 2.8283L13.1717 4.505A0.7 0.7 0 0 1 13.1717 5.495L6.1314 12.5353A0.7 0.7 0 0 1 5.8207 12.7156L3.5151 13.3444A0.7 0.7 0 0 1 2.6556 12.4849Z" /><path d="M9.6667 3.6667L12.3333 6.3333" /></svg>    </button>    <span :id="`${id}-name`" hidden>{{ label }}</span>    <textarea v-if="multiline" class="editable-field" :aria-label="label" :disabled="disabled" hidden v-bind="field()" :value.attr="first" />    <input v-else class="editable-field" :aria-label="label" :disabled="disabled" hidden v-bind="field()" :value.attr="first">  </div></template>

#クラス

クラス説明
editable値とそのフィールドを 1 つのセルに収め、セルの大きさはプレビューが保ちます。パディングの分だけ外側にはみ出すため、テキストは列の位置に揃います。
editable-preview保存済みの値を表示するボタンです。通常時はただのテキストで、ポインターを重ねると淡いくぼみと鉛筆アイコンが表示されます。非表示になってもセルの大きさを保ちます。
editable-pencilプレビューのテキストの後ろにある鉛筆アイコンです。ポインターを重ねたときとフォーカス時に表示され、ホバーできるポインターがない場合は常に表示されます。
editable-fieldプレビューの代わりに表示されるフィールドで、通常時は非表示です。同じフォント、パディング、角丸を持つ、フォーカスされたくぼみとして表示されます。
editable-placeholder値が空のときは、プレビュー内にフィールドのプレースホルダーを控えめな文字色で表示します。

#カスタムプロパティ

プロパティ既定値説明
--editable-padding-x.375emプレビューとフィールドのインライン方向のパディング。ルート要素はこの分だけ外側にはみ出します。
--editable-padding-y.125emプレビューとフィールドのブロック方向のパディング
--editable-radiusvar(--radius-control-sm)くぼみの角の丸み

#ソース

@master/ui/components/editable.css
/* * Editable: a value read as text that becomes a field in place. * The preview and the field stand in one grid cell with the same font, padding and corner, so the text does * not move by a pixel when one replaces the other: the preview stays in the layout while it is hidden and * holds the cell open. At rest the value is plain text, set out from the column by the padding it bleeds * into; under the pointer a faint well appears around it with a pencil at its end, and while editing the * well is a focused field. Its type is whatever it stands in: a heading, a cell, a line of a form. * The editable behavior switches the two and saves; without it the preview is a button that does nothing. */@layer components.ui {  .editable {    --editable-padding-x: .375em;    --editable-padding-y: .125em;    --editable-radius: var(--radius-control-sm);    position: relative;    display: inline-grid;    grid-template: auto / minmax(0, auto);    max-width: calc(100% + var(--editable-padding-x) * 2);    /* The text lines up with the column; the well reaches out around it. */    margin-inline: calc(-1 * var(--editable-padding-x));    vertical-align: baseline;    /*     * While the value is on its way, the preview waits: it reads as pending and takes no press. The pointer     * passes through it to the root, so the root is what shows the progress cursor.     */    &[aria-busy="true"] {      cursor: progress;    }    &[aria-busy="true"] .editable-preview {      color: var(--color-text-muted);      pointer-events: none;      .editable-pencil {        opacity: 0;      }    }  }  /* What the preview and the field share, so that one sits exactly where the other was. */  .editable-preview,  .editable-field {    grid-area: 1 / 1;    box-sizing: border-box;    min-width: 0;    margin: 0;    padding: var(--editable-padding-y) var(--editable-padding-x);    border: 0;    border-radius: calc(var(--editable-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    font: inherit;    font-feature-settings: inherit;    letter-spacing: inherit;    text-align: start;    text-transform: inherit;  }  .editable-preview {    position: relative;    display: block;    background: transparent;    color: inherit;    white-space: pre-wrap;    overflow-wrap: anywhere;    appearance: none;    cursor: text;    -webkit-tap-highlight-color: transparent;    transition-property: background-color, box-shadow;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);    /* The pencil: it follows the last word, so it says what the press will do where the eye already is. */    .editable-pencil {      display: inline-block;      width: .8125em;      height: .8125em;      margin-inline-start: .375em;      color: var(--color-text-muted);      vertical-align: -.0625em;      opacity: 0;      transition: opacity var(--duration-quick) var(--easing-glide);    }    @media (hover: hover) {      &:hover:not(:disabled) {        background: var(--color-surface-inset);        box-shadow: inset 0 0 0 .5px var(--color-line-contour);        .editable-pencil {          opacity: 1;        }      }    }    /* Without a pointer that hovers, the pencil is always there: the only sign the text can be changed. */    @media (hover: none) {      &:not(:disabled) .editable-pencil {        opacity: .7;      }    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 0;      .editable-pencil {        opacity: 1;      }    }    &:active:not(:disabled) {      background: var(--color-surface-inset-hover);    }    &:disabled {      cursor: default;    }    /* Hidden, it still holds the cell open, so the field takes its place and nothing below moves. */    &[hidden] {      display: block;      visibility: hidden;    }    /* A touch target reaches 44px tall without moving the text. */    @media (pointer: coarse) {      &::before {        @apply --touch-target-block;      }    }    @media (forced-colors: active) {      .editable-pencil {        color: ButtonText;      }      /* Heavier than the focus ring, so it steps aside on a focused preview instead of thinning its ring. */      @media (hover: hover) {        &:hover:not(:disabled, :focus-visible) {          outline: 1px solid ButtonText;        }      }    }  }  /* The field: a well risen to the sheet with one ink contour and a halo, as a focused input is. */  .editable-field {    display: block;    width: 100%;    outline: none;    background: var(--color-surface-raised);    color: inherit;    box-shadow: inset 0 0 0 .5px var(--color-line-mark), 0 0 0 .5px var(--color-line-mark), 0 0 0 3.5px var(--color-focus-halo);    caret-color: var(--color-text-strong);    resize: none;    appearance: none;    &::placeholder {      color: var(--color-text-muted);      opacity: 1;    }    /* Where the field can size itself, it grows past the preview as the value does. */    @supports (field-sizing: content) {      field-sizing: content;      min-width: 100%;    }    &:is([aria-invalid="true"], :user-invalid) {      box-shadow: inset 0 0 0 .5px var(--color-danger), 0 0 0 .5px var(--color-danger), 0 0 0 3.5px color-mix(in oklab, var(--color-danger) 15%, transparent);    }    &[hidden] {      display: none;    }    @media (forced-colors: active) {      outline: 2px solid Highlight;      outline-offset: -2px;      /* The danger edge is a shadow, which forced colors drop: the outline says it instead. */      &:is([aria-invalid="true"], :user-invalid) {        outline-color: Mark;      }    }  }  /* What the preview says while the value is empty: the field's placeholder, in the muted ink. */  .editable-placeholder {    color: var(--color-text-muted);  }}