v2 public-props API review (#342): naming consistency pass#362
Merged
Conversation
…ic fix Two items from the v2 public-props review (#342): #1 — Rename `allowClipboard` → `showClipboardButton`. It's a display toggle, not a capability gate (hiding the copy button can't prevent copying — the value is selectable in the DOM), so it joins the `show*` family rather than the `allow*` gates. Threaded through core, the demo, README, and the migration guide (the v1 story is now `enableClipboard` → `showClipboardButton` + `onCopy`); changeset added. #10 — `CustomNodeDefinition`'s `U` generic now binds `wrapperProps` (was `Record<string, unknown>`), so a `wrapperComponent` and its `wrapperProps` are kept consistent — mirroring how `componentProps?: T` already binds the value-component generic. Added a compile-time regression guard (ts-jest fails on an unused `@ts-expect-error`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- `defaultValue`: `DefaultValueFilterFunction` → `DefaultValueFunction` (the type that actually exists) - `allowTypeSelection`: type column `DataType[]` → `TypeOptions` (it also admits custom-type strings and `EnumDefinition`, as the row's own text says) - `insertAtTop`: fix the malformed type cell (`boolean|"object"|"array"`) and a stray trailing table cell - `customNodeDefinitions`: the link component now ships in `@json-edit-react/components`, not the main package - `onEditEvent`: describe the full v2 lifecycle (start/submit/commit/cancel, delete/move, updateSuccess/updateError) instead of "starts or stops editing" `arrayIndexStart`'s documented `0 | 1` is left as-is — deliberately narrower than its `number` type. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 55.70 KB | 55.68 KB | 🟢 -14 B (-0.02%) | 20.00 KB | 19.98 KB | 🟢 -22 B (-0.11%) |
| cjs | 57.20 KB | 57.19 KB | 🟢 -14 B (-0.02%) | 20.09 KB | 20.07 KB | 🟢 -22 B (-0.11%) |
@json-edit-react/components
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 13.75 KB | 13.74 KB | 🟢 -10 B (-0.07%) | 4.67 KB | 4.67 KB | 🟢 -3 B (-0.06%) |
| cjs | 14.45 KB | 14.44 KB | 🟢 -10 B (-0.07%) | 4.54 KB | 4.53 KB | 🟢 -8 B (-0.17%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
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.
Works through the #342 public-props review. Since v2 is unreleased, these are done now. Each item was decided on its merits — some renamed, several deliberately kept where the "inconsistency" turned out to be load-bearing.
Changed
allowClipboard→showClipboardButtonshow*familyonChange— no change=> ValueDatareturn (already enforced at compile time); rename withdrawn'when-closed'→'when-collapsed'showCollectionCountliterals — unifies vocabulary on "collapse"CustomSelect→Select(CustomSelectProps→SelectProps)custom*config-family prefixupdateSuccessful→updateSuccessupdateError; keeps the pervasive "error" vocabularythrowing fromfromStandardType— kills theonErrorname clash entirely (no in-repo callers)CustomNodeDefinition'sUgeneric now bindswrapperPropsRecord<string, unknown>); compile-time regression guard addedsetIsEditingKey→startEditingKeyDispatch— thesetIs*name misledhandleKeyPress→onKeyDownCustomComponentProps+AutogrowTextArea)datafromCustomComponentPropsvalue(live) /nodeData.value(committed);dataduplicated the latter and was typedunknownDefaultValueFunction,TypeOptions, theinsertAtToptype-cell typo + a stray table cell, the moved link component, and the staleonEditEventrowKept (won't-fix), with rationale
collapseprop — collision witheditorRef.collapse()is cross-namespace (low confusion), and every natural replacement (defaultCollapse/initialCollapse) would mislead: React'sdefault*/initial*convention means "uncontrolled, set-once", but this prop is reactive.allowTypeSelection— not the lone outlier it looks: it's interaction-named likeallowDrag. Renaming only it would be a half-measure, and "Selection" is accurate (it takesTypeOptions).delete/moveinEditEvent— the bare name signals an atomic single-event op;commit*would imply astart*/submit*lifecycle that doesn't exist for instant ops. (Already documented in the type + README.)EnumDefinition.enum— it's a self-documenting type-tag insideallowTypeSelectionarrays (among bare type strings);namewould read as a generic object and lose that signal.arrayIndexStart0 | 1— deliberately documented narrower than itsnumbertype.Notes
startEditingKey/onKeyDown/value); the v2-dev-only renames update their existing changesets in place. Changesets are included/updated throughout.tsc, lint, the full test suite (488 passing), and the@json-edit-react/componentstypecheck are green on every commit.🤖 Generated with Claude Code