UNPKG

flipper-plugin

Version:

Flipper Desktop plugin SDK and components

51 lines 2.2 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import React from 'react'; import { DataSource } from '../data-source/index'; import { PluginClient } from '../plugin/Plugin'; import { DataTableColumn } from '../ui/data-table/DataTable'; type PluginResult<Raw, Row> = { plugin(client: PluginClient<Record<string, Raw | {}>>): { rows: DataSource<Row, Row[keyof Row]>; }; Component(): React.ReactElement; }; /** * `createTablePlugin` creates a plugin that handles receiving data from the client and * displaying it in a table. The table handles selection of items, sorting, filtering and * rendering a sidebar where more detailed information can be presented about the selected row. * * The plugin expects the be able to subscribe to the `method` argument and receive either single data objects. * Each data object represents a row in the table. * * An optional `resetMethod` argument can be provided which will replace the current rows with the data provided. * This is useful when connecting to Flipper for this first time, or reconnecting to the client in an unknown state. * * Since the `createTablePlugin` defines both the `plugin` and `Component` for the plugin in one go, * making the result is most easily done by using `module.exports = createTablePlugin(....)` so that both are exported from the plugin package. */ export declare function createTablePlugin<Row extends object>(props: { method: string; resetMethod?: string; columns: DataTableColumn<Row>[]; renderSidebar?: (record: Row) => any; key?: keyof Row; onCopyRows?(records: Row[]): string; }): PluginResult<Row, Row>; export declare function createTablePlugin<Raw extends object, Row extends object = Raw>(props: { buildRow: (record: Raw) => Row; method: string; resetMethod?: string; columns: DataTableColumn<Row>[]; renderSidebar?: (record: Row) => any; key?: keyof Raw; onCopyRows?(records: Row[]): string; }): PluginResult<Raw, Row>; export {}; //# sourceMappingURL=createTablePlugin.d.ts.map