Commit cbf761f8 authored by Loïc Correnson's avatar Loïc Correnson

[dome] fix typing of children

parent cafbcb25
......@@ -451,7 +451,7 @@ export interface RadioGroupProps<A> {
/** Additional style for the `< dov /> ` container of Raiods */
style?: React.CSSProperties;
/** [[Radio]] Buttons. */
children: any;
children?: React.ReactNode;
}
/**
......@@ -523,7 +523,7 @@ export interface SelectProps {
/** Additional style for the `< dov /> ` container of Raiods */
style?: React.CSSProperties;
/** Shall be standard `<option/>` and `<optgroup/>` elements. */
children: any;
children?: React.ReactNode;
}
/**
......
......@@ -30,7 +30,7 @@ export interface LabelProps {
/** If `false`, do not display the label. Default to `true`. */
display?: boolean;
/** Additional content of the `<label/>` element. */
children?: any;
children?: React.ReactNode;
}
const makeLabel = (className: string, props: LabelProps) => {
......
......@@ -166,7 +166,7 @@ export interface FolderProps {
/** Contents left margin (in pixels, defaults to 18). */
indent?: number;
/** Children JSX elements. */
children: any;
children?: React.ReactNode;
}
/**
......
......@@ -60,7 +60,7 @@ export interface ElementProps {
/** Element identifier. */
id: string;
/** Element contents. */
children: React.ReactNode;
children?: React.ReactNode;
}
/**
......
......@@ -339,7 +339,7 @@ export interface FilterProps {
disabled?: boolean;
}
export interface Children { children: React.ReactNode }
export interface Children { children?: React.ReactNode }
interface FormContext {
disabled: boolean;
......@@ -1208,7 +1208,7 @@ export function RadioField<A>(props: RadioFieldProps<A>) {
/** @category Form Fields */
export interface SelectFieldProps extends FieldProps<string | undefined> {
placeholder?: string;
children: any;
children?: React.ReactNode;
}
/**
......
......@@ -155,7 +155,7 @@ export interface TableProps<Key, Row> {
/** Fallback for rendering an empty table. */
renderEmpty?: () => null | JSX.Element;
/** Shall only contains `<Column<Row> … />` elements. */
children?: any;
children?: React.ReactElement | React.ReactElement[];
}
// --------------------------------------------------------------------------
......@@ -705,7 +705,7 @@ export function Column<Row, Cell>(props: ColumnProps<Row, Cell>) {
function spawnIndex(
state: TableState<any, any>,
path: number[],
children: any,
children: React.ReactElement | React.ReactElement[],
) {
const indexChild = (elt: React.ReactElement, k: number) => (
<ColumnContext.Provider value={{ state, path, index: k }}>
......@@ -715,6 +715,11 @@ function spawnIndex(
return <>{React.Children.map(children, indexChild)}</>;
}
export interface ColumnGroupProps {
index?: index;
children?: React.ReactElement | React.ReactElement[];
}
/** Column Groups.
You should use this component in replacement of React fragments rendering
......@@ -758,12 +763,13 @@ function spawnIndex(
this implicit root column group, just pack your columns inside a classical
React fragment: `<Table … ><>{children}</></Table>`.
*/
export function ColumnGroup(props: { index?: index; children: any }) {
export function ColumnGroup(props: ColumnGroupProps) {
const context = React.useContext(ColumnContext);
if (!context) return null;
const { state, path, index: defaultIndex } = context;
const newPath = path.concat(props.index ?? defaultIndex);
return spawnIndex(state, newPath, props.children);
const { children } = props;
return children ? spawnIndex(state, newPath, children) : null;
}
// --------------------------------------------------------------------------
......@@ -1103,10 +1109,11 @@ export function Table<Key, Row>(props: TableProps<Key, Row>) {
return state.unwind;
});
Settings.useGlobalSettingsEvent(state.importSettings);
const columns = props.children ?? [];
return (
<div className="dome-xTable">
<React.Fragment key="columns">
{spawnIndex(state, [], props.children)}
{spawnIndex(state, [], columns)}
</React.Fragment>
<AutoSizer key="table">
{(size: Size) => makeTable(props, state, size)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment