Skip to content

v2 public-props API review (#342): naming consistency pass#362

Merged
CarlosNZ merged 9 commits into
v2.0-devfrom
342-public-props-api-review
Jun 15, 2026
Merged

v2 public-props API review (#342): naming consistency pass#362
CarlosNZ merged 9 commits into
v2.0-devfrom
342-public-props-api-review

Conversation

@CarlosNZ

Copy link
Copy Markdown
Owner

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

# Change Notes
1 allowClipboardshowClipboardButton It's a display toggle, not a capability gate (can't prevent copying) — moved into the show* family
2 onChangeno change Kept the name + compulsory => ValueData return (already enforced at compile time); rename withdrawn
3 'when-closed''when-collapsed' showCollectionCount literals — unifies vocabulary on "collapse"
5 CustomSelectSelect (CustomSelectPropsSelectProps) Bare PascalCase, off the custom* config-family prefix
7 updateSuccessfulupdateSuccess Noun/noun parallel with updateError; keeps the pervasive "error" vocabulary
9 Removed the custom-component error-reporter prop Components reject invalid input by throwing from fromStandardType — kills the onError name clash entirely (no in-repo callers)
10 CustomNodeDefinition's U generic now binds wrapperProps Genuine type bug fix (was Record<string, unknown>); compile-time regression guard added
11 setIsEditingKeystartEditingKey It's a zero-arg command, not a React Dispatch — the setIs* name misled
12 handleKeyPressonKeyDown Off React's deprecated "keyPress" name; both public props (CustomComponentProps + AutogrowTextArea)
13 Dropped redundant data from CustomComponentProps Use value (live) / nodeData.value (committed); data duplicated the latter and was typed unknown
README ↔ types drift (a–e) Fixed DefaultValueFunction, TypeOptions, the insertAtTop type-cell typo + a stray table cell, the moved link component, and the stale onEditEvent row

Kept (won't-fix), with rationale

  • More sophisticated theming #4 collapse prop — collision with editorRef.collapse() is cross-namespace (low confusion), and every natural replacement (defaultCollapse/initialCollapse) would mislead: React's default*/initial* convention means "uncontrolled, set-once", but this prop is reactive.
  • Localisation #6 allowTypeSelection — not the lone outlier it looks: it's interaction-named like allowDrag. Renaming only it would be a half-measure, and "Selection" is accurate (it takes TypeOptions).
  • Better icons #8 bare delete/move in EditEvent — the bare name signals an atomic single-event op; commit* would imply a start*/submit* lifecycle that doesn't exist for instant ops. (Already documented in the type + README.)
  • Performance improvements #14 EnumDefinition.enum — it's a self-documenting type-tag inside allowTypeSelection arrays (among bare type strings); name would read as a generic object and lose that signal.
  • (f) arrayIndexStart 0 | 1 — deliberately documented narrower than its number type.

Notes

  • Most renames are breaking. The ones a v1 consumer must act on are in the migration guide (§6 clipboard split, §11 custom-node fields incl. the error-reporter removal / 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/components typecheck are green on every commit.

🤖 Generated with Claude Code

CarlosNZ and others added 9 commits June 15, 2026 22:45
…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>
@github-actions

Copy link
Copy Markdown

Bundle size impact

json-edit-react

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.

@CarlosNZ CarlosNZ linked an issue Jun 15, 2026 that may be closed by this pull request
@CarlosNZ CarlosNZ merged commit ece6d70 into v2.0-dev Jun 15, 2026
2 checks passed
@CarlosNZ CarlosNZ deleted the 342-public-props-api-review branch June 15, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2 public props API review: naming inconsistencies and confusions

1 participant