feat(input): Input primitive (shadcn v4) + gallery showcase#51
Merged
Conversation
…semantics, perf+test guards (review)
…horitative Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Input — the form-cluster keystone (4th primitive)
Ships
Inputatapps/gallery/lib/components/ui/input.dart— a Material-free, themeable, shadcn-v4-faithful single-line text field, the repo's first text input. shadcn'sInputis a styled<input>; the Flutter-faithful equivalent is a styledEditableText(thewidgets.darttext primitive —TextFieldis Material and off-limits) wrapped in one.twbox, with a managed controller/focusNode, a placeholder overlay, a focus ring, and invalid/disabled states.shadcn v4 class mapping
Base
<input>:h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base outline-none placeholder:text-muted-foreground disabled:opacity-50 disabled:pointer-events-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 …h-9 w-full rounded-md border-input bg-transparent px-3.tw.bg(transparent).border(1,color:input).roundedMd.px(3).py(2).minH(9).wFulltext-base placeholder:text-muted-foregroundEditableText@FwFontSize.base.px(16);Textoverlay inmutedForegroundwhen emptyfocus-visible:border-ring ring-[3px] ring-ring/50ring+.ring(3, color: ring @0.5)aria-invalid:border-destructive ring-destructive/20invalid⇒ borderdestructive(+destructive @0.2ring when focused)disabled:opacity-50 pointer-events-none.opacity(0.5)+IgnorePointer+ExcludeFocus+EditableText.readOnlyDesign decisions
variant/sizeenums (shadcn's Input has neither). State is boolean props:enabled,invalid.w-full) — requires a bounded-width parent (documented), like Card.ExcludeFocusremoves it from keyboard traversal (not justIgnorePointer, which blocks pointer only) without mutating a caller-owned focusNode;assert(!autofocus || enabled)guards the misuse.MergeSemantics+Semantics(label:)collapses the field's name + value + text-field role into one node, so a screen reader announces "name, edit text, value" (deliberately notexcludeSemantics— unlike Button/Badge, an input's value must announce alongside its name; covered by a test asserting both the label and the value are reachable).Faithful deviations (documented, not bugs)
shadow-xs,md:text-sm, anddark:bg-input/30are dropped (an input's depth is its border+ring; 16px is the mobile-first default; the dark fill needs a brightness-only token knob we don't have — same precedent as Badge's droppeddark:bg-destructive/60). Selected text keeps itsforegroundcolor. Not yet built (feasible, §11b): a custom selection toolbar/handles (TextSelectionControls) and a multi-lineTextareasibling — v1 ships keyboard + basic selection.Tests
IgnorePointer+ opacity) and non-focusable (ExcludeFocus); obscure; onChanged/onSubmitted; semantics (name + value both reachable); managed-controller lifecycle (self-managed + external swap, asserting the external survives); RTL; dark reskin.EditableText.debugDeterministicCursorfor a stable caret.apps/gallery(Inputs section) + smoke-tested. Charter §8 progress note (no-drift).Executed via writing-plans → subagent-driven-development (implementer + spec-review + code-quality-review; review findings triaged and applied —
ExcludeFocus,MergeSemantics,autofocusassert, lifecycle/value test guards, per-keystrokesetStateguard).🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com