feat: card list editing, opt-in per field - #1
Open
timBm10c wants to merge 7 commits into
Open
Conversation
`import { FieldText } from '@m10c/mui-kit'` cannot resolve against
0.0.1, which exports only subpaths, so `yarn ts` and the dts build fail
on a fresh checkout. `^0.0.1` pins that version exactly, being a 0.0.x
range.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A list field could only edit the items its data already held, with every item's fields listed one after another. Designs for the DCG page editor call for a card per item, added and deleted by the admin, so `variant: 'cards'` renders each item as a summary card with a dialog to edit it, capped by `maxItems` and reordered by dragging. Lists left on the default `inline` render as they always have. Cards need to show a saved value rather than an input, which the package cannot always do: an icon field holds a slug, not a picture. `previews` lets the consumer draw those values, alongside `icons` for the drag and edit affordances, so an app can use its own icon set. Fields carry the extras the designs ask of the schema: `required` marks a label, `hideLabel` drops a heading a block's list already provides, `headerFieldKeys` pulls a sibling field under the list's heading, and `variables` lists the placeholders an admin may type. The preview's device names are overridable too, for sites that call them something else. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three follow-ons from fitting the editor to the DCG designs: A list whose `minItems` equals its `maxItems` cannot grow or shrink, so it drops the heading, the Add button and the count that only make sense where an admin chooses how many items there are. The SEO tab takes `renderers` the way the block editor does, so an app whose inputs look nothing like these can draw its own without the two tabs disagreeing. A renderer is handed the field's `features`, which the schema already carried but nothing passed on: one rich text field offers lists and links where another offers bold. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`react` and `react-dom` are already on 19 here while their types were pinned to 18. The mismatch is invisible to `yarn ts` but surfaces in a consumer that links this package during development: two copies of `@types/react` disagree, and the app's own components fail to check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The DCG designs ask more of a field than text: an image with the dimensions it should have, a radio group for a review's app store, a gallery of feature images, a currency prefix on an amount, and a card that names a part of the page an admin cannot edit at all. Uploading is the consuming app's, so `image` and `images` pass through to a renderer, `images` carrying the values it holds alongside the single value the other kinds use. `choice` and `note` need nothing an app owns, so they draw themselves. The preview renders the site at the device's real width and scrolls to what does not fit, rather than scaling the page down to the pane. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A page that names no image of its own is still shared with one: the site's default. The preview drew an empty grey block instead, so it disagreed with what a post would look like. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The chip was a rounded square the favicon filled edge to edge, so the icon's own corners sat outside it. Search engines draw the favicon inset inside a circle, so the chip is one too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
A card-based editor for list fields, for the DCG page editor designs. Everything here is opt-in, so Balance renders exactly as it does today.
Ported from markm10c/m10c-content-elements#1, adapted to this repo's flat
src/layout and the@m10c/mui-kitroot import.Schema
ListField.variant: 'cards'— each item becomes a summary card with a dialog to edit it: Add capped bymaxItems, delete down tominItems, and drag to reorder.inline(the default) is unchanged.ListField.headerFieldKeys— sibling fields of the block rendered under the list's heading, e.g. a subtitle that sits above the cards.ListField.variables— placeholders an admin can type, listed at the top of the item dialog.SimpleField.required/ListField.required— marks the label with an asterisk.BlockType.hideLabel— drops the block heading where its list already provides one.Props
previews— draws a field's saved value on a card. The package can't do this itself: an icon field holds a slug, not a picture.icons— swaps the drag and edit affordances for the app's own icon set.deviceLabels— renames the preview's device sizes, e.g. "Mobile website".Notes
@dnd-kit/sortablev10 and dcg-admin on v7, so a peer dependency would force one of them to move.ListCardIconsis exported from the barrel, so a consumer can type theiconsprop it passes.@m10c/mui-kitto 0.0.2.^0.0.1pinned that version exactly, and 0.0.1 has no root export, soyarn tsand the dts build fail onmainas it stands.