99// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
1010// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1111
12- import type { Layout } from "./types.ts" ;
12+ import type { Layout , LayoutPathTraversal } from "./types.ts" ;
1313
1414/**
1515 * Inserts a new child panel into the layout tree at a specified location.
@@ -28,32 +28,32 @@ import type { Layout } from "./types.ts";
2828export function insert_child (
2929 panel : Layout ,
3030 child : string ,
31- path : number [ ] ,
31+ path : LayoutPathTraversal ,
3232 orientation ?: "horizontal" | "vertical" ,
3333) : Layout {
3434 const createChildPanel = ( childId : string ) : Layout => ( {
35- type : "child-panel " ,
35+ type : "tab-layout " ,
3636 tabs : [ childId ] ,
3737 } ) ;
3838
3939 if ( path . length === 0 ) {
4040 // Insert at root level
41- if ( panel . type === "child-panel " ) {
42- // Add to existing child-panel as a tab
41+ if ( panel . type === "tab-layout " ) {
42+ // Add to existing tab-layout as a tab
4343 return {
44- type : "child-panel " ,
44+ type : "tab-layout " ,
4545 tabs : [ child , ...panel . tabs ] ,
4646 } ;
4747 } else if ( orientation ) {
4848 // When inserting at edge of root, wrap the entire panel in a new split
4949 return {
50- type : "split-panel " ,
50+ type : "split-layout " ,
5151 orientation : orientation ,
5252 children : [ createChildPanel ( child ) , panel ] ,
5353 sizes : [ 0.5 , 0.5 ] ,
5454 } ;
5555 } else {
56- // Append to existing split-panel
56+ // Append to existing split-layout
5757 const newChildren = [ ...panel . children , createChildPanel ( child ) ] ;
5858 const newSizes = [ ...panel . sizes , 1 / ( newChildren . length - 1 ) ] ;
5959 return {
@@ -69,8 +69,8 @@ export function insert_child(
6969
7070 // Special case: when orientation is provided and restPath is empty, handle edge insertion
7171 if ( orientation && restPath . length === 0 ) {
72- // If panel is a split-panel with the same orientation, insert into its children
73- if ( panel . type === "split-panel " && panel . orientation === orientation ) {
72+ // If panel is a split-layout with the same orientation, insert into its children
73+ if ( panel . type === "split-layout " && panel . orientation === orientation ) {
7474 const newChildren = [ ...panel . children ] ;
7575 newChildren . splice ( index , 0 , createChildPanel ( child ) ) ;
7676 const newSizes = [ ...panel . sizes ] ;
@@ -89,14 +89,14 @@ export function insert_child(
8989 : [ panel , createChildPanel ( child ) ] ;
9090
9191 return {
92- type : "split-panel " ,
92+ type : "split-layout " ,
9393 orientation : orientation ,
9494 children,
9595 sizes : [ 0.5 , 0.5 ] ,
9696 } ;
9797 }
9898
99- if ( panel . type === "child-panel " ) {
99+ if ( panel . type === "tab-layout " ) {
100100 // Stack into child array only when ALL of these conditions are met:
101101 // 1. Path has exactly one element (restPath is empty)
102102 // 2. Orientation was NOT explicitly provided (orientation is undefined)
@@ -117,7 +117,7 @@ export function insert_child(
117117
118118 // Otherwise, wrap in a split panel and recurse
119119 const newPanel : Layout = {
120- type : "split-panel " ,
120+ type : "split-layout " ,
121121 orientation : orientation || "horizontal" ,
122122 children : [ panel ] ,
123123 sizes : [ 1 ] ,
@@ -130,7 +130,7 @@ export function insert_child(
130130 if ( orientation && panel . children [ index ] ) {
131131 // When inserting at an edge, create a split panel with the new child and existing child
132132 const newSplitPanel : Layout = {
133- type : "split-panel " ,
133+ type : "split-layout " ,
134134 orientation : orientation ,
135135 children : [ createChildPanel ( child ) , panel . children [ index ] ] ,
136136 sizes : [ 0.5 , 0.5 ] ,
@@ -159,9 +159,9 @@ export function insert_child(
159159
160160 const targetChild = panel . children [ index ] ;
161161
162- // Determine the orientation to pass down when navigating into a child-panel
162+ // Determine the orientation to pass down when navigating into a tab-layout
163163 const childOrientation =
164- targetChild . type === "child-panel " &&
164+ targetChild . type === "tab-layout " &&
165165 restPath . length > 0 &&
166166 orientation !== undefined
167167 ? panel . orientation === "horizontal"
0 commit comments