Integrate Sheetwrite with Vue events, exposed Grid state, and resets.
@sheetwrite/vue initializes WASM after client mount. The simple component accepts columns and defaultRows; Vue templates use kebab-case event listeners such as @grid-change and @ready.
The component exposes grid before emitting ready. A reset clears the old exposed handle, creates a new generation, and then publishes the replacement. Reattach any coordinator that subscribed to the old grid.
Vue adapter
<scriptsetuplang="ts">
import { Sheetwriteconst Sheetwrite: SheetwriteComponentConstructor<SheetwriteProps, SheetwriteGridEmits, object>constSheetwrite:SheetwriteComponentConstructor<SheetwriteProps,SheetwriteGridEmits,object>constSheetwrite:SheetwriteComponentConstructor<SheetwriteProps,SheetwriteGridEmits,object>Convenience component for local object rows with live option updates.API reference →, typeGridReadyEventinterface GridReadyEventinterfaceGridReadyEventinterfaceGridReadyEventGrid handle, generation, and reason published after adapter initialization.API reference →, typeSimpleColumninterface SimpleColumn<Row extends Record<string, CellScalar>>interfaceSimpleColumn<RowextendsRecord<string, CellScalar>>interfaceSimpleColumn<RowextendsRecord<string, CellScalar>>Column definition accepted by the adapters’ simple row-object API.API reference → } from"@sheetwrite/vue";
importtype { ChangeEventinterface ChangeEventinterfaceChangeEventinterfaceChangeEventPayload of the change event; flows OUT for API submission/reconcile.API reference → } from"@sheetwrite/core";
const { columnsconst columns: readonly SimpleColumn<Row>[]constcolumns:readonlySimpleColumn<Row>[]constcolumns:readonlySimpleColumn<Row>[]Restrict to these column indices (defaults to all columns).API reference →, rowsconst rows: readonly Row[]constrows:readonlyRow[]constrows:readonlyRow[]end-exclusive row rangeAPI reference → } =definePropsconst defineProps: () => DefineProps<LooseRequired, never> (+2 overloads)constdefineProps: () =>DefineProps<LooseRequired, never> (+2overloads)constdefineProps: () =>DefineProps<LooseRequired, never> (+2overloads)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 }>()@seevuejs.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.<{
constemitconst emit: ((evt: "gridChange", event: ChangeEvent) => void) & ((evt: "ready", event: GridReadyEvent) => void)constemit: ((evt:"gridChange",event:ChangeEvent,) =>void) &((evt:"ready", event:GridReadyEvent) =>void)constemit: ((evt:"gridChange",event:ChangeEvent,) =>void) &((evt:"ready",event:GridReadyEvent,) =>void)=defineEmitsconst defineEmits: () => ((evt: "gridChange", event: ChangeEvent) => void) & ((evt: "ready", event: GridReadyEvent) => void) (+2 overloads)constdefineEmits: () => ((evt:"gridChange", event:ChangeEvent) =>void) & ((evt:"ready", event:GridReadyEvent) =>void) (+2overloads)constdefineEmits: () => ((evt:"gridChange", event:ChangeEvent) =>void) & ((evt:"ready", event:GridReadyEvent) =>void) (+2overloads)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.@seevuejs.org/api/sfc-script-setup.html#defineprops-defineemits<{
gridChange: [eventChangeEventChangeEvent;ChangeEvent;Payload of the change event; flows OUT for API submission/reconcile.: ChangeEventinterface ChangeEventinterfaceChangeEventinterfaceChangeEventPayload of the change event; flows OUT for API submission/reconcile.API reference →];
ready: [eventGridReadyEventGridReadyEvent;GridReadyEvent;Grid handle, generation, and reason published after adapter initialization.: GridReadyEventinterface GridReadyEventinterfaceGridReadyEventinterfaceGridReadyEventGrid handle, generation, and reason published after adapter initialization.API reference →];
}>();
consthandleGridChangeconst handleGridChange: (event: ChangeEvent) => voidconsthandleGridChange: (event:ChangeEvent) =>voidconsthandleGridChange: (event:ChangeEvent,) =>void= (event:ChangeEventinterface ChangeEventinterfaceChangeEventinterfaceChangeEventPayload of the change event; flows OUT for API submission/reconcile.API reference →) =>emitconst emit: (evt: "gridChange", event: ChangeEvent) => void (+1 overload)constemit: (evt:"gridChange", event:ChangeEvent) =>void (+1overload)constemit: (evt:"gridChange", event:ChangeEvent) =>void (+1overload)("gridChange", event);
<Sheetwriteconst Sheetwrite: SheetwriteComponentConstructor<SheetwriteProps, SheetwriteGridEmits, object>constSheetwrite:SheetwriteComponentConstructor<SheetwriteProps,SheetwriteGridEmits,object>constSheetwrite:SheetwriteComponentConstructor<SheetwriteProps,SheetwriteGridEmits,object>Convenience component for local object rows with live option updates.API reference →
:columnsSheetwriteProps.columns: readonly SimpleColumn<Record<string, CellScalar>>[]interfaceSheetwriteProps {columns:readonlySimpleColumn<Record<string, CellScalar>>[];}interfaceSheetwriteProps {columns:readonlySimpleColumn<Record<string, CellScalar>>[];}Ordered schema used to derive the component-owned sheet.="columnsconst columns: readonly SimpleColumn<Record<string, CellScalar>>[]constcolumns:readonlySimpleColumn<Record<string, CellScalar>>[]constcolumns:readonlySimpleColumn<Record<string, CellScalar>>[]Restrict to these column indices (defaults to all columns).API reference →"