From 78d226d2a290d93ffa413dd2f4b672f88f11b962 Mon Sep 17 00:00:00 2001 From: phranck Date: Mon, 9 Feb 2026 21:22:15 +0100 Subject: [PATCH] Docs: Finalize TextField plan and update status files --- .../2026-02-09-textfield-component.md | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) rename plans/{open => done}/2026-02-09-textfield-component.md (91%) diff --git a/plans/open/2026-02-09-textfield-component.md b/plans/done/2026-02-09-textfield-component.md similarity index 91% rename from plans/open/2026-02-09-textfield-component.md rename to plans/done/2026-02-09-textfield-component.md index 76266fe..718f061 100644 --- a/plans/open/2026-02-09-textfield-component.md +++ b/plans/done/2026-02-09-textfield-component.md @@ -4,6 +4,41 @@ This plan implements TextField, an essential text input component for TUIKit. TextField provides an editable single-line text interface with cursor navigation, text editing, and SwiftUI-conformant API. Users can type, delete, and navigate within the field using standard keyboard controls. The component supports placeholder text (prompt), focus states with visual feedback, and the `.onSubmit()` modifier for form submission. This is a fundamental building block for forms, search fields, and any user text input. +## Completed + +**2026-02-09** - TextField v1 complete with 37 tests. Core functionality implemented: text editing, cursor navigation, focus integration, prompt/placeholder, onSubmit, disabled state, ViewBuilder label init, and Example app demo page. TextFieldStyle deferred to future enhancement. + +## Checklist + +### Phase 1: Core TextField +- [x] Create TextFieldHandler class +- [x] Create TextField struct with body: some View +- [x] Implement _TextFieldCore with Renderable +- [x] Render text content with cursor +- [x] Handle character input +- [x] Handle backspace/delete +- [x] Handle cursor movement (left/right) +- [x] Handle home/end keys +- [x] Add focus indicator (pulsing vertical bars) +- [x] State persistence for cursor position + +### Phase 2: SwiftUI API Parity +- [x] init(_:text:) - basic initializer +- [x] init(_:text:prompt:) - with placeholder +- [x] init(text:prompt:label:) - ViewBuilder label +- [x] Render prompt when empty and unfocused + +### Phase 3: Modifiers & Polish +- [x] .onSubmit() modifier support +- [x] .disabled() support +- [x] Width/frame support (uses availableWidth from context) +- [ ] .textFieldStyle(_:) modifier (deferred) + +### Phase 4: Testing & Demo +- [x] TextFieldHandler key event tests (21 tests) +- [x] TextField rendering tests (16 tests) +- [x] Example app demo page (TextFieldPage.swift) + ## Context / Problem TUIKit currently has no way for users to enter text. All existing controls (Button, Toggle, Menu, List) are selection-based, not input-based. TextField is essential for: @@ -203,43 +238,6 @@ TextField("Search", text: $query) 3. Focus integration tests 4. Example app integration -## Checklist - -### Phase 1: Core TextField -- [x] Create TextFieldHandler class -- [x] Create TextField struct with body: some View -- [x] Implement _TextFieldCore with Renderable -- [x] Render text content with cursor -- [x] Handle character input -- [x] Handle backspace/delete -- [x] Handle cursor movement (left/right) -- [x] Handle home/end keys -- [x] Add focus indicator (pulsing brackets) -- [x] State persistence for cursor position - -### Phase 2: SwiftUI API Parity -- [x] init(_:text:) - basic initializer -- [x] init(_:text:prompt:) - with placeholder -- [ ] init(text:prompt:label:) - ViewBuilder label -- [x] Render prompt when empty and unfocused - -### Phase 3: Modifiers & Polish -- [x] .onSubmit() modifier support -- [ ] .textFieldStyle(_:) modifier -- [ ] TextFieldStyle protocol -- [ ] PlainTextFieldStyle -- [ ] RoundedBorderTextFieldStyle (default for TUI) -- [x] .disabled() support -- [ ] Width/frame support - -### Phase 4: Testing -- [x] TextFieldHandler key event tests (27 tests) -- [x] TextField rendering tests (9 tests) -- [ ] Focus integration tests -- [ ] Prompt/placeholder tests -- [ ] Style tests -- [ ] Example app demo page - ## Open Questions 1. **Cursor representation**: Block (`█`), underscore (`_`), or pipe (`|`)?