@sheetwrite/vue wraps a Grid in a Vue component. It initializes WASM after the
component mounts on the client.
Package @sheetwrite/vue
Component Sheetwrite
Grid access Exposed grid and @ready
Change events @grid-change
Install
$ npm install @sheetwrite/vue
Import @sheetwrite/vue/styles.css once in your app.
Mount a grid
The component accepts columns and default-rows. Templates use kebab-case
event listeners.
import "@sheetwrite/vue/styles.css" ;
type Row = { name : string ; amount : number }; const emit = defineEmits <{
Listen to changes
@grid-change reports committed Grid changes. The component exposes grid
before it emits ready.
Resets and cleanup
A reset clears the old exposed handle, creates a new generation, and then
publishes the replacement. Attach again any coordinator that subscribed to the
old Grid. The lifecycle page lists which inputs
update in place and which reset.
Server rendering
Importing or rendering the component on the server does not start WASM. In Nuxt
or another server-rendered host, use a client-only boundary.
const Sheetwrite: SheetwriteComponentConstructor<SheetwriteProps<Record<string, CellScalar>, RowBridgeId>, SheetwriteGridEmits<RowBridgeId>, object> const Sheetwrite : SheetwriteComponentConstructor <
SheetwriteProps < Record < string , CellScalar >, RowBridgeId >,
SheetwriteGridEmits < RowBridgeId >,
object
> const Sheetwrite : SheetwriteComponentConstructor <
SheetwriteProps <
Record < string , CellScalar >,
RowBridgeId
>,
SheetwriteGridEmits < RowBridgeId >,
object
> Convenience component for local object rows with live option updates. Example import { createApp, h } from "vue" ;
import { Sheetwrite } from "@sheetwrite/vue" ;
const app = createApp ({ render : () => h (Sheetwrite, {
columns: [{ key: "amount" , title: "Amount" , type: "number" }],
defaultRows: [{ amount: 12 }, { amount: 18 }],
height: 400 ,
}) });
app. mount (document.body);
// Call app.unmount() before removing the host view. See also SheetwriteGrid * See also /docs/frameworks/vue/ API reference → interface GridReadyEvent interface GridReadyEvent interface GridReadyEvent Grid handle, generation, and reason published after adapter initialization. API reference → interface SimpleColumn<Row extends Record<string, CellScalar>> interface SimpleColumn < Row extends Record < string , CellScalar >> interface SimpleColumn < Row extends Record < string , CellScalar >> Column definition accepted by the adapters’ simple row-object API. API reference → interface ChangeEvent interface ChangeEvent interface ChangeEvent Payload of the change event; flows OUT for API submission/reconcile. API reference → type Row = {
name: string;
amount: number;
} type Row = {
name : string ;
amount : number ;
}; type Row = {
name : string ;
amount : number ;
}; name: string let name : string let name : string User-facing sheet name shown in tabs and workbook exports. API reference → const columns: readonly SimpleColumn<Row>[] const columns : readonly SimpleColumn < Row >[] const columns : readonly SimpleColumn < Row >[] Exact column runs represented by every returned row. API reference → const rows: readonly Row[] const rows : readonly Row [] const rows : readonly Row [] end-exclusive row range API reference → const defineProps: () => DefineProps<LooseRequired, never> (+2 overloads) const defineProps : () => DefineProps < LooseRequired , never > (+ 2 overloads ) const defineProps : () => DefineProps < LooseRequired , never > (+ 2 overloads ) Vue <script setup> compiler macro for declaring component props. The expected argument is the same as the component props option. Example runtime declaration: // using Array syntax const props = defineProps(['foo', 'bar']) // using Object syntax const props = defineProps({ foo: String, bar: { type: Number, required: true } }) Equivalent type-based declaration: // will be compiled into equivalent runtime declarations const props = defineProps<{ foo?: string bar: number }>() See also vuejs.org/api/sfc-script-setup.html#defineprops-defineemits This is only usable inside <script setup>, is compiled away in the output and should not be actually called at runtime.columns: readonly SimpleColumn<Row>[] let columns : readonly SimpleColumn < Row >[] let columns : readonly SimpleColumn < Row >[] Exact column runs represented by every returned row. API reference → rows: readonly Row[] let rows : readonly Row [] let rows : readonly Row [] end-exclusive row range API reference → const emit: ((evt: "gridChange", event: ChangeEvent) => void) & ((evt: "ready", event: GridReadyEvent) => void) const emit : ((
evt : "gridChange" ,
event : ChangeEvent ,
) => void ) &
(( evt : "ready" , event : GridReadyEvent ) => void ) const emit : ((
evt : "gridChange" ,
event : ChangeEvent ,
) => void ) &
((
evt : "ready" ,
event : GridReadyEvent ,
) => void ) const defineEmits: () => ((evt: "gridChange", event: ChangeEvent) => void) & ((evt: "ready", event: GridReadyEvent) => void) (+2 overloads) const defineEmits : () => (( evt : "gridChange" , event : ChangeEvent ) => void ) & (( evt : "ready" , event : GridReadyEvent ) => void ) (+ 2 overloads ) const defineEmits : () => (( evt : "gridChange" , event : ChangeEvent ) => void ) & (( evt : "ready" , event : GridReadyEvent ) => void ) (+ 2 overloads ) Vue <script setup> compiler macro for declaring a component's emitted events. The expected argument is the same as the component emits option. Example runtime declaration: const emit = defineEmits(['change', 'update']) Example type-based declaration: const emit = defineEmits<{ // <eventName>: <expected arguments> change: [] update: [value: number] // named tuple syntax }>() emit('change') emit('update', 1) This is only usable inside <script setup>, is compiled away in the output and should not be actually called at runtime. See also vuejs.org/api/sfc-script-setup.html#defineprops-defineemits gridChange: [event: ChangeEvent] let gridChange : [ event : ChangeEvent ] let gridChange : [
event : ChangeEvent ,
] Receives every committed Grid change, including its applied transaction. API reference → ChangeEvent ChangeEvent; ChangeEvent; Payload of the change event; flows OUT for API submission/reconcile. API reference → ready: [event: GridReadyEvent] let ready : [ event : GridReadyEvent ] let ready : [
event : GridReadyEvent ,
] Resolves after durable work is restored and every startup commit is visible locally. API reference → GridReadyEvent GridReadyEvent; GridReadyEvent; Grid handle, generation, and reason published after adapter initialization. API reference → const handleGridChange: (event: ChangeEvent) => void const handleGridChange : ( event : ChangeEvent ) => void const handleGridChange : (
event : ChangeEvent ,
) => void API reference → const emit: (evt: "gridChange", event: ChangeEvent) => void (+1 overload) const emit : ( evt : "gridChange" , event : ChangeEvent ) => void (+ 1 overload ) const emit : ( evt : "gridChange" , event : ChangeEvent ) => void (+ 1 overload ) API reference → const handleReady: (event: GridReadyEvent) => void const handleReady : ( event : GridReadyEvent ) => void const handleReady : (
event : GridReadyEvent ,
) => void API reference → const emit: (evt: "ready", event: GridReadyEvent) => void (+1 overload) const emit : ( evt : "ready" , event : GridReadyEvent ) => void (+ 1 overload ) const emit : ( evt : "ready" , event : GridReadyEvent ) => void (+ 1 overload ) API reference → SheetwriteProps<Record<string, CellScalar>, RowBridgeId>.columns: readonly SimpleColumn<Record<string, CellScalar>>[] SheetwriteProps < Record < string, CellScalar > , RowBridgeId > .columns: readonly SimpleColumn < Record < string, CellScalar >> [] SheetwriteProps < Record < string, CellScalar > , RowBridgeId > .columns: readonly SimpleColumn < Record < string, CellScalar >> [] Ordered schema used to derive the component-owned sheet. const columns: readonly SimpleColumn<Record<string, CellScalar>>[] const columns : readonly SimpleColumn <
Record < string , CellScalar >
>[] const columns : readonly SimpleColumn <
Record < string , CellScalar >
>[] Exact column runs represented by every returned row. API reference → SheetwriteProps<Record<string, CellScalar>, RowBridgeId>.defaultRows: readonly Record<string, CellScalar>[] SheetwriteProps < Record < string, CellScalar > , RowBridgeId > .defaultRows: readonly Record < string, CellScalar > [] SheetwriteProps < Record < string, CellScalar > , RowBridgeId > .defaultRows: readonly Record < string, CellScalar > [] Rows converted to initial columnar data; missing keys become null. const rows: readonly Record<string, CellScalar>[] const rows : readonly Record < string , CellScalar >[] const rows : readonly Record <
string ,
CellScalar
>[] end-exclusive row range API reference → height?: string | number | undefined height ?: string | number | undefined height ?: string | number | undefined Host height in CSS pixels for numbers or any CSS length string. onGridChange: (event: ChangeEvent) => void let onGridChange : ( event : ChangeEvent ) => void let onGridChange : (
event : ChangeEvent ,
) => void Committed Grid change, including its applied transaction. API reference → onReady?: ((payload: GridReadyEvent) => void) | undefined onReady ?: (( payload : GridReadyEvent ) => void ) | undefined onReady ?: (( payload : GridReadyEvent ) => void ) | undefined Resolves after durable work is restored and every startup commit is visible locally. API reference →