Skip to content

fix(SplitterLayout - TypeScript): extend children type #7457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 3 additions & 35 deletions packages/main/src/components/SplitterLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,13 @@

import { debounce, useStylesheet, useSyncRef } from '@ui5/webcomponents-react-base';
import { clsx } from 'clsx';
import type { CSSProperties, DependencyList, ReactElement } from 'react';
import type { CSSProperties } from 'react';
import { forwardRef, useEffect, useRef, useState } from 'react';
import { SplitterLayoutContext } from '../../internal/SplitterLayoutContext.js';
import type { CommonProps } from '../../types/index.js';
import type { SplitterElementPropTypes } from '../SplitterElement/index.js';
import { classNames, styleData } from './SplitterLayout.module.css.js';
import type { SplitterLayoutPropTypes } from './types.js';
import { useConcatSplitterElements } from './useConcatSplitterElements.js';

interface SplitterLayoutOptions {
/**
* Defines whether the `SplitterLayout` should be reset when its size changes depending on the orientation.
*/
resetOnSizeChange?: boolean;
/**
* Defines whether the `SplitterLayout` should be reset when its `children` change.
*/
resetOnChildrenChange?: boolean;
/**
* Defines a list of dependencies that trigger a reset of the `SplitterLayout` when they are changed.
*
* __Note:__ The order and size of arrays of dependencies must remain constant in React, it's therefore not possible to change size or order between renders.
*/
resetOnCustomDepsChange?: DependencyList;
}

export interface SplitterLayoutPropTypes extends CommonProps {
/**
* Controls if a vertical or horizontal `SplitterLayout` is rendered.
*/
vertical?: boolean;
/**
* The content areas (optional) to be split. The control will show n-1 splitter bars between n controls in this aggregation.
*/
children?: ReactElement<SplitterElementPropTypes> | ReactElement<SplitterElementPropTypes>[];
/**
* Defines options to customize the behavior of the SplitterLayout.
*/
options?: SplitterLayoutOptions;
}

/**
* A layout that contains several content areas. The content that is added to the `SplitterLayout` should be wrapped
* into 0-n `SplitterElement`s which define the size and size constraints of the content area.
Expand Down Expand Up @@ -137,4 +104,5 @@ const SplitterLayout = forwardRef<HTMLDivElement, SplitterLayoutPropTypes>((prop

SplitterLayout.displayName = 'SplitterLayout';

export type { SplitterLayoutPropTypes };
export { SplitterLayout };
37 changes: 37 additions & 0 deletions packages/main/src/components/SplitterLayout/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { CommonProps } from '@ui5/webcomponents-react-base';
import type { DependencyList, ReactElement } from 'react';
import type { SplitterElementPropTypes } from '../SplitterElement/index.js';

interface SplitterLayoutOptions {
/**
* Defines whether the `SplitterLayout` should be reset when its size changes depending on the orientation.
*/
resetOnSizeChange?: boolean;
/**
* Defines whether the `SplitterLayout` should be reset when its `children` change.
*/
resetOnChildrenChange?: boolean;
/**
* Defines a list of dependencies that trigger a reset of the `SplitterLayout` when they are changed.
*
* __Note:__ The order and size of arrays of dependencies must remain constant in React, it's therefore not possible to change size or order between renders.
*/
resetOnCustomDepsChange?: DependencyList;
}

type SplitterLayoutChild = ReactElement<SplitterElementPropTypes> | undefined | false | null;

export interface SplitterLayoutPropTypes extends CommonProps {
/**
* Controls if a vertical or horizontal `SplitterLayout` is rendered.
*/
vertical?: boolean;
/**
* The content areas (optional) to be split. The control will show n-1 splitter bars between n controls in this aggregation.
*/
children?: SplitterLayoutChild | SplitterLayoutChild[];
/**
* Defines options to customize the behavior of the SplitterLayout.
*/
options?: SplitterLayoutOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import type { CSSProperties, ReactElement } from 'react';
import { Children, cloneElement, isValidElement, useMemo } from 'react';
import { Splitter } from '../Splitter/index.js';
import type { SplitterElementPropTypes } from '../SplitterElement/index.js';
import type { SplitterLayoutPropTypes } from './types.js';

interface ConcatSplitterElements {
children: ReactElement<SplitterElementPropTypes> | ReactElement<SplitterElementPropTypes>[];
children: SplitterLayoutPropTypes['children'];
width: CSSProperties['width'];
height: CSSProperties['height'];
vertical: boolean;
Expand Down
Loading