Skip to content

render components automatically#15

Merged
fadymondy merged 2 commits intolaravilt:masterfrom
swarakaka:render-dynamic-components
Feb 25, 2026
Merged

render components automatically#15
fadymondy merged 2 commits intolaravilt:masterfrom
swarakaka:render-dynamic-components

Conversation

@swarakaka
Copy link
Contributor

@swarakaka swarakaka commented Feb 25, 2026

Description:
This change allows all form components previously defined in Laravel to be imported automatically. It also has a positive impact on performance, since the components don't need to be imported again.
On the other hand, Laravilt allows reading the components that the developer has created.

Changes:

  • Add a prefix to identify previously defined components.
  • Automatically import components because they have been previously identified.

Summary by CodeRabbit

  • Refactor
    • Streamlined internal component resolution to use a consistent naming scheme for rendering.
    • Improved handling of component properties and error message normalization.
    • No user-facing behavior changes; rendering API and functionality remain the same.

- Automatically import components because they have been previously identified.
@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b926a3a and 52ecf28.

📒 Files selected for processing (1)
  • resources/js/components/schema/Grid.vue

📝 Walkthrough

Walkthrough

Component resolution in form and grid components was refactored: explicit static/async component maps were removed and replaced by a naming-normalization approach (toLaraviltName) that derives rendered component names from field types. Helper functions for prop filtering and error normalization were added.

Changes

Cohort / File(s) Summary
Form component resolution
resources/js/components/Form.vue
Removed explicit/static component map and async imports; introduced toLaraviltName naming strategy for runtime component resolution. Added getComponentProps and getError helpers to filter props and normalize errors; runtime fallback to a plain div when name missing.
Grid field resolution
resources/js/components/schema/Grid.vue
Replaced static/async component mapping with toLaraviltName-based resolution for field components; removed prior async component definitions and direct imports, relying on constructed laravilt-prefixed names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through props and names so bright,
Swapping heavy maps for a nimble light,
"toLaravilt" hums the component's tune,
Errors tamed, props trimmed soon —
A small rabbit dance beneath the moon. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'render components automatically' is vague and generic, using non-descriptive language that doesn't clearly convey the specific change being made. Revise the title to be more specific about the core change, such as 'Refactor component resolution to use naming conventions instead of static map' or 'Replace componentMap with dynamic component resolution via toLaravelName helper'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
resources/js/components/Form.vue (1)

536-539: Harden name normalization before prefixing.

This helper is now central to rendering, so it should normalize defensively (trim, de-prefix, and consistent kebab-case) to avoid unresolved dynamic components from mixed input formats.

Proposed refactor
-const toLaraviltName = (name: any) => {
-  if (!name) return
-  return 'laravilt-' + name.replaceAll('_', '-')
-}
+const toLaraviltName = (name: unknown) => {
+  if (typeof name !== 'string' || name.trim() === '') return
+
+  const normalized = name
+    .trim()
+    .replace(/^laravilt-/, '')
+    .replace(/_/g, '-')
+    .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
+    .toLowerCase()
+
+  return `laravilt-${normalized}`
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@resources/js/components/Form.vue` around lines 536 - 539, The toLaraviltName
helper should defensively normalize inputs before prefixing: ensure the input is
a string, trim whitespace, remove any existing "laravilt-" prefix
(case-insensitive) to avoid double-prefixing, convert underscores and whitespace
to single hyphens, collapse consecutive hyphens, lowercase the result, then
return "laravilt-" + normalizedName; also return an empty string or undefined
consistently when the final normalized name is empty. Update the toLaraviltName
function to perform these steps and handle non-string inputs safely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@resources/js/components/Form.vue`:
- Around line 536-539: The toLaraviltName helper should defensively normalize
inputs before prefixing: ensure the input is a string, trim whitespace, remove
any existing "laravilt-" prefix (case-insensitive) to avoid double-prefixing,
convert underscores and whitespace to single hyphens, collapse consecutive
hyphens, lowercase the result, then return "laravilt-" + normalizedName; also
return an empty string or undefined consistently when the final normalized name
is empty. Update the toLaraviltName function to perform these steps and handle
non-string inputs safely.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e7ae33a and b926a3a.

📒 Files selected for processing (1)
  • resources/js/components/Form.vue

@fadymondy fadymondy merged commit da21639 into laravilt:master Feb 25, 2026
3 of 4 checks passed
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.

2 participants