From 311652169bc48448ed16ff5a58b010121f401e6e Mon Sep 17 00:00:00 2001 From: itsprade Date: Tue, 10 Nov 2026 19:46:32 +0530 Subject: [PATCH] feat(editable-card): edit a record card in place Add EditableCard and EditableCard.Field. View and edit are one card with one field list: each field renders the same cell in both modes (a fixed label row and a value slot the height of a control), so pressing Edit moves nothing and only swaps values for controls. Fields that can't be edited keep their view rendering and, in edit mode, show an icon whose tooltip gives the reason, by kind: system, calculated, locked or permission. Save submits only this card; an async onSave keeps the card in edit mode until it resolves and stays there if it rejects. Labels are translated into English and Japanese. The form templates page gets three in-place examples: a purchase order header with every read-only kind, a table of the kinds, and two cards where only one can be edited at a time. Refs tailor-inc/platform-planning#2265 Co-Authored-By: Claude Opus 5.5 # Conflicts: # docs-manifest.json --- .changeset/editable-card-in-place.md | 18 + docs-manifest.json | 30 +- .../editable-card.docs.examples.tsx | 87 ++++ .../components/editable-card.docs.outline.md | 105 ++++ .../components/form-layout.docs.outline.md | 15 +- docs-src/skill/SKILL.template.md | 1 + docs/components/editable-card.md | 170 ++++++ docs/components/form-layout.md | 15 +- .../form-templates/complex-examples.tsx | 2 + .../form-templates/in-place-examples.tsx | 484 ++++++++++++++++++ .../showcase/form-templates/overview.tsx | 1 + ...editable-card__editable-card.test.tsx.snap | 5 + .../editable-card/editable-card.test-d.tsx | 60 +++ .../editable-card/editable-card.test.tsx | 423 +++++++++++++++ .../editable-card/editable-card.tsx | 411 +++++++++++++++ .../core/src/components/editable-card/i18n.ts | 18 + .../src/components/editable-card/index.ts | 3 + .../src/components/editable-card/types.ts | 120 +++++ packages/core/src/index.ts | 5 + 19 files changed, 1953 insertions(+), 20 deletions(-) create mode 100644 .changeset/editable-card-in-place.md create mode 100644 docs-src/components/editable-card.docs.examples.tsx create mode 100644 docs-src/components/editable-card.docs.outline.md create mode 100644 docs/components/editable-card.md create mode 100644 examples/vite-app/src/pages/showcase/form-templates/in-place-examples.tsx create mode 100644 packages/core/__snapshots__/src__components__editable-card__editable-card.test.tsx.snap create mode 100644 packages/core/src/components/editable-card/editable-card.test-d.tsx create mode 100644 packages/core/src/components/editable-card/editable-card.test.tsx create mode 100644 packages/core/src/components/editable-card/editable-card.tsx create mode 100644 packages/core/src/components/editable-card/i18n.ts create mode 100644 packages/core/src/components/editable-card/index.ts create mode 100644 packages/core/src/components/editable-card/types.ts diff --git a/.changeset/editable-card-in-place.md b/.changeset/editable-card-in-place.md new file mode 100644 index 000000000..482e0345c --- /dev/null +++ b/.changeset/editable-card-in-place.md @@ -0,0 +1,18 @@ +--- +"@tailor-platform/app-shell": minor +--- + +Add `EditableCard` for editing part of a record in place. View and edit are one card with one field list, so every field keeps its exact position when Edit is pressed and only its value turns into a control. Fields the user can't change keep their view rendering and show a hint icon whose tooltip gives the reason (`readOnly={{ kind: "system" | "calculated" | "locked" | "permission", reason }}`); an empty value shows a dash. Save submits only that card, after the fields pass validation; an async `onSave` keeps the card in edit mode until it resolves, and a rejected or throwing `onSave` keeps it there with the user's changes. Pass server errors back through `errors` to show them under their fields. Type the saved values with a type argument (`>`). Edit moves focus to the first control; Cancel or Escape (which also calls `onCancel`) and a successful save return it to Edit. + +```tsx + title="Order details" errors={errors} onSave={saveOrder}> + Confirmed} + readOnly={{ reason: "Changes as the order moves through approval." }} + /> + + + + + + + + setTerms(value ?? PO_HEADER.paymentTerms)} + /> + + + + {/* Row 3 */} + +