|
|
|
@@ -53,7 +53,7 @@ const Split: React.FC<SplitProps> & { Panel: React.FC<PanelProps> } = ({
|
|
|
|
|
|
|
|
|
|
|
|
// detect Panel children and extract sizes and passthrough props
|
|
|
|
// detect Panel children and extract sizes and passthrough props
|
|
|
|
const sizes: (number | null)[] = childrenArray.map((c) => {
|
|
|
|
const sizes: (number | null)[] = childrenArray.map((c) => {
|
|
|
|
if (React.isValidElement(c) && (c.type as any).displayName === 'SplitPanel') {
|
|
|
|
if (React.isValidElement(c) && (c.type as any)?.displayName === 'SplitPanel') {
|
|
|
|
const p = c as React.ReactElement<PanelProps>
|
|
|
|
const p = c as React.ReactElement<PanelProps>
|
|
|
|
return typeof p.props.size === 'number' ? p.props.size : 1
|
|
|
|
return typeof p.props.size === 'number' ? p.props.size : 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -71,7 +71,7 @@ const Split: React.FC<SplitProps> & { Panel: React.FC<PanelProps> } = ({
|
|
|
|
let extraClass = ''
|
|
|
|
let extraClass = ''
|
|
|
|
let extraStyle: React.CSSProperties | undefined
|
|
|
|
let extraStyle: React.CSSProperties | undefined
|
|
|
|
|
|
|
|
|
|
|
|
if (React.isValidElement(child) && (child.type as any).displayName === 'SplitPanel') {
|
|
|
|
if (React.isValidElement(child) && (child.type as any)?.displayName === 'SplitPanel') {
|
|
|
|
const p = child as React.ReactElement<PanelProps>
|
|
|
|
const p = child as React.ReactElement<PanelProps>
|
|
|
|
extraClass = p.props.className || ''
|
|
|
|
extraClass = p.props.className || ''
|
|
|
|
extraStyle = p.props.style
|
|
|
|
extraStyle = p.props.style
|
|
|
|
@@ -90,7 +90,9 @@ const Split: React.FC<SplitProps> & { Panel: React.FC<PanelProps> } = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const mergedStyle = extraStyle ? { ...style, ...extraStyle } : style
|
|
|
|
const mergedStyle = extraStyle ? { ...style, ...extraStyle } : style
|
|
|
|
const childElem = React.isValidElement(child) ? (child as React.ReactElement<PanelProps>) : null
|
|
|
|
const childElem = React.isValidElement(child) && (child.type as any)?.displayName === 'SplitPanel'
|
|
|
|
|
|
|
|
? (child as React.ReactElement<PanelProps>)
|
|
|
|
|
|
|
|
: null
|
|
|
|
const variant = childElem ? childElem.props.variant ?? splitVariant : splitVariant
|
|
|
|
const variant = childElem ? childElem.props.variant ?? splitVariant : splitVariant
|
|
|
|
// Determine accent: a panel with its own `accent` always uses it.
|
|
|
|
// Determine accent: a panel with its own `accent` always uses it.
|
|
|
|
// Otherwise, if the parent `Split` has an `accent`, only the first
|
|
|
|
// Otherwise, if the parent `Split` has an `accent`, only the first
|
|
|
|
|