1- import { ReactElement } from 'react' ;
2- import { getIntrinsicSize , hasUnboundedFlexStyle } from '../layout-reducer/flexUtils' ;
3- import { getProp } from '../utils' ;
4- import type { BreakPoint , ContentMeta } from './flexboxTypes' ;
1+ import { ReactElement } from "react" ;
2+ import {
3+ getIntrinsicSize ,
4+ hasUnboundedFlexStyle ,
5+ } from "../layout-reducer/flexUtils" ;
6+ import { getProp } from "../utils" ;
7+ import type { BreakPoint , ContentMeta } from "./flexboxTypes" ;
58
69const NO_INTRINSIC_SIZE : {
710 height ?: number ;
@@ -11,9 +14,13 @@ const NO_INTRINSIC_SIZE: {
1114export const SPLITTER = 1 ;
1215export const PLACEHOLDER = 2 ;
1316
14- const isIntrinsicallySized = ( item : ContentMeta ) => typeof item . intrinsicSize === 'number' ;
17+ const isIntrinsicallySized = ( item : ContentMeta ) =>
18+ typeof item . intrinsicSize === "number" ;
1519
16- const getBreakPointValues = ( breakPoints : BreakPoint [ ] , component : ReactElement ) => {
20+ const getBreakPointValues = (
21+ breakPoints : BreakPoint [ ] ,
22+ component : ReactElement
23+ ) => {
1724 const values : { [ key : string ] : number | undefined } = { } ;
1825 breakPoints . forEach ( ( breakPoint ) => {
1926 values [ breakPoint ] = getProp ( component , breakPoint ) ;
@@ -23,20 +30,21 @@ const getBreakPointValues = (breakPoints: BreakPoint[], component: ReactElement)
2330
2431export const gatherChildMeta = (
2532 children : ReactElement [ ] ,
26- dimension : ' width' | ' height' ,
33+ dimension : " width" | " height" ,
2734 breakPoints ?: BreakPoint [ ]
2835) => {
2936 return children . map ( ( child , index ) => {
30- const resizeable = getProp ( child , 'resizeable' ) ;
31- const { [ dimension ] : intrinsicSize } = getIntrinsicSize ( child ) ?? NO_INTRINSIC_SIZE ;
37+ const resizeable = getProp ( child , "resizeable" ) ;
38+ const { [ dimension ] : intrinsicSize } =
39+ getIntrinsicSize ( child ) ?? NO_INTRINSIC_SIZE ;
3240 const flexOpen = hasUnboundedFlexStyle ( child ) ;
3341 if ( breakPoints ) {
3442 return {
3543 index,
3644 flexOpen,
3745 intrinsicSize,
3846 resizeable,
39- ...getBreakPointValues ( breakPoints , child )
47+ ...getBreakPointValues ( breakPoints , child ) ,
4048 } ;
4149 } else {
4250 return { index, flexOpen, intrinsicSize, resizeable } ;
@@ -47,7 +55,9 @@ export const gatherChildMeta = (
4755// Splitters are inserted AFTER the associated index, so
4856// never a splitter in last position.
4957// Placeholder goes before (first) OR after(last) index
50- export const findSplitterAndPlaceholderPositions = ( childMeta : ContentMeta [ ] ) => {
58+ export const findSplitterAndPlaceholderPositions = (
59+ childMeta : ContentMeta [ ]
60+ ) => {
5161 const count = childMeta . length ;
5262 const allIntrinsic = childMeta . every ( isIntrinsicallySized ) ;
5363 const splitterPositions = Array ( count ) . fill ( 0 ) ;
@@ -81,15 +91,21 @@ export const findSplitterAndPlaceholderPositions = (childMeta: ContentMeta[]) =>
8191 }
8292} ;
8393
84- export const identifyResizeParties = ( contentMeta : ContentMeta [ ] , idx : number ) => {
94+ export const identifyResizeParties = (
95+ contentMeta : ContentMeta [ ] ,
96+ idx : number
97+ ) => {
8598 const idx1 = getLeadingResizeablePos ( contentMeta , idx ) ;
8699 const idx2 = getTrailingResizeablePos ( contentMeta , idx ) ;
87100 const participants = idx1 !== - 1 && idx2 !== - 1 ? [ idx1 , idx2 ] : undefined ;
88101 const bystanders = identifyResizeBystanders ( contentMeta , participants ) ;
89102 return [ participants , bystanders ] ;
90103} ;
91104
92- function identifyResizeBystanders ( contentMeta : ContentMeta [ ] , participants ?: number [ ] ) {
105+ function identifyResizeBystanders (
106+ contentMeta : ContentMeta [ ] ,
107+ participants ?: number [ ]
108+ ) {
93109 if ( participants ) {
94110 const bystanders = [ ] ;
95111 for ( let i = 0 ; i < contentMeta . length ; i ++ ) {
@@ -115,7 +131,7 @@ function getTrailingResizeablePos(contentMeta: ContentMeta[], idx: number) {
115131 let pos = idx ,
116132 resizeable = false ;
117133 const count = contentMeta . length ;
118- while ( pos < count && ! resizeable ) {
134+ while ( pos < count - 1 && ! resizeable ) {
119135 pos = pos + 1 ;
120136 resizeable = isResizeable ( contentMeta , pos ) ;
121137 }
0 commit comments