@@ -2,7 +2,14 @@ import { useCallback, useEffect, useState } from "react";
2
2
import { CellProps , GridContextMenuItemProps , SelectedRegion , SelectionFocus } from ".." ;
3
3
import { Grid as CUIGrid } from "./Grid" ;
4
4
5
- const Cell : CellProps = ( { type, rowIndex, columnIndex, isScrolling, width, ...props } ) => {
5
+ const Cell : CellProps = ( {
6
+ type,
7
+ rowIndex,
8
+ columnIndex,
9
+ isScrolling,
10
+ width,
11
+ ...props
12
+ } ) => {
6
13
return (
7
14
< div
8
15
data-scrolling = { isScrolling }
@@ -123,109 +130,3 @@ export const Playground = {
123
130
} ,
124
131
} ,
125
132
} ;
126
-
127
- export const AutoHeightWithVariableData = {
128
- args : {
129
- rowCount : 10 ,
130
- columnCount : 5 ,
131
- rowAutoHeight : true ,
132
- rowStart : 0 ,
133
- } ,
134
- parameters : {
135
- docs : {
136
- source : {
137
- transform : ( _ : string , story : { args : Props ; [ x : string ] : unknown } ) => {
138
- const { rowCount, columnCount, rowAutoHeight, ...props } = story . args ;
139
- return `
140
- const VariableCell: CellProps = ({ type, rowIndex, columnIndex, isScrolling, width, ...props }) => {
141
- let content = \`Row \${rowIndex}, Col \${columnIndex}\${rowIndex % 2 === 0 ? '\\nExtra line' : ''}\`;
142
-
143
- if (rowIndex === 0 && columnIndex === 0) {
144
- content = \`CREATE TABLE random_user_events (
145
- user_id UInt32,
146
- event_time DateTime,
147
- event_type Enum8('click' = 1, 'view' = 2, 'purchase' = 3),
148
- item_id String,
149
- price Decimal(10,2),
150
- quantity UInt16
151
- ) ENGINE = MergeTree()
152
- ORDER BY (user_id, event_time)
153
- PARTITION BY toYYYYMM(event_time)
154
- SETTINGS index_granularity = 8192;\`;
155
- }
156
-
157
- return (
158
- <div
159
- data-scrolling={isScrolling}
160
- style={{
161
- whiteSpace: 'pre-wrap',
162
- padding: '8px',
163
- borderBottom: '1px solid #ccc',
164
- fontFamily: rowIndex === 0 && columnIndex === 0 ? 'monospace' : 'inherit',
165
- fontSize: rowIndex === 0 && columnIndex === 0 ? '12px' : 'inherit',
166
- }}
167
- {...props}
168
- >
169
- {content}
170
- </div>
171
- );
172
- };
173
-
174
- <Grid
175
- cell={VariableCell}
176
- focus={{ row: 0, column: 0 }}
177
- columnWidth={() => 300}
178
- rowAutoHeight={${ rowAutoHeight } }
179
- ${ Object . entries ( props )
180
- . flatMap ( ( [ key , value ] ) =>
181
- typeof value === "boolean"
182
- ? value
183
- ? ` ${ key } `
184
- : [ ]
185
- : ` ${ key } =${ typeof value == "string" ? `"${ value } "` : `{${ value } }` } `
186
- )
187
- . join ( "\n" ) }
188
- />
189
- ` ;
190
- } ,
191
- } ,
192
- } ,
193
- } ,
194
- render : ( args ) => {
195
- const VariableCell : CellProps = ( { type, rowIndex, columnIndex, isScrolling, width, ...props } ) => {
196
- let content = `Row ${ rowIndex } , Col ${ columnIndex } ${ rowIndex % 2 === 0 ? '\nExtra line' : '' } ` ;
197
-
198
- if ( rowIndex === 0 && columnIndex === 0 ) {
199
- content = `CREATE TABLE random_user_events (
200
- user_id UInt32,
201
- event_time DateTime,
202
- event_type Enum8('click' = 1, 'view' = 2, 'purchase' = 3),
203
- item_id String,
204
- price Decimal(10,2),
205
- quantity UInt16
206
- ) ENGINE = MergeTree()
207
- ORDER BY (user_id, event_time)
208
- PARTITION BY toYYYYMM(event_time)
209
- SETTINGS index_granularity = 8192;` ;
210
- }
211
-
212
- return (
213
- < div
214
- data-scrolling = { isScrolling }
215
- style = { {
216
- whiteSpace : 'pre-wrap' ,
217
- padding : '8px' ,
218
- borderBottom : '1px solid #ccc' ,
219
- fontFamily : rowIndex === 0 && columnIndex === 0 ? 'monospace' : 'inherit' ,
220
- fontSize : rowIndex === 0 && columnIndex === 0 ? '12px' : 'inherit' ,
221
- } }
222
- { ...props }
223
- >
224
- { content }
225
- </ div >
226
- ) ;
227
- } ;
228
-
229
- return < Grid { ...args } cell = { VariableCell } columnWidth = { ( ) => 300 } /> ;
230
- } ,
231
- } ;
0 commit comments