11<script lang="ts">
2- import { defineComponent , onMounted , onBeforeUnmount , ref , h as vueH , isRef , watch } from ' vue' ;
2+ import { defineComponent , onMounted , onBeforeUnmount , ref , h as vueH , watch } from ' vue' ;
33import {
44 GridSheet as PreactGridSheet ,
55 h as preactH ,
66 render as preactRender ,
77} from ' @gridsheet/preact-core' ;
8- import type { Ref } from ' vue' ;
98
10- import type {
11- CellsByAddressType ,
12- OptionsType ,
13- HubType ,
14- Connector ,
9+ import type {
10+ CellsByAddressType ,
11+ OptionsType ,
12+ BookType ,
13+ SheetHandle ,
14+ StoreHandle ,
1515} from ' @gridsheet/preact-core' ;
1616
1717interface RefObject <T > {
@@ -29,13 +29,17 @@ export default defineComponent({
2929 type: String ,
3030 default: ' ' ,
3131 },
32- hub : {
33- type: Object as () => HubType | Ref < HubType > ,
34- default: null ,
32+ book : {
33+ type: Object as () => BookType ,
34+ default: undefined ,
3535 },
36- connector: {
37- type: Object as () => RefObject <Connector | null >,
38- default: null ,
36+ sheetRef: {
37+ type: Object as () => RefObject <SheetHandle | null >,
38+ default: undefined ,
39+ },
40+ storeRef: {
41+ type: Object as () => RefObject <StoreHandle | null >,
42+ default: undefined ,
3943 },
4044 options: {
4145 type: Object as () => OptionsType ,
@@ -55,11 +59,15 @@ export default defineComponent({
5559 let root: HTMLElement | null = null ;
5660
5761 function getPreactProps() {
58- // Remove legacy tableRef, use connector instead
59- const { tableRef, ... rest } = props as any ;
6062 return {
61- ... rest ,
62- hub: isRef (props .hub ) ? (props .hub .value as HubType | undefined ) : (props .hub as HubType | undefined ),
63+ initialCells: props .initialCells ,
64+ sheetName: props .sheetName ,
65+ book: props .book ,
66+ sheetRef: props .sheetRef ,
67+ storeRef: props .storeRef ,
68+ options: props .options ,
69+ className: props .className ,
70+ style: props .style ,
6371 };
6472 }
6573
@@ -75,24 +83,16 @@ export default defineComponent({
7583
7684 onMounted (() => {
7785 renderPreact ();
78- if (isRef (props .hub )) {
79- watch (
80- () => (props .hub as Ref <HubType >).value ,
81- renderPreact ,
82- { deep: false }
83- );
84- } else {
85- watch (
86- () => props .hub ,
87- renderPreact ,
88- { deep: false }
89- );
90- }
86+ watch (
87+ () => props .book ,
88+ renderPreact ,
89+ { deep: false }
90+ );
9191 });
9292
9393 onBeforeUnmount (() => {
9494 if (root ) {
95- root . innerHTML = ' ' ;
95+ preactRender ( null , root ) ;
9696 }
9797 });
9898
@@ -101,8 +101,6 @@ export default defineComponent({
101101 };
102102 },
103103});
104-
105-
106104 </script >
107105
108106<template >
0 commit comments