-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
437 lines (314 loc) · 11 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/// <reference types="react" />
import { ComponentProps } from 'react';
import { ComponentType } from 'react';
import { Context } from 'react';
import { ElementType } from 'react';
import { PropsWithChildren } from 'react';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
export declare type Accessor<D, C> = string | ((row: D) => C);
export declare function ArrayOutput<V>(props: ArrayOutputProps<V>): JSX.Element;
declare interface ArrayOutputOwnProps<V> {
value: ReadonlyArray<V>;
getKey?: (value: V, index: number) => string | number;
}
export declare type ArrayOutputProps<V> = PropsWithChildren<
ArrayOutputOwnProps<V>
>;
export declare function Cell<
C extends ComponentType = ComponentType,
A extends Accessor<any, any> = Accessor<any, any>,
>(props: CellProps<C, A>): JSX.Element;
declare interface CellOwnProps<
C extends ComponentType,
A extends Accessor<any, any>,
> {
accessor: A | null;
TdProps?: Partial<ComponentProps<C>>;
tdEl?: ReactElement;
}
export declare type CellProps<
C extends ComponentType,
A extends Accessor<any, any>,
> = PropsWithChildren<CellOwnProps<C, A>>;
export declare function Children(props: ChildrenProps): JSX.Element;
declare type ChildrenContextType = ReactNode;
declare interface ChildrenOwnProps {}
declare type ChildrenProps = ChildrenOwnProps;
export declare function ChildrenProvider(
props: ChildrenProviderProps,
): JSX.Element;
declare interface ChildrenProviderOwnProps {
value: ChildrenContextType;
}
declare type ChildrenProviderProps =
PropsWithChildren<ChildrenProviderOwnProps>;
export declare function Column<
C extends ComponentType = ComponentType,
H extends ComponentType = ComponentType,
A extends Accessor<any, any> = Accessor<any, any>,
>(props: ColumnProps<C, H, A>): JSX.Element;
declare interface ColumnOwnProps<
C extends ComponentType,
H extends ComponentType,
A extends Accessor<any, any>,
> {
header?: ReactNode;
accessor?: A | null;
TdProps?: Partial<ComponentProps<C>>;
ThProps?: Partial<ComponentProps<H>>;
tdEl?: ReactElement;
thEl?: ReactElement;
}
export declare type ColumnProps<
C extends ComponentType,
H extends ComponentType,
A extends Accessor<any, any>,
> = PropsWithChildren<ColumnOwnProps<C, H, A>>;
export declare function Columns(props: ColumnsProps): JSX.Element | null;
export declare namespace Columns {
var __COLUMNS__: boolean;
}
export declare const ColumnsContext: Context<ColumnsNode | undefined>;
export declare type ColumnsNode = ReactNode;
declare interface ColumnsOwnProps {
part?: string;
}
export declare type ColumnsProps = PropsWithChildren<ColumnsOwnProps>;
export declare function ColumnsProvider(
props: ColumnsProviderProps,
): JSX.Element;
declare interface ColumnsProviderOwnProps {
value: ColumnsNode;
}
export declare type ColumnsProviderProps =
PropsWithChildren<ColumnsProviderOwnProps>;
export declare interface ColumnsType<D extends object = {}> {
__COLUMNS__: true;
}
export declare type Content<V> = V;
export declare const ContentContext: Context<Content<any> | undefined>;
export declare function ContentProvider<V>(
props: ContentProviderProps<V>,
): JSX.Element;
declare interface ContentProviderOwnProps<V> {
value: Content<V>;
}
export declare type ContentProviderProps<V> = PropsWithChildren<
ContentProviderOwnProps<V>
>;
export declare function ContentValue<D, C>(
props: ContentValueProps<D, C>,
): JSX.Element;
declare interface ContentValueOwnProps<D, C> {
accessor: Accessor<D, C> | null;
}
export declare type ContentValueProps<D, C> = PropsWithChildren<
ContentValueOwnProps<D, C>
>;
export declare type CurrentValue<V> = V;
export declare const CurrentValueContext: Context<
CurrentValue<any> | undefined
>;
export declare function CurrentValueProvider<V>(
props: CurrentValueProviderProps<V>,
): JSX.Element;
export declare type CurrentValueProviderProps<V> = PropsWithChildren<
ItemProviderOwnProps<V>
>;
export declare type Data<D> = ReadonlyArray<D>;
export declare const DataContext: Context<Data<any> | undefined>;
export declare function DataProvider<D>(
props: DataProviderProps<D>,
): JSX.Element;
declare interface DataProviderOwnProps<D> {
value: Data<D>;
}
export declare type DataProviderProps<D> = PropsWithChildren<
DataProviderOwnProps<D>
>;
export declare function DataTable<D>(props: DataTableProps<D>): JSX.Element;
declare interface DataTableOwnProps<D> {
data?: ReadonlyArray<D>;
}
export declare type DataTableProps<D> = PropsWithChildren<DataTableOwnProps<D>>;
export declare function DefaultContent<D>(
props: DefaultContentProps<D>,
): JSX.Element;
declare interface DefaultContentOwnProps<D> {}
export declare type DefaultContentProps<D> = PropsWithChildren<
DefaultContentOwnProps<D>
>;
export declare const defaultTableComponents: TableComponents;
export declare function findColumns<D extends object = {}>(
children: ReactNode,
): ReactNode;
export declare function getValue<D, C>(data: D, accessor: null): null;
export declare function getValue<D, C>(data: D, accessor: Accessor<D, C>): C;
export declare function getValue<D, C>(
data: D,
accessor: Accessor<D, C> | null,
): C | null;
export declare function HeaderCell<C extends ComponentType = ComponentType>(
props: HeaderCellProps<C>,
): JSX.Element;
declare interface HeaderCellOwnProps<C extends ComponentType> {
ThProps?: Partial<ComponentProps<C>>;
thEl?: ReactElement;
}
export declare type HeaderCellProps<C extends ComponentType> =
PropsWithChildren<HeaderCellOwnProps<C>>;
export declare function HeaderRow<C extends ComponentType = ComponentType>(
props: HeaderRowProps<C>,
): JSX.Element;
declare interface HeaderRowOwnProps<C extends ComponentType> {
TrProps?: Partial<ComponentProps<C>>;
trEl?: ReactElement;
}
export declare type HeaderRowProps<C extends ComponentType> = PropsWithChildren<
HeaderRowOwnProps<C>
>;
export declare type Index = number;
export declare const IndexContext: Context<Index | undefined>;
export declare function IndexProvider(props: IndexProviderProps): JSX.Element;
declare interface IndexProviderOwnProps {
value: Index;
}
export declare type IndexProviderProps =
PropsWithChildren<IndexProviderOwnProps>;
export declare function isColumnsType<D extends object = {}>(
type: any,
): type is ColumnsType<D>;
declare interface ItemProviderOwnProps<V> {
value: CurrentValue<V>;
}
export declare function Row<D, C extends ComponentType = ComponentType>(
props: RowProps<D, C>,
): JSX.Element;
export declare type RowData<V> = V;
export declare const RowDataContext: Context<RowData<any> | undefined>;
export declare function RowDataProvider<V>(
props: RowDataProviderProps<V>,
): JSX.Element;
declare interface RowDataProviderOwnProps<V> {
value: RowData<V>;
}
export declare type RowDataProviderProps<V> = PropsWithChildren<
RowDataProviderOwnProps<V>
>;
declare interface RowOwnProps<D, C extends ComponentType> {
row?: D;
TrProps?: Partial<ComponentProps<C>>;
trEl?: ReactElement;
}
export declare type RowProps<D, C extends ComponentType> = PropsWithChildren<
RowOwnProps<D, C>
>;
export declare function Rows<D>(props: RowsProps<D>): JSX.Element;
declare interface RowsOwnProps<D> {
keyAccessor?: Accessor<D, string | number>;
data?: ReadonlyArray<D>;
}
export declare type RowsProps<D> = PropsWithChildren<RowsOwnProps<D>>;
export declare function Table<C extends ComponentType = ComponentType>(
props: TableProps<C>,
): JSX.Element;
export declare function TableBody<D, C extends ComponentType = ComponentType>(
props: TableBodyProps<D, C>,
): JSX.Element;
declare interface TableBodyOwnProps<D, C extends ComponentType> {
TbodyProps?: Partial<ComponentProps<C>>;
tbodyEl?: ReactElement;
}
export declare type TableBodyProps<
D,
C extends ComponentType,
> = PropsWithChildren<TableBodyOwnProps<D, C>>;
export declare interface TableComponents {
Table: ElementType;
Thead: ElementType;
Tbody: ElementType;
Tr: ElementType;
Th: ElementType;
Td: ElementType;
}
export declare const TableComponentsContext: Context<TableComponents>;
export declare function TableComponentsProvider(
props: TableComponentsProviderProps,
): JSX.Element;
declare interface TableComponentsProviderOwnProps {
value: TableComponents;
}
export declare type TableComponentsProviderProps =
PropsWithChildren<TableComponentsProviderOwnProps>;
declare interface TableElements {
table: ReactElement;
thead: ReactElement;
tbody: ReactElement;
tr: ReactElement;
th: ReactElement;
td: ReactElement;
}
export declare const TableElementsContext: Context<TableElements>;
export declare function TableElementsProvider(
props: TableElementsProviderProps,
): JSX.Element;
declare interface TableElementsProviderOwnProps {
value: TableElements;
}
declare type TableElementsProviderProps =
PropsWithChildren<TableElementsProviderOwnProps>;
export declare function TableHeader<C extends ComponentType = ComponentType>(
props: TableHeaderProps<C>,
): JSX.Element;
declare interface TableHeaderOwnProps<C extends ComponentType> {
TheadProps?: Partial<ComponentProps<C>>;
theadEl?: ReactElement;
}
export declare type TableHeaderProps<C extends ComponentType> =
PropsWithChildren<TableHeaderOwnProps<C>>;
declare interface TableOwnProps<C extends ComponentType> {
TableProps?: Partial<ComponentProps<C>>;
tableEl?: ReactElement;
}
export declare type TablePart = TablePartType;
export declare const TablePartContext: Context<TablePart | undefined>;
export declare function TablePartProvider(
props: TablePartProviderProps,
): JSX.Element;
declare interface TablePartProviderOwnProps {
value: TablePart;
}
export declare type TablePartProviderProps =
PropsWithChildren<TablePartProviderOwnProps>;
export declare type TablePartType = 'definition' | 'header' | 'body';
export declare type TableProps<C extends ComponentType> = PropsWithChildren<
TableOwnProps<C>
>;
export declare function useChildren(): ChildrenContextType;
export declare function UseColumns(props: UseColumnsProps): JSX.Element;
export declare function useColumns(): ColumnsNode;
declare interface UseColumnsOwnProps {
part?: string;
}
export declare type UseColumnsProps = PropsWithChildren<UseColumnsOwnProps>;
export declare function useContent<V>(): Content<V>;
export declare function useContentValue<D, C>(accessor: null): null;
export declare function useContentValue<D, C>(accessor: Accessor<D, C>): C;
export declare function useContentValue<D, C>(
accessor: Accessor<D, C> | null,
): C | null;
export declare function useCurrentValue<V>(value?: V): CurrentValue<V>;
export declare function useData<D>(value?: ReadonlyArray<D>): Data<D>;
export declare function useIndex(): Index;
export declare function useRowData<V>(): RowData<V>;
export declare function useTableComponents(): TableComponents;
export declare function useTableElements(): TableElements;
export declare function useTablePart(): TablePart;
export declare function withDefaultChildren<
TProps extends {
children?: ReactNode;
},
C extends ComponentType<TProps> | keyof JSX.IntrinsicElements,
>(Cmp: C): ComponentType<ComponentProps<C>>;
export {};