diff --git a/docs/components/icon-button/v0.4/hit-area-amendment.md b/docs/components/icon-button/v0.4/hit-area-amendment.md new file mode 100644 index 00000000..19c13346 --- /dev/null +++ b/docs/components/icon-button/v0.4/hit-area-amendment.md @@ -0,0 +1,121 @@ +# IconButton v0.4 — invisible hit-area amendment + +- **Status:** Approved — 2026-11-22 (owner, in session; odd/tasks/consumer-request-specs.md L6). Implementation plan requires separate approval. +- **Amends:** [v0.3](../v0.3/spec.md), [v0.2](../v0.2/hover-motion-amendment.md) and the v0.1 contract in [#57](https://github.com/egdev6/egdev-design-system/issues/57); unmentioned promises remain unchanged. The frozen v0.3 spec still says Draft, but its [implementation plan](../v0.3/implementation-plan.md) records the owner's separate [v0.3 snapshot approval](https://github.com/egdev6/egdev-design-system/issues/57#issuecomment-6576885478); do not rewrite the frozen snapshot. Its historical 32/40/48px descriptions do not describe the current scaled implementation. +- **Approval / recovery:** Owner session 2026-11-22, recorded verbatim in this file's resolved decisions and in odd/tasks/consumer-request-specs.md; this spec is not an implementation authorization. A separate plan approval is required. No code, token, dependency, registry or GitHub change is authorized here. +- **Snapshot identity:** `version: v0.4`; `contentSHA256: 9b79473b96a8ac9a657bcad82604c770a2fafa4228067b79e7d08567c0c116df`; `visualHashes: VIS-01 5b6c4dd02d58a04f36bac9799106ac925825486dde1b4904c30f3bf24bd6a2b5 (historical v0.1); VIS-02 cc7ff50c78f695a4758349aaf430a2aa88cb1b0d0d91c0c64b3e067328e366c9 (historical v0.1); VIS-03 Pending`; `approvalReference: owner session 2026-11-22 (odd/tasks/consumer-request-specs.md L6)`; `canonicalIssue: https://github.com/egdev6/egdev-design-system/issues/57`; `latestPublishedComment: Pending` (v0.4 is unpublished; latest remote history was not checked). +- **Hash definition:** SHA-256 of the UTF-8 payload from the line-start `## 1. Purpose and scope` through EOF, with LF line endings and the final newline. Tracking metadata above that heading is excluded. Finalize before requesting approval or publication. + +## 1. Purpose and scope + +**Proposal.** Extend the pointer target of the existing `@egdev/ui` IconButton without enlarging its visible control or changing its in-flow layout box. Recommend doing so automatically for every enabled size, including `lg`, and for every pointer, with no new prop. This repairs the existing touch-layout promise rather than making a caller discover a new opt-in. The larger target is a square, including around the round `outline` treatment; its corners are invisible. The consumer still has to provide an unobstructed, non-overlapping region. Final API, input policy and geometry remain owner decisions below. + +**Cataloging.** Reuse and amend the exported IconButton atom: it already owns one named action and the relevant size, treatment and Slot behavior. Reuse unchanged cannot meet the recorded target promise; another visual size or variant would change the visible geometry or conflate geometry with appearance. An app wrapper would duplicate the fix and could change layout, focus and Slot semantics. Extraction or a new component adds no distinct responsibility. ListItem continues to own row layout and composition, not the IconButton target. + +**Evidence — inspected, not a runtime measurement.** + +- `packages/ui/src/index.ts:13` and `packages/ui/src/atoms/icon-button/index.ts:1` export the existing atom and its public types. `packages/ui/src/atoms/icon-button/types.ts:5,28-33,64` defines `sm | md | lg`, `size-8/10/12`, and the existing promise: "touch layouts provide a hit area of at least 44px." Under the default token scale these visible border boxes are 25.6, 32 and 38.4 CSS px, respectively (`packages/tokens/src/theme.css:454-458,589-593`); even `lg` is below 44px. The existing CVA contains no hit-area expansion (`types.ts:50-65`). These are source-derived values, not observed browser results. +- `types.ts:51` also applies a motion-safe `scale-94` on active press. A 44.8px descendant hit rectangle scaled with the root would become 42.112px; merely sizing a pseudo-element to `size-14` cannot establish the minimum during press. Reduced-motion behavior and the existing press appearance must be preserved. +- `IconButton.tsx:8-14` uses one native or slotted root and Radix AccessibleIcon; `useIconButton.ts:34-40,54-69` supplies disabled guards and event forwarding. `IconButton.test.tsx:52,100-163,205-214` has existing native, Slot, disabled and focus/press coverage, not browser geometry proof. +- The #540 triage comment records the owner's invisible-area decision and asks how it is enabled, how neighboring targets avoid overlap, and how focus and Material are handled. [Recado #41](https://github.com/egdev6/recado/issues/41) identifies this request and [#538](https://github.com/egdev6/egdev-design-system/issues/538) as issue-backed mitigations. Per `odd/tasks/consumer-request-specs.md:9-10,22-23`, both originate in the same compact note card: a two-line ListItem with a trailing icon action. Keep the Recado TODO/allowlist mitigation until the relevant design-system change ships and the consumer independently verifies removal. + +## 2. Anatomy and composition + +| Part | Proposal | Semantics / compatibility | +| --- | --- | --- | +| Root | Existing visible native `button`, or the supported empty anchor/router host through Radix Slot | `eg-icon-btn`, native/slotted ref, props and event ownership remain on the same root. No wrapper or extra focus stop. | +| Invisible extension | Prefer one empty, absolutely positioned root pseudo-element, centered and square, with transparent paint | Pointer hit region belongs to the root; no accessible node, role, name or public part marker. It must not clip or obscure the focus ring. | +| Icon and hidden name | Existing Radix AccessibleIcon composition | Decorative glyph remains hidden; `label` remains the sole required name input. | + +This is a feasibility proposal, not proof that a pseudo-element works with every host. `asChild` still requires one compatible host that spreads props and forwards its ref (`types.ts:35-46`); native anchors and router anchors must be checked. A child that already owns the selected pseudo-element, clips overflow, or changes positioning/stacking can conflict: do not silently drop the target or overwrite its presentation. Resolve such conflicts in the separate plan or document and approve a precise compatibility restriction before implementation. No new Radix primitive is needed. + +## 3. Public API + +| Existing API | Proposal / compatibility | +| --- | --- | +| `size?: 'sm' \| 'md' \| 'lg'`, default `md` | Remains the **visible** control/glyph preset. All three get the proposed extension; do not add or rename a size. | +| `variant?: 'ghost' \| 'outline' \| 'primary' \| 'secondary'`, default `ghost` | All treatments get identical target semantics. `outline` remains round; the others retain their existing radius. There is no `round` prop and none is proposed. | +| `label: string`, `icon: ReactElement`, `asChild?: boolean`, `children?: ReactElement` | Types, requiredness, default `asChild=false`, hidden naming, decorative icon and Slot restrictions remain unchanged. | +| Native `disabled`, events and attributes, `className`, ref | Existing native/slotted disabled semantics and event forwarding remain; `className` remains root outer layout only, merged with `cn()`, not an appearance or target override. The ref remains on the actual host; no new ref type or export. | + +**Recommended enablement: automatic, no prop.** A change from today's effective target can alter `event.target`, pointer-enter/hover boundaries and which nearby control or row receives a click even though the component itself causes no in-flow layout shift. Consumers may need to change spacing, which *can* shift their layouts. A transparent rectangle is not automatically non-intercepting or safe merely because it is invisible. Audit dense consumers and provide the spacing rules below before adopting this behavior. + +**Alternative — opt-in:** `extendHitArea?: boolean`, proposed default `false`, applies the extension only when true. This avoids changing existing hit testing until the caller opts in, but omitted/false controls, including `lg`, retain the broken touch promise; it does **not** satisfy the requested universal fix without an explicit owner decision to narrow that promise and update its documentation. Defaulting true with a false opt-out instead preserves the automatic default but permits intentionally undersized targets and introduces an API/contract exception. Neither alternative is approved. + +**Prop naming lookup.** Consulted the [registry source](../../../../skills/_shared/prop-naming.json) and [generated view](../../../prop-naming.md) by meaning, name and aliases for hit area, touch target, hitbox, target size, size and density. Existing approved `preset-dimensions` / `size` (`skills/_shared/prop-naming.json:737`, `docs/prop-naming.md:180`) selects visible dimensional presets; it does not name a separate invisible target. `visual-treatment` / `variant` (`prop-naming.json:1014`) is appearance, not hit geometry. Density references describe component size or unrelated effect profiles, not target expansion. Existing `accessible-name`, `leading-icon` and `slot-composition` stay unchanged (`prop-naming.json:1606,2591,2852`). + +If the owner selects opt-in, propose **new**, not registered or approved: semantic ID `hit-area-extension`, canonical name `extendHitArea`, component-specific `IconButton` type `boolean`, optional, proposed default `false`; meaning: enable a larger invisible pointer target without changing visible dimensions or layout. No exception is proposed. Reviewed baseline source: `{ path: 'packages/ui/src/atoms/icon-button/types.ts', symbol: 'IconButtonProps', revision: 'sha256:9018d3d7c164e7858bd40a937af4cf968fa0ccb4ee32c3820abf6ca048109f75' }`; this identifies the existing type and does **not** claim the prop exists. Convention approval, a future reviewed usage/source revision and registry integration require separate authorization. The recommended automatic option needs no new entry or exception. + +Controlled/uncontrolled state is not applicable. No new prop, default, export or registry change is approved by this draft. + +## 4. Behavior + +**Proposed target and input policy.** For every enabled IconButton, on every pointer type, make the centered usable target at least 44 × 44 CSS px. With default tokens, propose a 44.8 × 44.8px square using `--space-14` / `--spacing-14`. Its rest-state outsets from each visible edge are 9.6px (`sm`), 6.4px (`md`) and 3.2px (`lg`). The minimum applies to the actual clickable region, not just a declared width or a circle's bounding box. The target must remain usable across pointer-down, active feedback and release, without moving the pointer, including points inside the outer corners of a centered 44 × 44px square. A touch must not turn into a neighboring action or a duplicate activation. + +| Action / condition | Proposed result | +| --- | --- | +| Pointer enters and activates an enabled extension | The same root action or slotted link receives one native activation; existing callbacks, navigation and event propagation remain. The extension may cause hover/tooltip triggering earlier than the visible boundary. | +| Keyboard Tab, Enter or Space | Existing native button behavior remains; a link retains native link keys. The extension is not independently focusable and adds no keyboard handler. | +| Disabled native button or slotted host | Existing `disabled` or `aria-disabled`, `data-disabled`, tab-order and activation guards remain. The extension must not independently receive pointer events; preserve the existing disabled `pointer-events: none` policy. Events may fall through to underlying content, so a host must not depend on a disabled target blocking its row. | +| Tooltip wraps the button | Existing Radix Tooltip trigger/ref and supplementary description remain; pointer entry may occur over the extension. Do not promise a tooltip opens on touch or becomes the accessible name. | + +**Implementation direction, subject to plan review.** Prefer a static token-backed, empty `::after` on a positioned root, inheriting disabled pointer behavior and routing native pointer input to that root. It must have no background, border, shadow or focus appearance. Validate the actual hit-tested square and the interaction with root transitions, active `scale-94`, reduced motion, stacking, clipping, Slot and a child's own pseudo-elements. A pseudo-element is transformed with its ancestor; the plan must demonstrate a compliant way to keep the required region effective throughout press and release, not assume a declared 44.8px remains 44.8px. If that cannot be shown without changing visible press feedback, stop for a revised proposal; `--space-16` (51.2px at rest, 48.128px at steady 0.94 scale) is a possible larger-token fallback, with increased overlap and press-edge risks, not an approved automatic substitution. In either case test the complete down/up sequence, including the boundary of the promised square. No custom event forwarding, synthetic click, new inline geometry or dynamic utility-string interpolation is authorized here. + +Padding plus negative margins is an alternative, but rejected as the recommendation: even if it preserves a flex/grid footprint, it changes the button border box, native ref geometry, focus/shadow boundary and potentially clipping/Slot layout. It does not meet this proposal's unchanged visible-root box without a separately reviewed structural solution. + +**Pointer policy alternatives.** `@media (pointer: coarse)` limits interception on a fine primary pointer and matches the existing Slider precedent (`packages/ui/src/atoms/slider/types.ts:74-76`), but can miss touch on hybrids whose primary pointer is fine. `@media (any-pointer: coarse)` also covers a secondary touch capability, but expands mouse hit testing on such devices and does not identify each event's input type. Always-on covers hybrids and avoids media-query detection gaps, but changes fine-pointer hit testing everywhere. Recommend always-on; the owner must select the policy, not infer it from this draft. + +**Overlap and host responsibilities.** Expanded targets must not overlap any other interactive hit region, including neighboring rows, links, drag handles or controls. For horizontally aligned controls with overlapping vertical ranges, the visible edge-to-edge gap must be at least the sum of their outsets: two `sm` buttons need 19.2px, two `md` need 12.8px, and two `lg` need 6.4px under the proposed default tokens. Mixed sizes use the sum of their respective outsets. These are illustrative minima for the proposed 44.8px rectangle, not automatic layout or collision detection. Actual target regions, stacking, writing direction and vertical gaps must also be checked; an unrelated overlay or clipped ancestor can invalidate the guarantee. In particular, ListItem's existing action `gap-1` is 3.2px (`packages/ui/src/molecules/list-item/types.ts:219` and `packages/tokens/src/theme.css:440`), insufficient for two adjacent `lg` targets under this proposal. + +For the shared Recado two-line card, keep the trailing IconButton an independent action; reserve its full target in the row, separate from the text/link or row action. Never nest it in a whole-row anchor; ListItem's contract explicitly keeps actions out of that anchor (`packages/ui/src/molecules/list-item/types.ts:84-85`). With the proposed 44.8px target, a centered action needs at least 44.8px of unobstructed vertical space and row-to-row center separation, or equivalent non-interactive gap; a shorter row may retain its height only if the full target can extend into reserved, unclipped space without touching the next row's target. The atom itself does not increase row height. If the owner chooses a larger target, reserve that actual extent instead. This amendment neither changes ListItem nor decides #538's text contract. + +## 5. Accessibility + +- Preserve the same accessible name, role, hidden icon, descriptions, disabled semantics and keyboard/focus order; an invisible target adds no name, role, live region or focus stop. A tooltip remains a supplementary description (`packages/ui/src/atoms/tooltip/types.ts:5-17`). +- Focus-visible remains on the **visible button boundary**, not the larger invisible square: the existing `--shadow-focus` has priority over competing Material state shadows. The target cannot clip, mask or draw over that ring. This preserves the visual relationship between focus and the actual visible control rather than implying a larger painted button. +- The design-system objective is a contiguous, independently operable 44 × 44 CSS-pixel square for each enabled target, not merely visual size. [WCAG 2.2 SC 2.5.5 Target Size (Enhanced)](https://www.w3.org/TR/WCAG22/#target-size-enhanced) is AAA and specifies 44 × 44 CSS px with stated exceptions; [SC 2.5.8 Target Size (Minimum)](https://www.w3.org/TR/WCAG22/#target-size-minimum) is AA and specifies 24 × 24 CSS px or its specified spacing/other exceptions. The proposed 44px target is stronger than the AA minimum; neither a token value nor this draft alone establishes WCAG conformance. Test actual target geometry, adjacent targets, keyboard, focus and AT in context. +- Scope is an unobstructed, unscaled, supported host with tokens resolving to a sufficient size. Clipping, overlays, ancestor transforms and locally overridden spacing tokens can reduce the effective target; the consumer must avoid or correct them. Do not claim a universal 44px guarantee under arbitrary overrides. + +## 6. Appearance + +No intended visible change to any preset, `outline` roundness, glyph, resting/hover/active/disabled appearance, Material layers, border, shadow, focus ring or reduced-motion behavior. Preserve the approved v0.2 no-hover-motion rule and the existing v0.3 outline hover-border decision; do not move Material paint to the hit-area element or invent a new recipe. Focus stays on the visible root. Dynamic inline geometry: **not proposed**. + +**Tokens.** `packages/tokens/src/theme.css:460,595` provides `--space-14: 44.8px` and its `--spacing-14` utility alias; this already exceeds 44 CSS px, so no new token or dependency is proposed. The source explicitly allows local spacing overrides (`theme.css:565-567`), so a host overriding it below the required effective dimension must not be presented as satisfying the target. The `--space-16` fallback is 51.2px (`theme.css:462`), not an exact 44px token. Any future missing token or geometry exception needs separate confirmation; do not change token source or compiled artifacts in this amendment. + +**Files / styling role.** The existing six roles remain: `types.ts` API/CVA, `useIconButton.ts` derivation, `IconButton.tsx` JSX, `IconButton.test.tsx`, `IconButton.stories.tsx`, and `index.ts`. Prefer static token-backed utilities and **No stylesheet**; a meaningful stylesheet role, new internal module, changed class composition or dependency needs its own explicit spec/plan approval. Preserve legacy styles. Static utility scanning, actual built CSS and a packaged consumer without its own Tailwind compiler must be checked by the implementation plan. + +### Expected-design visual reference + +| ID | Image / scenario | Provenance and status | +| --- | --- | --- | +| VIS-01 | [Historical IconButton board](../../../design/foundation-boards/v2026-10-17/IconButton.png): ghost and outline rest/hover/disabled | Approved v0.1 expected design as recorded in `docs/components/icon-button/v0.1/implementation-evidence.md`; source capture v0.1, not a new v0.4 capture. Hash above. | +| VIS-02 | [Historical IconButton specimen](../../../design/foundation-boards/v2026-10-17/specimens/icon-button--specimen.png): sizes, treatments, focus and disabled | Same historical approval and limitation; hash above. Neither image proves the invisible region or current computed geometry. | +| VIS-03 | Pending: proposed compact two-line row with trailing `sm`/`md`/`lg` actions, including focus-visible and adjacent-target context | Source/version, image, viewport, DPR, browser/version, theme, fonts, motion/transparency, component crop, capture date/tool, hash and explicit v0.4 adoption all Pending. | + +**Visual conformity: Not evaluated.** No new capture or server was authorized for this draft. Exact next step: the owner selects an expected-design source and the principal/additional scenarios and capture conditions, authorizes read-only source/hosting and Playwright MCP access (including a server start if needed), then a real browser captures component-zone PNGs under `docs/components/icon-button/v0.4/` with `capture.json`, conditions and SHA-256 per the [visual guide](../../../design/README.md). Present captures as Proposed; separately obtain recoverable approval identifying the exact spec and image hashes. An observed current implementation is not automatically expected design, and a screenshot cannot prove hit testing. + +## 7. Acceptance criteria + +All methods below are **planned**, not observed. Browser tests must use real built styles and actual pointer hit testing; JSDOM class assertions or stories alone cannot measure targets. Assertions involving the proposed automatic/all-pointer policy are conditional on owner approval. + +| ID | Observable promise | Planned check / story | Evidence | +| --- | --- | --- | --- | +| AC-01 | All enabled `sm`, `md`, `lg` and four treatments expose an actual centered square of at least 44 × 44 CSS px, including square corners around `outline`, at rest and throughout active/release transitions. | Browser `elementFromPoint` grid and real pointer down/up in the outer corners of the centered 44px square, including motion-safe/reduced-motion and default token values; inspect computed pseudo geometry as supporting evidence, not `getBoundingClientRect()` of the visible root alone. Verify no duplicate click. | Pending | +| AC-02 | Native and supported slotted hosts keep their visible dimensions, border box, layout/flow positions, icon, public marker and ref; no wrapper or new focus stop. | Before/after browser root `getBoundingClientRect` and neighboring flow boxes at rest, comparable active-state baseline, plus DOM/ref/role and Slot regression tests across sizes. | Pending | +| AC-03 | The selected media policy works as approved, including fine/coarse primary and hybrid devices, without claiming event-specific detection from a media query. | Browser media emulation and `matchMedia`/real hit testing for fine-only, coarse-primary and fine-primary with coarse capability; verify all cases against the chosen policy. | Pending | +| AC-04 | Target extension does not intercept any neighboring interactive region when the documented spacing is provided; row text/link, adjacent actions and neighboring rows remain independently operable. | Browser hit tests and real clicks on both sides of reserved boundaries; two `sm`, two `md`, two `lg`, mixed sizes and compact two-line ListItem row with a trailing action, including clipping/overlay negative fixtures. Check consumer guidance and show an insufficient-gap example as unsupported, not as a passing guarantee. | Pending | +| AC-05 | Native and slotted disabled controls cannot activate or focus; no pseudo-element overrides disabled pointer suppression. Re-enabled controls recover. | Public native/slotted interaction tests plus browser pointer probes in the extension; verify root/child handlers and navigation are suppressed and document possible fall-through. | Pending | +| AC-06 | Name, role, hidden decorative icon, native keyboard, Slot attributes/ref and Tooltip description/trigger behavior remain unchanged. | Role/name and keyboard tests, real native/slotted link and Tooltip-trigger browser tests, plus AT follow-up; preserve existing cases and verify a single activation/description. | Pending | +| AC-07 | Root focus ring follows the visible boundary and remains legible; Material, geometry, hover/press/disabled paint and reduced motion remain unchanged. | Computed style/keyboard-focus comparison and approved comparable component-zone captures; VIS-01/02 are historical, VIS-03 is pending. Include tooltip and adjacent-row focus context. | Pending; visual conformity Not evaluated | +| AC-08 | Existing token use, CSS utility emission, docs and supported consumers reflect the chosen contract; no new token/dependency or accidental target shrink from supported theme conditions. | Static CVA/CSS scan, built stylesheet and packed React 18/19 consumer without a Tailwind compiler; inspect token overrides, docgen/Controls if a prop is approved, updated story/JSDoc and consumer spacing guidance. | Pending | + +### Resolved decisions + +1. **Enablement:** automatic, for every enabled IconButton, with no prop. Owner choice, verbatim: "Automática, sin prop (Recomendado)". No naming entry or exception is needed. The opt-in and opt-out alternatives are rejected. +2. **Pointer policy:** always, for every pointer type. Owner choice, verbatim: "Siempre, todos (Recomendado)". The coarse-pointer media-query alternatives are rejected. Audit existing dense consumers for overlap before adoption. +3. **Geometry and press feasibility:** remains an implementation-plan prerequisite. The plan must prove an effective target of at least 44px, using `--space-14`, throughout press and release, with no visible feedback change. Otherwise it stops for a revised proposal. No fallback, stylesheet or geometry exception is approved. +4. **Visual references:** the spec is approved without a VIS-03 capture. Appearance is promised to stay unchanged. VIS-03 stays pending, and conformity is Not evaluated until a capture is authorized and approved. + +### Planned checks and next step + +Resolve these choices, finalize the canonical digest and request explicit approval of this v0.4 snapshot. Only then propose a separate implementation plan, including a compatibility audit of compact consumers, Slot/Tooltip, clipping, press-scale transitions, actual browser hit testing and the AC matrix. This document authorizes no implementation, token/dependency or registry edits, or GitHub publication. diff --git a/docs/components/text/v0.3/truncate-amendment.md b/docs/components/text/v0.3/truncate-amendment.md new file mode 100644 index 00000000..98b421ae --- /dev/null +++ b/docs/components/text/v0.3/truncate-amendment.md @@ -0,0 +1,142 @@ +# Text v0.3 — single-line truncation amendment + +- **Version / status:** v0.3 — Approved 2026-11-22 (owner, in session; odd/tasks/consumer-request-specs.md L6). Implementation plan requires separate approval. +- **Amends:** the [approved Text and Heading v0.1 contract](https://github.com/egdev6/egdev-design-system/issues/108#issuecomment-6251575943) and [Text v0.2](../v0.2/body-tone-amendment.md). Except for the explicitly opt-in changes below, their promises remain unchanged. Request: [#538](https://github.com/egdev6/egdev-design-system/issues/538); context: [Recado #41](https://github.com/egdev6/recado/issues/41). +- **Approval / recovery:** Owner session 2026-11-22, recorded verbatim in this file's resolved decisions and in odd/tasks/consumer-request-specs.md; this spec is not an implementation authorization. A separate plan approval is required. No code, token, dependency, registry or GitHub change is authorized here. +- **Snapshot identity:** `version: v0.3`; `contentSHA256: fd8f0fdebc2bfd898a51cee69f94685cc64a9f877045f151fea609b202fcd799`; `visualHashes: Pending`; `approvalReference: owner session 2026-11-22 (odd/tasks/consumer-request-specs.md L6)`; `canonicalIssue: https://github.com/egdev6/egdev-design-system/issues/108`; `latestPublishedComment: Pending verification`. #538 is the request, not a replacement for the canonical component issue. +- **Hash definition:** SHA-256 of the UTF-8 payload from `## 1. Purpose and scope` through EOF, with LF line endings and the final newline. Tracking metadata above is excluded. Approval must identify this version, payload digest and any adopted visual hashes. + +## 1. Purpose and scope + +**Proposal:** add an opt-in, one-line ellipsis to passive `Text` wherever a consumer supplies a bounded inline size. Recado's compact card needs two independently truncated lines while keeping the full title and secondary text reachable. The host owns its card layout and full-text route. Multi-line clamping, automatic overflow detection, a new text component, automatic tooltips and modifications to `ListItem` are out of scope. + +**Cataloging:** reuse and extend the existing `@egdev/ui` Text primitive. Existing variants choose typography, not truncation; consumer `className` is not an appearance override, and a `ListItem`-only switch would not be reusable elsewhere. A new component or extraction would duplicate passive typography. Compose `Text` inside existing `ListItem` parts instead. This is a proposed contract expansion, not a new cataloging or implementation approval. + +**Evidence obtained, not validation of the proposal:** + +- The public barrel exports `Text`, `Heading`, `ListItem` and `Tooltip` (`packages/ui/src/index.ts:41`, `:67`, `:235-236`). `Text` renders a paragraph or Radix Slot; it has no public ref (`packages/ui/src/primitives/text/Text.tsx:9-20`). Its public props have `asChild`, not an `as` element selector (`packages/ui/src/primitives/text/types.ts:283-296`). +- Despite sharing `types.ts` and the barrel, `Heading` has a separate public type, hook and native h1–h6 renderer (`packages/ui/src/primitives/text/Heading.tsx:6-12`, `packages/ui/src/primitives/text/useHeading.ts:27-47`, `packages/ui/src/primitives/text/types.ts:304`). **Decision for this draft:** #538 requests `Text`, so `Heading` does not gain `truncate`; sharing a directory is not sufficient reason to change the heading contract. A real heading can contain a slotted, non-heading `Text` span as illustrated below. +- `ListItemContent` promises it is never *automatically* clamped or hidden (`packages/ui/src/molecules/list-item/ListItem.tsx:23-24`); its long-content story explicitly excludes ellipsis and tooltip (`packages/ui/src/molecules/list-item/ListItem.stories.tsx:354`). `ListItemTitle` is a native heading and `ListItemMeta` a div, not wrappers that render `Text` internally (`packages/ui/src/molecules/list-item/ListItem.tsx:30-32`, `:47-50`). +- The owner triage on [#538](https://github.com/egdev6/egdev-design-system/issues/538) selects an optional Text prop, with full text accessible and ListItem's default preserved. Its issue body describes a 440px Recado panel, two independent lines and an existing issue-backed TODO/allowlist mitigation. Keep that mitigation until the shipped change is verified in the consumer; this draft does not establish card-wide layout parity. + +## 2. Anatomy and composition + +| Part | Proposed responsibility / element | Content | +| --- | --- | --- | +| Text root | Existing `p`, or the one compatible non-heading element supplied with `asChild`; no new wrapper | Passive phrasing content, including native `strong`; the root is the clipping box only when opted in. | +| Existing decoration and accent | Existing eyebrow pseudo-element and optional trailing accent span | Decoration remains decorative. On opt-in, the accent joins the same visual line; its text remains in reading order. | +| Host full-text access | A separate, consumer-owned visible details link or disclosure outside the clipping box | It makes the complete value available visually to pointer, keyboard and touch users. No new Text control or focus stop. | + +Keep `eg-text`, `eg-text__accent` and the existing native/Slot semantics. Radix Slot is already used for `asChild`; no new Radix primitive, ref API or dependency is proposed. The consumer supplies valid HTML and keeps focusable elements outside the clipping box. An interactive ancestor, such as an existing whole-row link, may contain the passive Text if its own focus indicator is not clipped. + +### ListItem composition + +No `ListItem`, `ListItemTitle` or `ListItemMeta` prop needs to forward truncation: the consumer explicitly renders `Text` inside the appropriate part. In an editorial row, a `p` inside `ListItemTitle` would be invalid heading content, so use a slotted span. `self-stretch` is a permitted self-alignment, not an appearance override; it matters because the editorial Body is a column with `items-start`. The host must still bound the row's width. Example, with `note.href` resolving to a view that actually displays **both** complete values: + +```tsx + + + + + {note.title} + + + + + {note.project} + + + + +View full note +``` + +Alternatively, two ordinary `Text` paragraphs can be children of `ListItemContent` in a card/compact composition. The consumer chooses title emphasis and supplies full-text access; native `title` in the example is supplementary only. Current root, Body, Content, Title and Meta recipes have `min-w-0` at the locations shown in `packages/ui/src/molecules/list-item/types.ts:138-140`, `:185-203`, `:214`; other flex/grid ancestors still need inspection. The example's actual sizing and keyboard/touch route are **planned checks**, not observed results. ListItem's row recipe is allowed to wrap (`types.ts:140`); this amendment does not promise a single row or fixed card height at every width, nor does it modify the independent action or its hit area. Parent cross-checks the complete Recado card with the separate #540 proposal. + +## 3. Public API + +| Prop / input | Type and default | Proposed rule | +| --- | --- | --- | +| `Text.truncate` | New optional `boolean`; omitted or `false`: no truncation; `true`: opt in | Available on every existing Text variant; consume it in Text rather than forwarding it as a DOM/Slot attribute. Only the literal boolean `true` enables it at an untyped boundary. Proposed JSDoc: `@default false` and `@control boolean`. No new event or controlled state. | +| `variant`, `foreground`, `tone` | Existing types, restrictions and defaults | Orthogonal to truncation. Preserve the default `eyebrow`, all typography, allowed foreground/tone combinations and their token choices; no new variant or tone. | +| `accent`, `accentBreak` | Existing types; `accentBreak` defaults to `true` for display recipes | With `truncate=true` only, render an existing non-empty accent inline even when `accentBreak` is omitted or true; otherwise two lines would contradict the opt-in. Preserve its content, order, tone and glow recipe. `false` or omitted `truncate` restores the existing block/inline behavior. | +| `asChild`, native attributes including `title`, `lang`, `dir`, `id` | Existing types and defaults; no `as` prop | Default root remains `p`; one prop-spreading non-heading Slot child remains the actual element. With truncation it must be a passive, non-focusable, CSS-block-compatible element containing passive phrasing content. Existing consumer-supplied `title` passes through; Text never synthesizes or overwrites it. | + +The opt-in changes the clipping root's CSS display to `block`, including a slotted `span`. Its native tag and semantics do not change, but it no longer flows as an ordinary inline phrase. Consumers needing inline prose or a focusable Text root must not opt in; do not add a wrapper or silently change `asChild` when false. Explicit hard-break elements, nested block boxes and focusable descendants are unsupported within a truncating root; the component does not promise to inspect or reject arbitrary React children. Keep controls and their focus indicators outside the clipped root. An ancestor link may own interaction and its own focus ring. + +**Naming lookup:** checked meaning, canonical name and aliases for `truncate`, `clamp`, `lines`, `ellipsis`, `wrap` and `nowrap` in the [registry source](../../../../skills/_shared/prop-naming.json) and [generated reference](../../../prop-naming.md). No existing entry represents single-line text ellipsis. The nearby approved `accent-line-break` / `accentBreak` explicitly excludes truncation (`skills/_shared/prop-naming.json:6298-6302`); `control-label-wrap` / `labelWrap` explicitly excludes arbitrary children and truncation (`:8450-8454`); `section-content-wrap` / `wrap` means a section wrapper (`:8288-8292`). None is a match. + +**New convention proposal:** semantic ID `single-line-text-truncation`, canonical name `truncate`, meaning “opt in to visually eliding overflowing text to one line without removing its underlying content”; Text-specific usage `truncate?: boolean`, default `false`. Avoid multi-line clamp, data mutation and interactive-content clipping. Status `proposed`, `approval: null`; no aliases or scoped exception are proposed. Existing `slot-composition`, `visual-treatment`, `surface-material-tone` and `accent-line-break` continue to describe unchanged APIs, not the new concept. A spec approval does not itself approve a global convention. + +Reviewed current baseline: `{ path: 'packages/ui/src/primitives/text/types.ts', symbol: 'TextProps', revision: 'sha256:5ef0768327e1ad973783f0907b8a0f5f3a0b0975507bdc94499cda219f6a0b7e' }`. The symbol does **not** yet contain `truncate`; the baseline hash is not evidence of an implemented usage. A separately authorized implementation must review the resulting source and record its real revision in the registry; this draft changes neither registry nor generated view. + +**Compatibility:** omitted/false leaves existing Text behavior, defaults, markers, supported merges, accents, children and Slot/ref restrictions unchanged. Heading and ListItem APIs are unchanged. This is a TypeScript API addition only for Text; no migration is required for existing calls. `title` and other native attributes remain consumer-owned. React 18/19 compatibility and actual docgen/Controls are planned package checks, not inferred from types. + +## 4. Behavior + +| Input / condition | Proposed observable result | +| --- | --- | +| `truncate` omitted, false or an untyped non-boolean value | No truncation; consume the new prop without leaking it. Omitted/false preserves the existing rendering. No automatic clipping, title, tooltip, focus or extra DOM node. | +| `true`, passive phrasing content, finite constrained inline size, content overflows | One visual line; hide overflow and show the browser ellipsis at the inline end. Preserve the complete DOM text, including any accent and semantic `strong`, in original order. No character-count slicing or content mutation. | +| `true`, content fits | One line with no ellipsis. If the available width cannot fit the ellipsis glyph itself, the browser may clip it; no legibility is promised at zero or near-zero width. | +| Long unbroken text; RTL or mixed-direction text | No wrapping of the long token; native CSS ellipsis follows the resolved text direction (left edge for a simple RTL line). Preserve logical source and accessibility-tree order; do not reverse or manually insert characters. | +| `true` with a display accent / eyebrow | The accent is inline even for default/true `accentBreak`; the eyebrow remains a decorative diamond followed by text. Without truncation, existing block accent and `inline-flex` eyebrow behavior remain unchanged. | +| Nested focusable content, `
` or a block descendant in the clipping box | Unsupported for this opt-in; no focus, layout or single-line guarantee and no runtime tree-validation promise. Place controls outside or do not truncate. No interception of existing ancestor/other control interaction. | + +**Sizing ownership:** Text supplies `min-width: 0` on its own truncating root, but cannot change the min-content sizing of flex/grid ancestors. The consumer bounds the available inline size and sets `min-width: 0` (or the applicable logical equivalent) on **each flex/grid item in the shrinking path**, including wrappers where necessary; grid tracks must themselves permit shrinking. Setting it only on Text does not repair an unshrinkable ancestor. The owner of each ancestor supplies that layout; no measured-width observer or viewport breakpoint is added. Native keyboard behavior and state management are not applicable to passive Text. + +## 5. Accessibility + +**Selected proposal:** retain the full, unsliced children and accent in the DOM. Text itself adds no `aria-hidden`, automatically generated `aria-label` or duplicate announcement, and preserves consumer-authored child attributes. Screen readers can read the full meaningful text regardless of visual truncation; where it names a heading or an ancestor link, its full text remains available to that name, subject to the consumer not overriding or hiding it. A passive paragraph does not thereby acquire a new accessible name, role, tab stop or live region. Verify actual screen-reader reading order as well as DOM/accessibility-tree relationships; the latter alone is not assistive-technology proof. + +For visual access, the consumer must provide an always discoverable, visible, keyboard- and touch-operable route or disclosure outside the clipping box which exposes the **complete** text, including the secondary line when present. A pre-existing action can fulfill this only if it actually exposes both values and retains an accessible name and focus indicator. The host owns the route/disclosure, localization and focus behavior. Text itself neither adds an action nor makes itself focusable. Full text in an accessible name alone is not a visual-access solution. + +**Alternatives evaluated:** native `title` is already an inherited attribute, useful as supplementary pointer help but unreliable for keyboard and touch, so it cannot be the only route. The public DS `Tooltip` describes rather than names one focusable, ref-forwarding trigger (`packages/ui/src/atoms/tooltip/types.ts:5-17`); its own story explicitly says it is unavailable on touch and must not contain essential information (`packages/ui/src/atoms/tooltip/Tooltip.stories.tsx:18-20`; touch test at `Tooltip.test.tsx:151`). Passive Text has no public ref or focus stop. A tooltip is therefore optional supplementary content, not a substitute for the route or for the full accessibility-tree text. No automatic `title` is inferred from arbitrary React children or accents. + +## 6. Appearance + +| Axis | Opt-in proposal | Unchanged / limitation | +| --- | --- | --- | +| One-line geometry | Static CVA utilities equivalent to `block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap` on the Text root | Only while `truncate=true`; no fixed width. CSS ellipsis is a visual marker, not a substituted string. Layout needs a shrinkable host. | +| Eyebrow | Override its `inline-flex` root for a block formatting context; retain the existing token-sized rotated decorative diamond and token gap, using static pseudo-element utilities | The before pseudo-element must be inline-block and use logical end spacing equivalent to the existing gap. Centering and clipping are subject to the planned browser/visual check; do not claim current `inline-flex` itself can ellipsize the text. | +| Accent | Retain the existing accent span, tone and glow recipe; select inline layout only on opt-in | Root overflow may clip painted glow at its edge; evaluate it visually, do not promise an unclipped glow. Default block accent remains when not opted in. | +| Typography and foreground | Existing variant, semantic foreground and accent-tone token utilities | No new color, font, spacing, shadow or Material recipe; the host still owns its background and contrast. | + +Use static CVA choices in `types.ts`, composed through `useText` with `cn()`. No inline appearance, dynamic classes, new token or dependency. **No stylesheet** or extra internal module is proposed; the existing roles are `types.ts` (props/CVA), `useText.ts` (derivation), `Text.tsx` (JSX), `Text.test.tsx`, `Text.stories.tsx` and `index.ts` (exports). Shared Heading files and legacy CSS stay unchanged unless a separately approved plan identifies an unavoidable shared-file edit. + +Text's existing `className` remains outer layout only: margins, width constraints and flex/grid placement. Its existing tag is exactly `@classNameAllows width min-width max-width inline-size min-inline-size max-inline-size` (`packages/ui/src/primitives/text/types.ts:279-283`); no new property allowance is proposed. Base self-alignment and zero minimums are already allowed by the shared contract. Supported layout classes are merged last by `cn()` for recognized utility conflicts, while the prop owns overflow, whitespace, ellipsis and display; `className` is not permission to override those or typography/color. Slot child classes are also retained; conflicting child CSS and arbitrary selectors/cascade are not covered by `twMerge` or a universal last-class-wins promise. Test supported width/placement merges and non-conflicting Slot classes. + +### Expected-design visual reference + +| ID | Scenario / descriptive alt text | Source, conditions and status | +| --- | --- | --- | +| VIS-01 | Pending: two bounded single-line Text values in a compact ListItem, with the title visually stronger and an adjacent full-text route | Expected-design source/version, real image, viewport, device scale, browser/version, theme, loaded fonts, motion/transparency, component crop, capture date/tool, SHA-256 and human adoption all Pending. | +| VIS-02 | Pending: narrow LTR and RTL overflow, long unbroken text, eyebrow diamond and inline accent | Same source, conditions, provenance, hash and approval Pending. | + +No authorized capture or expected-design source was supplied; old Text v0.1/v0.2 captures are not approval for truncation. Visual conformity is **Not evaluated**. Exact next step: agree on the expected-design source, each scenario and capture conditions; obtain read-only source/hosting and real-browser permission (including separate server-start permission if needed); use Playwright MCP to capture each component zone, inspect the PNGs and record provenance, conditions and hashes in `docs/components/text/v0.3/capture.json`; then obtain recoverable human adoption of the exact images. Follow the [visual guide](../../../design/README.md). Do not implement merely to fabricate an expected reference, copy unrelated artifacts, or treat a capture as a behavior/accessibility test. + +## 7. Acceptance criteria + +All checks below are **planned**, not observed. Stories demonstrate scenarios; they do not replace behavior tests. Browser geometry, actual assistive technology and expected-design comparison are separate evidence. + +| ID | Observable promise | Planned test / method and story | Visual / observed evidence | +| --- | --- | --- | --- | +| AC-01 | `truncate` is optional boolean, defaults false, literal true opts in, false/omitted and untyped non-booleans do not; it never leaks to the native or slotted element. | Public DOM/rerender and positive/negative type tests, including untyped inputs; docgen and boolean Controls check. | Pending; visual not applicable to prop typing. | +| AC-02 | Bounded passive text fits or renders a single ellipsized line without slicing children; long unbroken text, LTR, RTL, mixed direction and insufficient-marker width follow the specified limits. | Browser computed-style, geometry and rendered-pixel inspection with full DOM text assertions; bounded, unbounded, fits, overflow and direction stories. JSDOM alone cannot prove ellipsis. | VIS-01/02 Pending. | +| AC-03 | Every Text variant can opt in; default eyebrow diamond, title accent, inline override of `accentBreak`, tone/glow and body/foreground combinations follow the delta, including toggle back to false. | Public DOM tests and browser computed-style checks per variant/representative tones, accents, `strong` and state toggling; Eyebrow and Accent stories. | VIS-02 Pending, including diamond centering and glow-edge review. | +| AC-04 | `p` and a non-heading slotted `span` keep their native tags, attributes, marker, order and child ref while opted-in display is block; no new wrapper or automatic `title`. Existing supplied `title` and non-conflicting child classes survive. | Public native/Slot DOM and ref tests plus browser display check; AsChild story. | VIS-01/02 Pending. | +| AC-05 | Root `min-width: 0` and bounded, shrinkable flex/grid ancestry allow ellipsis; an unshrinkable ancestor or unbounded host is explicitly the consumer's responsibility. | Browser flex and grid cases with/without ancestor min-width zero and a shrinkable track, plus supported width/placement merge tests; FlexGrid story. | VIS-02 Pending. | +| AC-06 | Full children and accent remain exposed to assistive technology and native heading/ancestor-link naming where applicable, without generated role, focus stop, label, live region or duplicate announcement. | Accessibility-tree/role/name and native-attribute tests, plus actual screen-reader reading-order check; heading/link composition story. | AT result Pending; visual not a substitute. | +| AC-07 | A host-provided visible details route exposes both complete card values and is operable by keyboard, pointer and touch; focus indicators and controls are outside clipping. Native title/Tooltip alone is not relied on. | Consumer integration story and real-browser keyboard, pointer and touch checks; destination/disclosure text and focus assertions. | VIS-01 Pending; consumer integration not yet observed. | +| AC-08 | ListItem default content remains unclamped; opt-in nested Text works in Content and in the editorial Title/Meta spans, with correct native heading, sizing and full text; no part receives a new prop. | Public ListItem preservation and composition tests; real-browser flex sizing and narrow row story; type/API checks for unchanged parts. | VIS-01 Pending. | +| AC-09 | With the option absent/false, existing Text defaults, recipes, whitespace, tone, accentBreak, Slot, native attributes and layout merge remain; Heading's separate behavior/API remains unchanged. | Existing focused Text and Heading suites plus explicit default/false preservation and Heading negative type case; existing stories. | Existing behavior is source evidence only; planned regression results Pending. | +| AC-10 | Static utilities are emitted in actual shipped CSS and the feature works for packed React 18/19 consumers without a Tailwind compiler. This draft changes no token, dependency, registry or legacy CSS; separately approved registry work is required for implementation. | Built-CSS/static-scan and packed-consumer tests, source/diff audit; verify separately approved registry work when authorized. | Pending; visual not applicable to packaging. | +| AC-11 | The usage documentation excludes hard breaks, block boxes and focusable descendants inside a truncating root; Text does not gain a tree-validation or interaction engine. Independent ancestor/sibling controls remain operable. | Documentation/source review and public DOM/keyboard tests for unchanged ancestor/sibling control behavior; unsupported child combinations are not represented as supported test cases. | Pending; visual not applicable to the unsupported-content policy. | + +### Resolved decisions and next steps + +1. **Spec:** approved as drafted. Owner choice, verbatim: "Aprobar tal cual (Recomendado)". Text-only `truncate` on every variant, block display on opt-in, inline accent and eyebrow while truncating. Widening to `Heading` would need a separate scoped decision. +2. **Full-text access policy:** approved as drafted. The visible route or disclosure is owned by the consumer; native `title` and the DS Tooltip are supplementary only. For Recado's card, confirm during implementation that tapping the card opens the full-text detail without hiding the trailing action's focus or touch target. +3. **Naming convention:** owner choice, verbatim: "Aprobar `truncate` (Recomendado)". `single-line-text-truncation` / `truncate` is approved for registration with the first reviewed usage, during separately authorized implementation. This draft does not edit the registry. +4. **Visual references:** the spec is approved without captures. VIS-01/02 remain pending, and visual conformity is Not evaluated until expected-design sources and captures are supplied and approved. +5. **Next step:** propose a separate implementation plan, which needs its own approval. All acceptance checks and real package, browser and assistive-technology evidence remain pending. diff --git a/odd/tasks/consumer-request-specs.md b/odd/tasks/consumer-request-specs.md new file mode 100644 index 00000000..58b8d03b --- /dev/null +++ b/odd/tasks/consumer-request-specs.md @@ -0,0 +1,27 @@ +# Specs for accepted consumer requests #538 and #540 + +Spec amendments (no code) for two capabilities Recado's compact note card needs, designed together: an opt-in single-line truncation on `Text` (#538) and an extended invisible hit area on `IconButton` (#540). Approval of each amendment is separate from any implementation plan. + +## Specs + +- S1: Owner request, verbatim: "93 merged, ponte con la specs". +- S2 (#538, owner triage decision verbatim): "Prop opcional en Text (Recomendado)" ("Reutilizable en cualquier sitio (ListItem incluido); opt-in, el texto completo queda accesible (title/tooltip). ListItem mantiene su promesa por defecto."). +- S3 (#540, owner triage decision verbatim): "Área invisible extendida (Recomendado)" ("El botón se ve igual pero su zona de toque llega a ≥44px; corrige también el incumplimiento actual de lg sin cambiar el aspecto. Requiere revisar Material y el anillo de foco."). +- S4: Follow skills/component-spec-proposer (seven blocks, prop-naming registry lookup with recorded entry IDs or new proposals, separate proposal/evidence/planned checks, no invented defaults or approval, English), the repo's amendment pattern (`docs/components//v/-amendment.md`), and the shared component contract. Do not implement, change tokens or dependencies, edit the registry, or publish on GitHub. + +## Tasks + +| ID | Specs | Route | Commit | +| --- | --- | --- | --- | +| T1 | S2, S4 | worker | drafted: docs/components/text/v0.3/truncate-amendment.md (this commit) | +| T2 | S3, S4 | worker | drafted: docs/components/icon-button/v0.4/hit-area-amendment.md (this commit) | +| T3 | S2, S3 | parent | done: both amendments approved (this commit) | + +## Log + +- L1 (owner, verbatim): S1, after merging egdev6/nexo#93. +- L2: Triage decisions recorded on #538 and #540 (S2, S3); both come from the same Recado compact note card (recado#41). +- L3: T1 drafted: `Text.truncate?: boolean` (default false) on every variant; opt-in makes the root block-level and inlines accents; full DOM text kept for assistive technology; the consumer owns a visible, keyboard- and touch-operable route to the full text (native `title` and Tooltip are supplementary only); consumer owns `min-width: 0` along the shrinking path; Heading and ListItem unchanged; new naming concept `single-line-text-truncation` proposed, not registered. +- L4: T2 drafted: recommends an automatic invisible hit area (no prop) on every enabled IconButton and every pointer type, a 44.8px square from `--space-14` via a static `::after`; focus ring stays on the visible button; overlap and row-spacing rules for consumers; the active `scale-94` press feedback must be proven not to shrink the effective target below 44px in the implementation plan, else stop for a revised proposal. Alternatives: opt-in `extendHitArea` (new naming concept) or coarse-pointer media queries. +- L5: Parent cross-check against the Recado card: compatible (one trailing action per row; tapping the card opens the full-text detail, which can satisfy the Text access route). +- L6 (owner choices, verbatim): Text v0.3 "Aprobar tal cual (Recomendado)"; naming "Aprobar `truncate` (Recomendado)" (`single-line-text-truncation` registered with the first reviewed usage at implementation); IconButton enablement "Automática, sin prop (Recomendado)"; pointer policy "Siempre, todos (Recomendado)". Recorded in each amendment's resolved decisions; snapshots finalized: Text v0.3 contentSHA256 fd8f0fdebc2bfd898a51cee69f94685cc64a9f877045f151fea609b202fcd799, IconButton v0.4 contentSHA256 9b79473b96a8ac9a657bcad82604c770a2fafa4228067b79e7d08567c0c116df. Both approved without new captures (visual conformity Not evaluated). IconButton press-scale feasibility stays an implementation-plan prerequisite. Next: separate implementation plans, each needing approval.