|
8 | 8 |
|
9 | 9 | import React from 'react'; |
10 | 10 | import type { FieldMetadata, SelectOptionMetadata } from '@object-ui/types'; |
| 11 | +import { ComponentRegistry } from '@object-ui/core'; |
11 | 12 | import { Badge, Avatar, AvatarFallback, Button } from '@object-ui/components'; |
12 | 13 | import { Check, X } from 'lucide-react'; |
13 | 14 |
|
@@ -519,54 +520,49 @@ registerFieldRenderer('select', SelectCellRenderer); |
519 | 520 | export function mapFieldTypeToFormType(fieldType: string): string { |
520 | 521 | const typeMap: Record<string, string> = { |
521 | 522 | // Text-based fields |
522 | | - text: 'input', |
523 | | - textarea: 'textarea', |
524 | | - markdown: 'textarea', // Markdown editor (fallback to textarea) |
525 | | - html: 'textarea', // Rich text editor (fallback to textarea) |
| 523 | + text: 'field:text', |
| 524 | + textarea: 'field:textarea', |
| 525 | + markdown: 'field:markdown', // Markdown editor (fallback to textarea) |
| 526 | + html: 'field:html', // Rich text editor (fallback to textarea) |
526 | 527 |
|
527 | 528 | // Numeric fields |
528 | | - number: 'input', |
529 | | - currency: 'input', |
530 | | - percent: 'input', |
| 529 | + number: 'field:number', |
| 530 | + currency: 'field:currency', |
| 531 | + percent: 'field:percent', |
531 | 532 |
|
532 | 533 | // Date/Time fields |
533 | | - date: 'date-picker', |
534 | | - datetime: 'date-picker', |
535 | | - time: 'input', // Time picker (fallback to input with type="time") |
| 534 | + date: 'field:date', |
| 535 | + datetime: 'field:datetime', |
| 536 | + time: 'field:time', |
536 | 537 |
|
537 | 538 | // Boolean |
538 | | - boolean: 'switch', |
| 539 | + boolean: 'field:boolean', |
539 | 540 |
|
540 | 541 | // Selection fields |
541 | | - select: 'select', |
542 | | - lookup: 'select', |
543 | | - master_detail: 'select', |
| 542 | + select: 'field:select', |
| 543 | + lookup: 'field:lookup', |
| 544 | + master_detail: 'field:master_detail', |
544 | 545 |
|
545 | 546 | // Contact fields |
546 | | - email: 'input', |
547 | | - phone: 'input', |
548 | | - url: 'input', |
| 547 | + email: 'field:email', |
| 548 | + phone: 'field:phone', |
| 549 | + url: 'field:url', |
549 | 550 |
|
550 | 551 | // File fields |
551 | | - file: 'file-upload', |
552 | | - image: 'file-upload', |
| 552 | + file: 'field:file', |
| 553 | + image: 'field:image', |
553 | 554 |
|
554 | 555 | // Special fields |
555 | | - password: 'input', |
556 | | - location: 'input', // Location/map field (fallback to input) |
| 556 | + password: 'field:password', |
| 557 | + location: 'field:location', // Location/map field (fallback to input) |
557 | 558 |
|
558 | 559 | // Auto-generated/computed fields (typically read-only) |
559 | | - formula: 'input', |
560 | | - summary: 'input', |
561 | | - auto_number: 'input', |
562 | | - |
563 | | - // Complex data types |
564 | | - object: 'input', // JSON object (fallback to input) |
565 | | - vector: 'input', // Vector/embedding data (fallback to input) |
566 | | - grid: 'input', // Grid/table data (fallback to input) |
| 560 | + formula: 'field:formula', |
| 561 | + summary: 'field:summary', |
| 562 | + auto_number: 'field:auto_number', |
567 | 563 | }; |
568 | 564 |
|
569 | | - return typeMap[fieldType] || 'input'; |
| 565 | + return typeMap[fieldType] || 'field:text'; |
570 | 566 | } |
571 | 567 |
|
572 | 568 | /** |
@@ -890,9 +886,8 @@ export function registerField(fieldType: string): void { |
890 | 886 | // Create lazy component |
891 | 887 | const LazyFieldWidget = React.lazy(loader); |
892 | 888 |
|
893 | | - // Register with field namespace |
894 | | - const renderer = createFieldRenderer(LazyFieldWidget); |
895 | | - ComponentRegistry.register(fieldType, renderer, { namespace: 'field' }); |
| 889 | + // Register with field namespace - NO WRAPPER to allow form renderer to control label/layout |
| 890 | + ComponentRegistry.register(fieldType, LazyFieldWidget, { namespace: 'field' }); |
896 | 891 | } |
897 | 892 |
|
898 | 893 | /** |
@@ -1011,3 +1006,6 @@ export * from './widgets/GeolocationField'; |
1011 | 1006 | export * from './widgets/SignatureField'; |
1012 | 1007 | export * from './widgets/QRCodeField'; |
1013 | 1008 | export * from './widgets/MasterDetailField'; |
| 1009 | + |
| 1010 | +// Initialize registry |
| 1011 | +registerAllFields(); |
0 commit comments