@@ -38,9 +38,6 @@ import {
3838import { TabbedForm } from './TabbedForm' ;
3939import { WizardForm } from './WizardForm' ;
4040import { useFormChromeTranslation } from './formChrome' ;
41- import { SplitForm } from './SplitForm' ;
42- import { DrawerForm } from './DrawerForm' ;
43- import { ModalForm } from './ModalForm' ;
4441import { MasterDetailForm } from './MasterDetailForm' ;
4542import {
4643 applyAutoLayout ,
@@ -226,18 +223,31 @@ export const ObjectForm: React.FC<ObjectFormComponentProps> = ({ schema, ...rest
226223 </ RecordFieldAccessForForm >
227224) ;
228225
229- const ObjectFormBody : React . FC < ObjectFormComponentProps > = ( {
230- schema : rawSchema ,
231- dataSource,
232- } ) => {
226+ /**
227+ * The schema every layout reads, prepared ONCE above the layout fork: the
228+ * structured `buttons` / `defaults` folded onto the flat keys, the seven
229+ * `I18nLabel` members resolved, legacy `groups` normalised to `sections`,
230+ * field-level permissions applied and `{ group }` sections resolved — plus the
231+ * section-label translator every section map uses.
232+ *
233+ * A hook of its own because two renderers prepare the same schema: this file's
234+ * `ObjectForm` (the `simple` / `tabbed` / `wizard` layouts) and
235+ * `ObjectFormContainer`, which supplies the drawer or modal container an
236+ * `object-form` block asks for with `formType` (ADR-0050 Decision 4 — the
237+ * container is the caller's, never the form's).
238+ */
239+ export function usePreparedFormSchema (
240+ rawSchema : ObjectFormComponentProps [ 'schema' ] ,
241+ dataSource : ObjectFormComponentProps [ 'dataSource' ] ,
242+ ) {
233243 const perms = usePermissions ( ) ;
234244
235245 // ── `sections[].group` — the ADR-0085 §5 REFERENCE form (objectui#7051) ───
236246 //
237247 // A section may point `group` at one of the object's declared `fieldGroups`
238248 // instead of enumerating members (`@objectstack/spec` 17.3.0,
239249 // objectstack#13855). Resolving it needs the OBJECT definition, and this
240- // dispatcher — unlike the six bodies below it — has never loaded one.
250+ // preparation — unlike the layout bodies it feeds — has never loaded one.
241251 //
242252 // It is resolved HERE, above the routing, on purpose: every variant's
243253 // `sections` prop is rebuilt key by key in the maps below, so a `group` left
@@ -274,7 +284,8 @@ const ObjectFormBody: React.FC<ObjectFormComponentProps> = ({
274284
275285 // Apply field-level permissions to the entire schema (sections + flat
276286 // fields) BEFORE dispatching to any variant. This way all variants
277- // (Tabbed/Wizard/Split/Drawer/Modal/Simple) transparently honour FLS.
287+ // (Tabbed/Wizard/Simple here, Drawer/Modal through `ObjectFormContainer`)
288+ // transparently honour FLS.
278289 // Fail-open when no provider mounted (perms.isLoaded false).
279290 const schema = useMemo < LocalizedObjectFormSchema > ( ( ) => {
280291 // framework#1894 / objectstack-ai/objectstack#2998 (ADR-0078): the authored @objectstack/spec
@@ -341,15 +352,23 @@ const ObjectFormBody: React.FC<ObjectFormComponentProps> = ({
341352 const { sectionLabel } = useSafeFieldLabel ( ) ;
342353 const tSec = ( s : any ) =>
343354 s ?. name ? sectionLabel ( schema . objectName , s . name , s . label || s . name ) : s ?. label ;
355+ return { schema, tSec } ;
356+ }
357+
358+ const ObjectFormBody : React . FC < ObjectFormComponentProps > = ( {
359+ schema : rawSchema ,
360+ dataSource,
361+ } ) => {
362+ const { schema, tSec } = usePreparedFormSchema ( rawSchema , dataSource ) ;
344363
345364 // Master-detail: when the schema declares inline child collections, render as
346365 // a master-detail form (parent fields + child grids, persisted atomically).
347366 // This lets a plain form view become master-detail by config — no bespoke
348367 // page. Skipped in view mode (read-only detail uses related lists instead).
349- // For drawer/modal formTypes we fall through to DrawerForm/ModalForm, which
350- // host the master-detail form INSIDE their envelope.
351- const routesToMasterDetail = ! ! ( schema as any ) . subforms ?. length && schema . mode !== 'view'
352- && schema . formType !== 'drawer' && schema . formType !== 'modal ' ;
368+ // A drawer or modal container never reaches here: `ObjectFormContainer`
369+ // hands it to DrawerForm/ModalForm, which host the master-detail form INSIDE
370+ // their envelope.
371+ const routesToMasterDetail = ! ! ( schema as any ) . subforms ?. length && schema . mode !== 'view ' ;
353372
354373 // ── objectui#6237 diagnostic, now scoped to the ONE arm still inert ────────
355374 // The interim diagnostic ruled on 2026-08-29 covered `tabbed` AND `wizard`,
@@ -447,10 +466,10 @@ const ObjectFormBody: React.FC<ObjectFormComponentProps> = ({
447466 // ADR-0089 section predicate (objectui#6237) — key-by-key rebuild,
448467 // so an uncopied key is silently dropped before TabbedForm ever
449468 // sees it, exactly as it was on this route until this card. The
450- // split/ drawer/modal maps below have carried it since #6111; this
451- // is the tabbed arm joining them.
469+ // drawer/modal maps (`ObjectFormContainer`) have carried it since
470+ // #6111; this is the tabbed arm joining them.
452471 //
453- // Read WITHOUT an `as any` cast on purpose, unlike those three :
472+ // Read WITHOUT an `as any` cast on purpose, unlike those two :
454473 // `ObjectFormSection.visibleWhen` is declared, so the compiler is
455474 // able to catch a rename here. Through a cast it would keep
456475 // compiling and silently copy `undefined` — the exact silent-drop
@@ -532,115 +551,6 @@ const ObjectFormBody: React.FC<ObjectFormComponentProps> = ({
532551 ) ;
533552 }
534553
535- if ( schema . formType === 'split' && schema . sections ?. length ) {
536- return (
537- < SplitForm
538- schema = { {
539- ...schema ,
540- formType : 'split' ,
541- sections : schema . sections . map ( s => ( {
542- name : s . name ,
543- label : tSec ( s ) ,
544- description : s . description ,
545- columns : s . columns ,
546- // `?? []` — see the tabbed arm above (objectui#7051).
547- fields : s . fields ?? [ ] ,
548- // Explicit pane placement (spec FormSection.pane). This mapping
549- // rebuilds each section key by key, so a key it doesn't copy is
550- // silently dropped — exactly how `visibleOn` once vanished here.
551- pane : s . pane ,
552- // ADR-0089 section predicate (#6111) — same reason as `pane` above:
553- // a key this map does not copy never reaches the layout at all.
554- visibleWhen : ( s as any ) . visibleWhen ,
555- visibleWhenFault : s . visibleWhenFault ,
556- // `className` / `gridClassName`: deliberately not copied — see the
557- // tabbed arm above (objectstack#13626, ruled 2026-09-01).
558- } ) ) ,
559- splitDirection : schema . splitDirection ,
560- splitSize : schema . splitSize ,
561- splitResizable : schema . splitResizable ,
562- } }
563- dataSource = { dataSource }
564- className = { schema . className }
565- />
566- ) ;
567- }
568-
569- if ( schema . formType === 'drawer' ) {
570- // `layout` passes through unfolded: it is `vertical | horizontal` on both
571- // faces since objectui#11168 slice 3 (objectui#7759 group C), and the fold
572- // that mapped `inline` / `grid` away here is retired with them.
573- return (
574- < DrawerForm
575- schema = { {
576- ...schema ,
577- formType : 'drawer' ,
578- sections : schema . sections ?. map ( s => ( {
579- name : s . name ,
580- label : tSec ( s ) ,
581- description : s . description ,
582- columns : s . columns ,
583- // `?? []` — see the tabbed arm above (objectui#7051).
584- fields : s . fields ?? [ ] ,
585- collapsible : ( s as any ) . collapsible ,
586- collapsed : ( s as any ) . collapsed ,
587- // ADR-0089 section predicate (#6111) — key-by-key rebuild, so an
588- // uncopied key is silently dropped before DrawerForm ever sees it.
589- visibleWhen : ( s as any ) . visibleWhen ,
590- visibleWhenFault : s . visibleWhenFault ,
591- // `className`: deliberately not copied — see the tabbed arm above
592- // (objectstack#13626, ruled 2026-09-01). DrawerForm's own divider
593- // site stops reading it in the same pass.
594- } ) ) ,
595- open : schema . open ,
596- onOpenChange : schema . onOpenChange ,
597- drawerSide : schema . drawerSide ,
598- drawerWidth : schema . drawerWidth ,
599- } }
600- dataSource = { dataSource }
601- className = { schema . className }
602- />
603- ) ;
604- }
605-
606- if ( schema . formType === 'modal' ) {
607- // `layout` passes through unfolded — see the drawer branch above.
608- return (
609- < ModalForm
610- schema = { {
611- ...schema ,
612- formType : 'modal' ,
613- sections : schema . sections ?. map ( s => ( {
614- name : s . name ,
615- label : tSec ( s ) ,
616- description : s . description ,
617- columns : s . columns ,
618- // `?? []` — see the tabbed arm above (objectui#7051).
619- fields : s . fields ?? [ ] ,
620- // The collapse pair (objectui#9849 step two — director ruling
621- // letter E, item 1: group semantics attach 「on every arm」). The
622- // spec declares both on `sections[]`; this map used to copy
623- // neither, so the modal silently ignored a declared collapse.
624- collapsible : s . collapsible ,
625- collapsed : s . collapsed ,
626- // ADR-0089 section predicate (#6111) — key-by-key rebuild, so an
627- // uncopied key is silently dropped before ModalForm ever sees it.
628- visibleWhen : ( s as any ) . visibleWhen ,
629- visibleWhenFault : s . visibleWhenFault ,
630- // `className` / `gridClassName`: deliberately not copied — see the
631- // tabbed arm above (objectstack#13626, ruled 2026-09-01).
632- } ) ) ,
633- open : schema . open ,
634- onOpenChange : schema . onOpenChange ,
635- modalSize : schema . modalSize ,
636- modalCloseButton : schema . modalCloseButton ,
637- } }
638- dataSource = { dataSource }
639- className = { schema . className }
640- />
641- ) ;
642- }
643-
644554 // Default: simple form
645555 return < SimpleObjectForm schema = { schema } dataSource = { dataSource } /> ;
646556} ;
@@ -1342,7 +1252,7 @@ const SimpleObjectForm: React.FC<{ schema: LocalizedObjectFormSchema; dataSource
13421252 }
13431253
13441254 // What this save writes — the ONE outbound sequence, shared with the
1345- // `tabbed`, `split` and `wizard` layouts (objectui#10563): strip what a form never
1255+ // `tabbed` and `wizard` layouts (objectui#10563): strip what a form never
13461256 // writes (server-owned, computed, read-only, unknown to the object, and
13471257 // refused by the caller's field-level security through `fieldWriteGate`,
13481258 // objectui#10108 / `80c54122e`), omit the producer-owned defaults on a
0 commit comments