Linked data types
Cells that carry a structured entity (Stocks, Geography, custom) with refreshable fields accessed via dot notation
The entity shape
type Entity = {
kind: "entity";
dataType: string; // matches a DataTypeProvider.id
externalId: string; // the ticker / location / etc.
status: "loading" | "loaded" | "stale" | "error";
fields?: Record<string, string | number | boolean>;
formattedValue?: string;
};Wiring a provider
import type { DataTypeProvider } from "@rowsncolumns/spreadsheet-state";
const stockProvider: DataTypeProvider = {
id: "stock",
schema: () => [
{ field: "name", type: "string" },
{ field: "price", type: "number", numberFormat: '"$"#,##0.00' },
{ field: "currency", type: "string" },
{ field: "changePercent", type: "number", numberFormat: "0.00%" },
],
async refresh(entity) {
const ticker = (entity.externalId ?? "").toUpperCase();
const row = await fetchStockQuote(ticker);
return {
fields: {
name: row.name,
price: row.price,
currency: row.currency,
changePercent: row.changePercent,
},
formattedValue: `${ticker} $${row.price.toFixed(2)}`,
};
},
};Inserting a linked data type
Dot-notation field access
Refresh model
What's not yet supported
Last updated