Skip to content

Mobile v4 docs: UI component plugins - #466

Merged
shanerbaner82 merged 1 commit into
mainfrom
docs/v4-ui-component-plugins
Aug 10, 2026
Merged

Mobile v4 docs: UI component plugins#466
shanerbaner82 merged 1 commit into
mainfrom
docs/v4-ui-component-plugins

Conversation

@shanerbaner82

Copy link
Copy Markdown
Contributor

What

Documents how a plugin ships a new EDGE element type — a components block in nativephp.json wiring a PHP Element and Blade component to a Compose renderer and a SwiftUI renderer.

The capability is fully implemented (it's how nativephp/mobile-ui ships text, column, button…) and native:plugin:create scaffolds 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)

  • When to reach for a UI plugin vs. a composed nested component
  • Scaffolding via native:plugin:create and the resulting package layout
  • The components manifest block, its field table, and the validation it's subject to (missing type/element/blade, or both renderers, throws)
  • The type → tag mapping<native:my-widget> / <my-widget> go through the precompiler and require a snake_case type; dotted types are only reachable via the x-native- component form. Also: core types always win, so plugin types can't shadow column/text/pressable
  • The Element contract — applyAttributes(), resolveProps() and callback-id registration, and the layout/style that arrive free from Tailwind parsing
  • The NativeBladeComponent contract and keeping $isSelfClosing in sync with the manifest
  • Both renderers, with the props accessors, node.children / NodeView, and the bridge event calls
  • How registration is generated — element + Blade component at boot, PluginRendererRegistration.{kt,swift} at build, and the consequence: a new component needs a rebuild, not just a composer update
  • Testing with Native::test() / assertElement()
  • Closing section on the lighter path: shipping a composed NativeComponent from any Composer package via ComponentRegistry — no native code, no plugin

Cross-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/mobile and nativephp/mobile-ui source rather than written from memory.

DocumentationRenderingTest caught real escaping bugs in a first draft (<x-native-…> examples being compiled as Blade components); those are wrapped in @verbatim now. Docs tests pass, and the rendered page was inspected to confirm the tables and escaped tags come out right.

🤖 Generated with Claude Code

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>
@shanerbaner82
shanerbaner82 merged commit 295f558 into main Aug 10, 2026
3 checks passed
@shanerbaner82
shanerbaner82 deleted the docs/v4-ui-component-plugins branch August 10, 2026 22:15
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.

1 participant