Loading documentation…
Create a typed bridge while preserving row and identity inference.
});function createRowBridge<Workspace packages depending on @sheetwrite/core
@sheetwrite/benchdependency@sheetwrite/docs-startdependency@sheetwrite/reactdependency@sheetwrite/sveltedependency@sheetwrite/vuedependency@sheetwrite/xlsxdependencyPublic exports naming createRowBridge
import { createRowBridge } from "@sheetwrite/core";
const bridge = createRowBridge({
columns: [{ key: "amount" }],
defaultRows: [{ id: "order-1", amount: 12 }],
getRowId: (row) => row.id,
});See also RowBridgeOptions *See also RowBridgeAPI reference →const bridge: RowBridge<string, Record<string, CellScalar>>const bridge: RowBridge<string, Record<string, CellScalar>>const bridge: RowBridge<
string,
Record<string, CellScalar>
>createRowBridge<{
id: string;
amount: number;
}, string>(options: RowBridgeOptions<{
id: string;
amount: number;
}, string>): RowBridge<string, Record<string, CellScalar>>createRowBridge<{
id: string;
amount: number;
}, string>(options: RowBridgeOptions<{
id: string;
amount: number;
}, string>): RowBridge<string, Record<string, CellScalar>>createRowBridge<{
id: string;
amount: number;
}, string>(options: RowBridgeOptions<{
id: string;
amount: number;
}, string>): RowBridge<string, Record<string, CellScalar>>Create a typed bridge while preserving row and identity inference.Exampleimport { createRowBridge } from "@sheetwrite/core";
const bridge = createRowBridge({
columns: [{ key: "amount" }],
defaultRows: [{ id: "order-1", amount: 12 }],
getRowId: (row) => row.id,
});See also RowBridgeOptions *See also RowBridgeAPI reference →RowBridgeOptions<{ id: string; amount: number; }, string>.columns: readonly RowBridgeColumn<{
id: string;
amount: number;
}>[]interface RowBridgeOptions<{ id: string; amount: number; }, string> { columns: readonly RowBridgeColumn<{
id: string;
amount: number;
}>[] }interface RowBridgeOptions<{ id: string; amount: number; }, string> { columns: readonly RowBridgeColumn<{
id: string;
amount: number;
}>[] }Exact column runs represented by every returned row.API reference →RowBridgeColumn<{ id: string; amount: number; }>.key: "amount" | "id"interface RowBridgeColumn<{ id: string; amount: number; }> { key: "amount" | "id" }interface RowBridgeColumn<{ id: string; amount: number; }> { key: "amount" | "id" }Non-empty key, unique within the sheet, used to map input and datasource values.API reference →RowBridgeOptions<{ id: string; amount: number; }, string>.defaultRows: readonly {
id: string;
amount: number;
}[]interface RowBridgeOptions<{ id: string; amount: number; }, string> { defaultRows: readonly {
id: string;
amount: number;
}[] }interface RowBridgeOptions<{ id: string; amount: number; }, string> { defaultRows: readonly {
id: string;
amount: number;
}[] }Rows converted to initial columnar data; missing keys become null.API reference →id: stringlet id: stringlet id: stringStable identity used by operations, history, and collaboration rebase.API reference →amount: numberlet amount: numberlet amount: numberRowBridgeOptions<{ id: string; amount: number; }, string>.getRowId: (row: {
id: string;
amount: number;
}, index: number) => stringinterface RowBridgeOptions<{ id: string; amount: number; }, string> { getRowId: (row: {
id: string;
amount: number;
}, index: number) => string }interface RowBridgeOptions<{ id: string; amount: number; }, string> { getRowId: (row: {
id: string;
amount: number;
}, index: number) => string }Opt-in stable data-row identity extractor.API reference →row: {
id: string;
amount: number;
}let row: {
id: string;
amount: number;
}let row: {
id: string;
amount: number;
}type CellScalar = string | number | boolean | null;type CellScalar = string | number | boolean | null;type CellScalar =
| string
| number
| boolean
| null;A scalar that can be displayed directly.API reference →type RowBridgeId = string | number;type RowBridgeId = string | number;type RowBridgeId =
string | number;A stable host identity for one data-space row.API reference →interface RowBridgeOptions<
Row extends Record<string, CellScalar>,
Id extends RowBridgeId = RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (row: Row, index: number) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (context: RowBridgeInsertContext) => Id;
readonly maxRecentTransactions?: number;
}interface RowBridgeOptions<
Row extends Record<string, CellScalar>,
Id extends RowBridgeId = RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (row: Row, index: number) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (context: RowBridgeInsertContext) => Id;
readonly maxRecentTransactions?: number;
}interface RowBridgeOptions<
Row extends Record<
string,
CellScalar
>,
Id extends RowBridgeId =
RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (
row: Row,
index: number,
) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (
context: RowBridgeInsertContext,
) => Id;
readonly maxRecentTransactions?: number;
}Options for the framework-neutral, opt-in row bridge.API reference →class RowBridge {
constructor<
Id extends RowBridgeId = RowBridgeId,
Row extends Record<string, CellScalar> = Record<
string,
CellScalar
>,
>(options: RowBridgeOptions<Row, Id>);
columnKeys: (sheet?: SheetId) => readonly string[];
project: (
event: ChangeEvent,
requestedOperations?: readonly DocumentOp[],
transactionId?: string,
) => RowBridgeProjection<Id>;
reconcile: (
// … 4 more lines — see the API reference
}class RowBridge {
constructor<
Id extends RowBridgeId = RowBridgeId,
Row extends Record<string, CellScalar> = Record<
string,
CellScalar
>,
>(options: RowBridgeOptions<Row, Id>);
columnKeys: (sheet?: SheetId) => readonly string[];
project: (
event: ChangeEvent,
requestedOperations?: readonly DocumentOp[],
transactionId?: string,
) => RowBridgeProjection<Id>;
reconcile: (
// … 4 more lines — see the API reference
}class RowBridge {
constructor<
Id extends RowBridgeId =
RowBridgeId,
Row extends Record<
string,
CellScalar
> = Record<
string,
CellScalar
>,
>(
options: RowBridgeOptions<
Row,
Id
>,
);
columnKeys: (
sheet?: SheetId,
// … 13 more lines — see the API reference
}Projects canonical document transactions into host-owned row changes. The bridge only owns compact data-space identity arrays. It never writes to defaultRows, never renders, and never creates a second document store.API reference →