Mobile v4 docs: UI component plugins - #466
Merged
Merged
Conversation
Plugins can declare new EDGE element types — a `components` block in nativephp.json wiring a PHP Element and Blade component to a Compose renderer and a SwiftUI renderer — and `native:plugin:create` scaffolds the whole thing. None of it was documented; the plugins section only covered bridge functions and native capabilities. Adds plugins/ui-components, covering the manifest fields and their validation, the type → tag mapping (including why dotted types are only reachable via the x-native- component form), the Element and Blade component contracts, both renderers with their props/children/event APIs, how registration is generated at boot and at build, and testing. Ends with the lighter alternative — shipping a composed NativeComponent via ComponentRegistry, no native code. Cross-links it from the plugins introduction, creating-plugins, the EDGE components introduction, and nested-components. 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.
What
Documents how a plugin ships a new EDGE element type — a
componentsblock innativephp.jsonwiring a PHPElementand Blade component to a Compose renderer and a SwiftUI renderer.The capability is fully implemented (it's how
nativephp/mobile-uishipstext,column,button…) andnative:plugin:createscaffolds it end-to-end, but nothing in the v4 docs mentioned it. The plugins section covered only bridge functions and native capabilities; the manifest field table had no UI entry at all.New page —
plugins/ui-components.md(order 450)native:plugin:createand the resulting package layoutcomponentsmanifest block, its field table, and the validation it's subject to (missingtype/element/blade, or both renderers, throws)type→ tag mapping —<native:my-widget>/<my-widget>go through the precompiler and require a snake_casetype; dotted types are only reachable via thex-native-component form. Also: core types always win, so plugin types can't shadowcolumn/text/pressableElementcontract —applyAttributes(),resolveProps()and callback-id registration, and the layout/style that arrive free from Tailwind parsingNativeBladeComponentcontract and keeping$isSelfClosingin sync with the manifestnode.children/NodeView, and the bridge event callsPluginRendererRegistration.{kt,swift}at build, and the consequence: a new component needs a rebuild, not just acomposer updateNative::test()/assertElement()NativeComponentfrom any Composer package viaComponentRegistry— no native code, no pluginCross-links
plugins/introduction(added UI components to "What Plugins Can Do"),plugins/creating-plugins(the scaffolder's type prompt),edge-components/introduction("Building your own"),the-basics/nested-components.Verification
Every code sample, class name, method signature, manifest field, and native API in the page was checked against
nativephp/mobileandnativephp/mobile-uisource rather than written from memory.DocumentationRenderingTestcaught real escaping bugs in a first draft (<x-native-…>examples being compiled as Blade components); those are wrapped in@verbatimnow. Docs tests pass, and the rendered page was inspected to confirm the tables and escaped tags come out right.🤖 Generated with Claude Code