import React from 'react'; import { ButtonLinkProps, ButtonProps } from '../../components/button/button.js'; import { FieldSet } from './field.js'; type GroupedDataProps = Omit, "draggable" | "title" | "onClick"> & { /** A title for the datagrid. */ title?: React.ReactNode; /** A `Function` that is used to create the preview for an object. */ renderPreview?: (data: T) => React.ReactNode; /** * A `string[]` containing the fields which should be used to detect the url * of a row. Fields specified in this object won't be rendered, instead: the * first (non url) field is rendered as link (`A`) with `href` set to the * resolved url of the row. */ urlFields?: string[]; buttonLinkProps?: ButtonLinkProps; buttonProps?: ButtonProps; /** * Gets called when a button is clicked. * @param event * @param data */ onClick?: (event: React.MouseEvent, data: T) => void; } & GroupedDataConfigurationProps; type GroupedDataConfigurationProps = GroupedDataFieldsetProps | GroupedDataGroupByProps; /** * WHen using `fieldsets` / `objectLists` to define sections. The length of `fieldSets` and `objectLists` should match. */ type GroupedDataFieldsetProps = { /** The field to sort by, if `undefined`: `fieldsets` and `objectLists` are used for manual segmentation. */ groupBy?: never; /** The fieldsets to render. */ fieldsets: FieldSet[]; /** The object lists to show, each index should match `fieldsets` index. */ objectLists: T[][]; fieldset?: never; objectList?: never; }; type GroupedDataGroupByProps = { /** * The field to sort by, if specified: `fieldset` acts as base fieldset and `objectList` as list of objects to group.`. * The first item in `fieldset` (the label) may contain "{group}" placeholder which will be replaced by the matching * value. */ groupBy: keyof T; /** The fieldset to render. */ fieldset: FieldSet; /** The objects to show. */ objectList: T[]; fieldsets?: never; objectLists?: never; }; /** * Returns segments represented by `[Fieldset[], T[][]]`. */ declare const getContextData: (groupBy?: keyof T, fieldset?: FieldSet, fieldsets?: FieldSet[], objectList?: T[], objectLists?: T[][]) => [FieldSet[], T[][]]; export { getContextData }; export type { GroupedDataConfigurationProps, GroupedDataFieldsetProps, GroupedDataGroupByProps, GroupedDataProps };