Definition factories: guard-preserving customization of pre-built components (#350)#354
Merged
Conversation
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 12.66 KB | 13.22 KB | 🔺 +572 B (+4.41%) | 4.26 KB | 4.49 KB | 🔺 +242 B (+5.55%) |
| cjs | 13.30 KB | 13.91 KB | 🔺 +626 B (+4.60%) | 4.14 KB | 4.36 KB | 🔺 +228 B (+5.38%) |
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.
Implements the core of #350: the pre-built custom-node definitions in
@json-edit-react/componentsare now exported as definition factories rather than plain objects, so customizing them can no longer silently drop the built-in safety condition.What changed
createDefinitionFactory(package-private,_common/): takes a plainCustomNodeDefinitionbase — itsconditioninterpreted as the guard — and returns the consumer-facing factory. Consumerconditionoverrides are targeting, ANDed with the guard; the explicitguardkey replaces the guard;componentPropsshallow-merges; everything else is override-wins. The base objects keep their names/shape but are no longer exported — the factory is the only door.hyperlinkDefinition(),enhancedLinkDefinition(),datePickerDefinition(),dateObjectDefinition(),colorPickerDefinition(),markdownDefinition(),imageDefinition(),booleanToggleDefinition(),bigIntDefinition(),nanDefinition(),symbolDefinition(),undefinedDefinition(). Calling with no arguments reproduces the previous definition exactly.MarkdownComponent,DateTimePicker, …) for wrapping and hand-rolled definitions;DefinitionOverrides<T>exported as the override-surface type.CodeEditor/ReactSelectstay component-only (no factory is possible — they have no default condition).typeof value === 'string'to compensate for dropping the guard); they're now factory calls with that boilerplate gone. Also removed a stale "override by index" comment (getConditionalDefinitionsmatches byname).LinkCustomNodeDefinitionusers now land onhyperlinkDefinition()), README spot-fixes (the components README usage example referenced aDateTimePickerDefinitionexport that never existed), two existing changesets corrected, new changeset added.{ linkStyles?, stringTruncateLength? }, copy-pasted from Hyperlink) dropped — the component takes no custom props.Verification
pnpm compile(components) and demotsc -b --forceboth cleanbuild/index.d.tsexports exactly the designed surface — factories + components + props types +DefinitionOverrides; nocreateDefinitionFactory, no raw definition objectsdemo/src/v1, and deliberate v1-name mentions in migration contextsFollow-ups (tracked in #350)
guardescape hatch, "UI-replacement components" category for CodeEditor/ReactSelectpackages/)🤖 Generated with Claude Code