@4399ywkf/editor 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{DocView-MZKHSN67.js → DocView-4MOGGX4Z.js} +4 -3
  2. package/dist/DocView-4MOGGX4Z.js.map +1 -0
  3. package/dist/SheetView-WP4DKSDS.js +3 -0
  4. package/dist/{SheetView-6Z5EPBN4.js.map → SheetView-WP4DKSDS.js.map} +1 -1
  5. package/dist/base-model.d.ts +499 -0
  6. package/dist/base-model.js +3 -0
  7. package/dist/base-model.js.map +1 -0
  8. package/dist/base.d.ts +910 -0
  9. package/dist/base.js +12971 -0
  10. package/dist/base.js.map +1 -0
  11. package/dist/chunk-3BRBH7MU.js +1833 -0
  12. package/dist/chunk-3BRBH7MU.js.map +1 -0
  13. package/dist/chunk-3KW24N3T.js +2256 -0
  14. package/dist/chunk-3KW24N3T.js.map +1 -0
  15. package/dist/{chunk-FMTC3EDQ.js → chunk-4SIP4BYI.js} +3 -3
  16. package/dist/{chunk-FMTC3EDQ.js.map → chunk-4SIP4BYI.js.map} +1 -1
  17. package/dist/{chunk-IKYVPJQ5.js → chunk-KZEURCGO.js} +9874 -10466
  18. package/dist/chunk-KZEURCGO.js.map +1 -0
  19. package/dist/{chunk-OBKIMG6G.js → chunk-X4BUO2RH.js} +4 -4
  20. package/dist/{chunk-OBKIMG6G.js.map → chunk-X4BUO2RH.js.map} +1 -1
  21. package/dist/csv.js +1 -1
  22. package/dist/doc-standalone.js +11860 -10205
  23. package/dist/doc-standalone.js.map +1 -1
  24. package/dist/doc.d.ts +4 -379
  25. package/dist/doc.js +3 -2
  26. package/dist/doc.js.map +1 -1
  27. package/dist/editor-config-context-DvLRd7Gx.d.ts +382 -0
  28. package/dist/{import-XL3AH3QH.js → import-TEZ37G5R.js} +5 -5
  29. package/dist/{import-XL3AH3QH.js.map → import-TEZ37G5R.js.map} +1 -1
  30. package/dist/index.js +2 -2
  31. package/dist/sheet.js +1 -1
  32. package/dist/style.css +2 -2
  33. package/dist/xlsx.js +4 -4
  34. package/package.json +10 -2
  35. package/dist/DocView-MZKHSN67.js.map +0 -1
  36. package/dist/SheetView-6Z5EPBN4.js +0 -3
  37. package/dist/chunk-IKYVPJQ5.js.map +0 -1
package/dist/base.d.ts ADDED
@@ -0,0 +1,910 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties, ForwardRefRenderFunction } from 'react';
3
+ import * as Y from 'yjs';
4
+ import { E as EditorVisualTheme } from './editor-config-context-DvLRd7Gx.js';
5
+ export { a as EditorConfig, b as EditorConfigProvider, c as EditorConfigProviderProps, d as EditorMentionConfig, e as EditorUploadConfig, f as EditorUserConfig, M as MentionUser, u as useEditorConfig } from './editor-config-context-DvLRd7Gx.js';
6
+
7
+ interface IGridTheme {
8
+ staticWhite: string;
9
+ staticBlack: string;
10
+ iconBgCommon: string;
11
+ iconFgCommon: string;
12
+ iconFgHighlight: string;
13
+ iconBgHighlight: string;
14
+ iconBgSelected: string;
15
+ iconFgSelected: string;
16
+ iconSizeXS: number;
17
+ iconSizeSM: number;
18
+ iconSizeMD: number;
19
+ iconSizeLG: number;
20
+ fontSizeXXS: number;
21
+ fontSizeXS: number;
22
+ fontSizeSM: number;
23
+ fontSizeMD: number;
24
+ fontSizeLG: number;
25
+ fontFamily: string;
26
+ cellBg: string;
27
+ cellBgHovered: string;
28
+ cellBgSelected: string;
29
+ cellBgLoading: string;
30
+ cellLineColor: string;
31
+ cellLineColorActived: string;
32
+ cellTextColor: string;
33
+ cellTextColorHighlight: string;
34
+ cellOptionBg: string;
35
+ cellOptionBgHighlight: string;
36
+ cellOptionTextColor: string;
37
+ groupHeaderBgPrimary: string;
38
+ groupHeaderBgSecondary: string;
39
+ groupHeaderBgTertiary: string;
40
+ columnHeaderBg: string;
41
+ columnHeaderBgHovered: string;
42
+ columnHeaderBgSelected: string;
43
+ columnHeaderNameColor: string;
44
+ columnResizeHandlerBg: string;
45
+ columnDraggingPlaceholderBg: string;
46
+ columnStatisticBgHoveredPrimary: string;
47
+ columnStatisticBgHoveredSecondary: string;
48
+ columnStatisticBgHoveredTertiary: string;
49
+ rowHeaderTextColor: string;
50
+ appendRowBg: string;
51
+ appendRowBgHovered: string;
52
+ avatarBg: string;
53
+ avatarTextColor: string;
54
+ avatarSizeXS: number;
55
+ avatarSizeSM: number;
56
+ avatarSizeMD: number;
57
+ themeKey: string;
58
+ scrollBarBg: string;
59
+ interactionLineColorCommon: string;
60
+ interactionLineColorHighlight: string;
61
+ searchCursorBg: string;
62
+ searchTargetIndexBg: string;
63
+ searchTargetIndexSelectedBg: string;
64
+ commentCountBg: string;
65
+ commentCountTextColor: string;
66
+ }
67
+ /**
68
+ * 默认主题:取飞书多维表格的配色与尺寸(UD 令牌的浅色值)。宿主可以按编辑器主题整体或局部覆盖。
69
+ */
70
+ declare const gridTheme: IGridTheme;
71
+
72
+ interface IButtonFieldCellValue {
73
+ count: number;
74
+ }
75
+ interface IButtonFieldOptions {
76
+ label: string;
77
+ /** 色板名,见 compat/select-color.ts 的 BUTTON_COLORS */
78
+ color: string;
79
+ maxCount?: number | null;
80
+ /** 点击前的确认配置,原样透传给点击回调 */
81
+ confirm?: unknown;
82
+ resetCount?: boolean;
83
+ }
84
+
85
+ interface IUrlMatch {
86
+ start: number;
87
+ end: number;
88
+ url: string;
89
+ }
90
+
91
+ interface IGlobalImageManager {
92
+ setWindow(newWindow: IRectangle, freezeCols: number): void;
93
+ loadOrGetImage(url: string, col: number, row: number): HTMLImageElement | ImageBitmap | undefined;
94
+ /** Whether loading `url` has failed, as opposed to still being in flight. */
95
+ hasFailed(url: string): boolean;
96
+ setCallback(imageLoaded: (locations: ICellItem[]) => void): void;
97
+ }
98
+ declare class ImageManager implements IGlobalImageManager {
99
+ private imageLoaded;
100
+ private loadedLocations;
101
+ private visibleWindow;
102
+ private freezeColumnCount;
103
+ private readonly isInWindow;
104
+ private cache;
105
+ setCallback(imageLoaded: (locations: ICellItem[]) => void): void;
106
+ private readonly sendLoaded;
107
+ private readonly clearOutOfWindow;
108
+ setWindow(newWindow: IRectangle, freezeColumnCount: number): void;
109
+ private loadImage;
110
+ hasFailed(url: string): boolean;
111
+ loadOrGetImage(url: string, col: number, row: number): HTMLImageElement | ImageBitmap | undefined;
112
+ }
113
+
114
+ declare class CombinedSelection {
115
+ type: SelectionRegionType;
116
+ ranges: IRange[];
117
+ constructor(type?: SelectionRegionType, ranges?: IRange[]);
118
+ get isColumnSelection(): boolean;
119
+ get isRowSelection(): boolean;
120
+ get isCellSelection(): boolean;
121
+ get isNoneSelection(): boolean;
122
+ reset(): CombinedSelection;
123
+ set(type: SelectionRegionType, ranges: IRange[]): CombinedSelection;
124
+ setRanges(ranges: IRange[]): CombinedSelection;
125
+ private isOverlap;
126
+ expand(range: IRange): CombinedSelection;
127
+ merge(range: IRange): CombinedSelection;
128
+ flatten(): number[];
129
+ serialize(): IRange[];
130
+ includes(range?: IRange): boolean;
131
+ equals(comparisonRanges: IRange[]): boolean;
132
+ }
133
+
134
+ declare const GRID_DEFAULT: {
135
+ rowHeight: number;
136
+ rowHeadWidth: number;
137
+ rowHeadIconPaddingTop: number;
138
+ appendRowHeight: number;
139
+ groupHeaderHeight: number;
140
+ maxRowCount: number;
141
+ columnWidth: number;
142
+ columnHeadHeight: number;
143
+ columnHeadMenuSize: number;
144
+ columnHeadMenuClickableSize: number;
145
+ columnHeadPadding: number;
146
+ columnAppendBtnWidth: number;
147
+ columnResizeHandlerWidth: number;
148
+ columnResizeHandlerPaddingTop: number;
149
+ columnFreezeHandlerWidth: number;
150
+ columnFreezeHandlerHeight: number;
151
+ cellHorizontalPadding: number;
152
+ cellVerticalPaddingXS: number;
153
+ cellVerticalPaddingSM: number;
154
+ cellVerticalPaddingMD: number;
155
+ cellVerticalPaddingLG: number;
156
+ cellTextLineHeight: number;
157
+ fillHandlerSize: number;
158
+ fillHandlerPadding: number;
159
+ columnStatisticHeight: number;
160
+ minColumnStatisticWidth: number;
161
+ scrollBuffer: number;
162
+ cellScrollBuffer: number;
163
+ cellScrollBarWidth: number;
164
+ cellScrollBarMinHeight: number;
165
+ cellScrollBarPaddingX: number;
166
+ cellScrollBarPaddingY: number;
167
+ cellEditorEdgePadding: number;
168
+ };
169
+
170
+ interface ISpriteProps {
171
+ fgColor: string;
172
+ bgColor: string;
173
+ }
174
+ declare enum GridInnerIcon {
175
+ Add = "add",
176
+ Drag = "drag",
177
+ Detail = "detail",
178
+ Description = "description",
179
+ Close = "close",
180
+ Expand = "expand",
181
+ Collapse = "collapse",
182
+ Lock = "lock",
183
+ EyeOff = "eyeOff"
184
+ }
185
+
186
+ type ISprite = (props: ISpriteProps) => string;
187
+ type ISpriteMap = Record<string | GridInnerIcon, ISprite>;
188
+ type ISpriteVariant = "normal" | "selected";
189
+ interface ISpriteDrawerProps {
190
+ x: number;
191
+ y: number;
192
+ sprite: GridInnerIcon | string;
193
+ size: number;
194
+ theme: IGridTheme;
195
+ colors?: [fgColor: string, bgColor: string];
196
+ variant?: ISpriteVariant;
197
+ alpha?: number;
198
+ }
199
+ declare class SpriteManager {
200
+ private readonly onSettled?;
201
+ private readonly spriteMap;
202
+ private readonly icons;
203
+ private inFlight;
204
+ constructor(icons?: ISpriteMap, onSettled?: (() => void) | undefined);
205
+ drawSprite(ctx: CanvasRenderingContext2D, props: ISpriteDrawerProps): void;
206
+ }
207
+
208
+ interface IGridExternalProps {
209
+ theme?: Partial<IGridTheme>;
210
+ customIcons?: ISpriteMap;
211
+ rowControls?: IRowControlItem[];
212
+ rowControlPaddingX?: number;
213
+ smoothScrollX?: boolean;
214
+ smoothScrollY?: boolean;
215
+ scrollBufferX?: number;
216
+ scrollBufferY?: number;
217
+ scrollBarVisible?: boolean;
218
+ rowIndexVisible?: boolean;
219
+ collaborators?: ICollaborator;
220
+ searchCursor?: [number, number] | null;
221
+ searchHitIndex?: {
222
+ fieldId: string;
223
+ recordId: string;
224
+ }[];
225
+ highlightedRowIndex?: number | null;
226
+ /**
227
+ * Indicates which areas can be dragged, including rows, columns or no drag
228
+ * - 'all': Allow drag of rows, columns and cells (default)
229
+ * - 'none': Disable drag for all areas
230
+ * - 'row': Allow row drag only
231
+ * - 'column': Allow column drag only
232
+ */
233
+ draggable?: DraggableType;
234
+ /**
235
+ * Indicates which areas can be selected, including row selection,
236
+ * column selection, cell selection, all areas, or no selection
237
+ * - 'all': Allow selection of rows, columns and cells (default)
238
+ * - 'none': Disable selection for all areas
239
+ * - 'row': Allow row selection only
240
+ * - 'column': Allow column selection only
241
+ * - 'cell': Allow cell selection only
242
+ */
243
+ selectable?: SelectableType;
244
+ /**
245
+ * Whether to allow multiple selection operations, including rows, columns and cells
246
+ * If true, allow multiple selection of rows/columns/cells (default)
247
+ * If false, disable multiple selection operations
248
+ * @type {boolean}
249
+ */
250
+ isMultiSelectionEnable?: boolean;
251
+ isRowClickSelectionEnabled?: boolean;
252
+ /**
253
+ * Keep the cursor on the active cell after Enter instead of moving to the next
254
+ * row, so the caller can follow a record that re-positions on edit.
255
+ */
256
+ disableEnterMoveDown?: boolean;
257
+ groupCollection?: IGroupCollection | null;
258
+ collapsedGroupIds?: Set<string> | null;
259
+ groupPoints?: IGroupPoint[] | null;
260
+ onUndo?: () => void;
261
+ onRedo?: () => void;
262
+ onCopy?: (selection: CombinedSelection, e: React.ClipboardEvent) => void;
263
+ onPaste?: (selection: CombinedSelection, e: React.ClipboardEvent) => void;
264
+ onDelete?: (selection: CombinedSelection) => void;
265
+ onCellEdited?: (cell: ICellItem, newValue: IInnerCell) => void;
266
+ onCellDblClick?: (cell: ICellItem) => void;
267
+ onSelectionChanged?: (selection: CombinedSelection) => void;
268
+ onVisibleRegionChanged?: (rect: IRectangle) => void;
269
+ onCollapsedGroupChanged?: (collapsedGroupIds: Set<string>) => void;
270
+ onColumnFreeze?: (freezeColumnCount: number) => void;
271
+ onColumnFreezeFailed?: () => void;
272
+ onColumnAppend?: () => void;
273
+ onRowExpand?: (rowIndex: number) => void;
274
+ onRowAppend?: (targetIndex?: number) => void;
275
+ onRowOrdered?: (dragRowIndexCollection: number[], dropRowIndex: number) => void;
276
+ onColumnOrdered?: (dragColIndexCollection: number[], dropColIndex: number) => void;
277
+ onColumnResize?: (column: IGridColumn, newSize: number, colIndex: number) => void;
278
+ onColumnHeaderClick?: (colIndex: number, bounds: IRectangle) => void;
279
+ onColumnHeaderDblClick?: (colIndex: number, bounds: IRectangle) => void;
280
+ onColumnHeaderMenuClick?: (colIndex: number, bounds: IRectangle) => void;
281
+ onColumnStatisticClick?: (colIndex: number, bounds: IRectangle) => void;
282
+ onContextMenu?: (selection: CombinedSelection, position: IPosition) => void;
283
+ onGroupHeaderContextMenu?: (groupId: string, position: IPosition) => void;
284
+ onScrollChanged?: (scrollLeft: number, scrollTop: number) => void;
285
+ onDragStart?: (type: DragRegionType, dragIndexs: number[]) => void;
286
+ /**
287
+ * Triggered when the mouse hovers over the every type of region
288
+ */
289
+ onItemHovered?: (type: RegionType, bounds: IRectangle, cellItem: ICellItem, data?: unknown) => void;
290
+ /**
291
+ * Triggered when the mouse clicks the every type of region
292
+ */
293
+ onItemClick?: (type: RegionType, bounds: IRectangle, cellItem: ICellItem) => void;
294
+ /**
295
+ * Triggered when user drags the fill handle downward to auto-fill cells
296
+ * Only vertical fill is supported. Provides current selection ranges and the target end real row index
297
+ */
298
+ onFillSelection?: (selectionRanges: [IRange, IRange], targetEndRealRowIndex: number) => void;
299
+ /**
300
+ * Triggered when user clicks a row control (checkbox, expand, drag)
301
+ * For checkbox: checked indicates the state after click (true = selected, false = deselected)
302
+ */
303
+ onRowControlClick?: (rowIndex: number, type: RowControlType, checked: boolean) => void;
304
+ /**
305
+ * Triggered when user shift+clicks to select a range of rows
306
+ * Provides the row ranges selected (can be used to fetch recordIds via API)
307
+ */
308
+ onRowRangeSelected?: (ranges: IRange[]) => void;
309
+ }
310
+ interface IGridProps extends IGridExternalProps {
311
+ columns: IGridColumn[];
312
+ commentCountMap?: Record<string, number>;
313
+ freezeColumnCount?: number;
314
+ rowCount: number;
315
+ rowHeight?: number;
316
+ style?: CSSProperties;
317
+ columnHeaderHeight?: number;
318
+ columnStatistics?: IColumnStatistics;
319
+ getCellContent: (cell: ICellItem) => ICell;
320
+ }
321
+ interface IGridRef {
322
+ resetState: () => void;
323
+ forceUpdate: () => void;
324
+ getActiveCell: () => ICellItem | null;
325
+ getRowOffset: (rowIndex: number) => number;
326
+ setSelection: (selection: CombinedSelection) => void;
327
+ getScrollState: () => IScrollState;
328
+ scrollBy: (deltaX: number, deltaY: number) => void;
329
+ scrollTo: (scrollLeft?: number, scrollTop?: number) => void;
330
+ scrollToItem: (position: [columnIndex: number, rowIndex: number]) => void;
331
+ setActiveCell: (cell: ICellItem | null) => void;
332
+ getCellIndicesAtPosition: (x: number, y: number) => ICellItem | null;
333
+ getContainer: () => HTMLDivElement | null;
334
+ getCellBounds: (cell: ICellItem) => IRectangle | null;
335
+ getFreezeColumnState: () => {
336
+ effectiveFreezeColumnCount: number;
337
+ maxFreezeColumnCount: number;
338
+ };
339
+ setCellLoading: (cells: ICellItem[]) => void;
340
+ setColumnLoadings: (columnLoadings: IColumnLoading[]) => void;
341
+ setCellErrors: (cellErrors: ICellError[]) => void;
342
+ isEditing: () => boolean | undefined;
343
+ }
344
+ declare const Grid: react.ForwardRefExoticComponent<IGridProps & react.RefAttributes<IGridRef>>;
345
+
346
+ interface IEditorRef<T extends IInnerCell = IInnerCell> {
347
+ focus?: () => void;
348
+ setValue?: (data: T["data"]) => void;
349
+ saveValue?: () => void;
350
+ }
351
+ interface IEditorProps<T extends IInnerCell = IInnerCell> {
352
+ cell: T;
353
+ rect: IRectangle & {
354
+ editorId: string;
355
+ };
356
+ theme: IGridTheme;
357
+ style?: CSSProperties;
358
+ isEditing?: boolean;
359
+ isScrolling?: boolean;
360
+ initialSearch?: string;
361
+ setEditing?: React.Dispatch<React.SetStateAction<boolean>>;
362
+ onChange?: (value: unknown) => void;
363
+ }
364
+
365
+ /** 按钮单元格的点击回调(原 Teable 的 IButtonClickStatusHook) */
366
+ interface IButtonClickStatusHook {
367
+ checkLoading?: (fieldId: string, recordId: string) => boolean;
368
+ buttonClick: (params: {
369
+ tableId: string;
370
+ recordId: string;
371
+ fieldId: string;
372
+ name: string;
373
+ confirm?: unknown;
374
+ record?: unknown;
375
+ }) => void;
376
+ }
377
+ /** 按钮单元格透传给回调的记录(原 Teable 的 Record 模型) */
378
+ type IRecord = unknown;
379
+ declare enum CellType {
380
+ Text = "Text",
381
+ Link = "Link",
382
+ Number = "Number",
383
+ Select = "Select",
384
+ Image = "Image",
385
+ Chart = "Chart",
386
+ Rating = "Rating",
387
+ User = "User",
388
+ Boolean = "Boolean",
389
+ Loading = "Loading",
390
+ Button = "Button"
391
+ }
392
+ declare enum EditorType {
393
+ Text = "Text",
394
+ Number = "Number",
395
+ Select = "Select",
396
+ Custom = "Custom"
397
+ }
398
+ type ICustomEditor = ForwardRefRenderFunction<IEditorRef, IEditorProps>;
399
+ interface IBaseCell {
400
+ id?: string;
401
+ readonly?: boolean;
402
+ cursor?: CSSProperties["cursor"];
403
+ contentAlign?: "left" | "right" | "center";
404
+ lastUpdated?: string;
405
+ customTheme?: Partial<IGridTheme>;
406
+ locked?: boolean;
407
+ hidden?: boolean;
408
+ }
409
+ interface IEditableCell extends IBaseCell {
410
+ editorWidth?: number;
411
+ customEditor?: ICustomEditor;
412
+ readonlyCustomEditor?: boolean;
413
+ }
414
+ interface ILoadingCell extends IBaseCell {
415
+ type: CellType.Loading;
416
+ }
417
+ interface ITextCell extends IEditableCell {
418
+ type: CellType.Text;
419
+ data: string;
420
+ displayData: string;
421
+ isWrap?: boolean;
422
+ links?: IUrlMatch[];
423
+ onLinkClick?: (url: string) => void;
424
+ }
425
+ interface ILinkCell extends IEditableCell {
426
+ type: CellType.Link;
427
+ data: string[];
428
+ displayData: string;
429
+ onClick?: (value: string) => void;
430
+ }
431
+ declare enum NumberDisplayType {
432
+ Ring = "ring",
433
+ Bar = "bar"
434
+ }
435
+ interface INumberShowAs {
436
+ type: NumberDisplayType;
437
+ color: string;
438
+ maxValue: number;
439
+ showValue: boolean;
440
+ }
441
+ interface INumberCell extends IEditableCell {
442
+ type: CellType.Number;
443
+ data: number | null | undefined;
444
+ displayData: string | string[];
445
+ showAs?: INumberShowAs;
446
+ }
447
+ declare enum ChartType {
448
+ Bar = "bar",
449
+ Line = "line"
450
+ }
451
+ interface IChartCell extends IEditableCell {
452
+ type: CellType.Chart;
453
+ data: number[];
454
+ displayData: string[];
455
+ chartType?: ChartType;
456
+ color?: string;
457
+ }
458
+ interface IBooleanCell extends IEditableCell {
459
+ type: CellType.Boolean;
460
+ data: boolean;
461
+ isMultiple?: boolean;
462
+ }
463
+ interface IRatingCell extends IEditableCell {
464
+ type: CellType.Rating;
465
+ data: number;
466
+ icon: string;
467
+ color: string;
468
+ max: number;
469
+ }
470
+ interface ISelectChoice {
471
+ id: string;
472
+ name: string;
473
+ color?: string;
474
+ backgroundColor?: string;
475
+ }
476
+ interface ISelectChoiceSorted {
477
+ id: string;
478
+ name: string;
479
+ [key: string]: unknown;
480
+ }
481
+ interface ISelectCell extends IEditableCell {
482
+ type: CellType.Select;
483
+ data: (string | {
484
+ title: string;
485
+ id: string;
486
+ })[];
487
+ displayData: string[];
488
+ choiceMap?: Record<string, ISelectChoice>;
489
+ choiceSorted?: ISelectChoiceSorted[];
490
+ isMultiple?: boolean;
491
+ isEditingOnClick?: boolean;
492
+ showAddButton?: boolean;
493
+ onPreview?: (activeId: string) => void;
494
+ }
495
+ interface IImageData {
496
+ id: string;
497
+ url: string;
498
+ /** Drawn in place of `url` once loading it has failed. */
499
+ fallbackUrl?: string;
500
+ width?: number;
501
+ height?: number;
502
+ }
503
+ interface IImageCell extends IEditableCell {
504
+ type: CellType.Image;
505
+ data: IImageData[];
506
+ displayData: string[];
507
+ onPreview?: (activeId: string) => void;
508
+ }
509
+ interface IUserData {
510
+ id: string;
511
+ name: string;
512
+ email?: string;
513
+ avatarUrl?: string;
514
+ isSystem?: boolean;
515
+ }
516
+ interface IUserCell extends IEditableCell {
517
+ type: CellType.User;
518
+ data: IUserData[];
519
+ displayData?: string;
520
+ }
521
+ interface IButtonCell extends IEditableCell {
522
+ type: CellType.Button;
523
+ data: {
524
+ cellValue: IButtonFieldCellValue;
525
+ fieldOptions: IButtonFieldOptions;
526
+ tableId: string;
527
+ statusHook?: IButtonClickStatusHook;
528
+ record?: IRecord;
529
+ };
530
+ }
531
+ type IInnerCell = ITextCell | ILinkCell | INumberCell | ISelectCell | IImageCell | IRatingCell | IBooleanCell | IChartCell | IUserCell | IButtonCell;
532
+ type ICell = IInnerCell | ILoadingCell;
533
+ type ICellRenderProps = {
534
+ ctx: CanvasRenderingContext2D;
535
+ theme: IGridTheme;
536
+ rect: IRectangle;
537
+ rowIndex: number;
538
+ columnIndex: number;
539
+ imageManager: ImageManager;
540
+ spriteManager: SpriteManager;
541
+ hoverCellPosition?: ICellPosition | null;
542
+ isActive?: boolean;
543
+ };
544
+ interface ICellClickProps {
545
+ width: number;
546
+ height: number;
547
+ theme: IGridTheme;
548
+ isActive: boolean;
549
+ activeCellBound: IActiveCellBound | null;
550
+ hoverCellPosition: ICellPosition;
551
+ }
552
+ interface ICellMeasureProps {
553
+ ctx: CanvasRenderingContext2D;
554
+ theme: IGridTheme;
555
+ width: number;
556
+ height: number;
557
+ }
558
+ interface ICellMeasureResult {
559
+ width: number;
560
+ height: number;
561
+ totalHeight: number;
562
+ }
563
+ declare enum CellRegionType {
564
+ Blank = "blank",
565
+ Update = "update",
566
+ Preview = "preview",
567
+ ToggleEditing = "toggleEditing",
568
+ Hover = "hover"
569
+ }
570
+ interface ICellRegionWithBlank {
571
+ type: CellRegionType.Blank;
572
+ }
573
+ interface ICellRegionWithData {
574
+ type: CellRegionType.Update | CellRegionType.ToggleEditing | CellRegionType.Preview | CellRegionType.Blank | CellRegionType.Hover;
575
+ data: unknown;
576
+ }
577
+ type ICellRegion = ICellRegionWithData | ICellRegionWithBlank;
578
+ type ICellClickCallback = (cellRegion: ICellRegionWithData) => void;
579
+ interface IBaseCellRenderer<T extends ICell> {
580
+ type: T["type"];
581
+ draw: (cell: T, props: ICellRenderProps) => void;
582
+ needsHover?: boolean;
583
+ needsHoverPosition?: boolean | ((cell: T) => boolean);
584
+ needsHoverWhenActive?: boolean;
585
+ needsHoverPositionWhenActive?: boolean;
586
+ measure?: (cell: T, props: ICellMeasureProps) => ICellMeasureResult;
587
+ checkRegion?: (cell: T, props: ICellClickProps, shouldCalculate?: boolean) => ICellRegion;
588
+ onClick?: (cell: T, props: ICellClickProps, callback: ICellClickCallback) => void;
589
+ provideEditor?: IProvideEditorCallback<T>;
590
+ }
591
+ type IProvideEditorCallback<T extends ICell> = (cell: T) => void;
592
+ interface IInternalCellRenderer<T extends ICell> extends IBaseCellRenderer<T> {
593
+ getAccessibilityString?: (cell: T) => string;
594
+ onPaste?: (val: string, cell: T) => T | undefined;
595
+ }
596
+
597
+ /** 协作者信息(原 Teable 的 IUser,表格只用到这几项) */
598
+ interface IUser {
599
+ id: string;
600
+ name: string;
601
+ email?: string;
602
+ avatar?: string | null;
603
+ phone?: string;
604
+ }
605
+
606
+ interface IScrollState {
607
+ scrollTop: number;
608
+ scrollLeft: number;
609
+ isScrolling: boolean;
610
+ }
611
+ interface IPosition {
612
+ x: number;
613
+ y: number;
614
+ }
615
+ interface IRegionPosition extends IPosition {
616
+ rowIndex: number;
617
+ columnIndex: number;
618
+ }
619
+ interface IRectangle {
620
+ x: number;
621
+ y: number;
622
+ width: number;
623
+ height: number;
624
+ }
625
+ declare enum SelectionRegionType {
626
+ Rows = "Rows",
627
+ Columns = "Columns",
628
+ Cells = "Cells",
629
+ None = "None"
630
+ }
631
+ declare enum RegionType {
632
+ Cell = "Cell",
633
+ ActiveCell = "ActiveCell",
634
+ CellValue = "CellValue",
635
+ AppendRow = "AppendRow",
636
+ AppendColumn = "AppendColumn",
637
+ ColumnHeader = "ColumnHeader",
638
+ GroupStatistic = "GroupStatistic",
639
+ ColumnStatistic = "ColumnStatistic",
640
+ ColumnHeaderMenu = "ColumnHeaderMenu",
641
+ ColumnPrimaryIcon = "ColumnPrimaryIcon",
642
+ ColumnIcon = "ColumnIcon",
643
+ ColumnDescription = "ColumnDescription",
644
+ ColumnResizeHandler = "ColumnResizeHandler",
645
+ ColumnFreezeHandler = "ColumnFreezeHandler",
646
+ RowHeaderDragHandler = "RowHeaderDragHandler",
647
+ RowHeaderExpandHandler = "RowHeaderExpandHandler",
648
+ RowHeaderCheckbox = "RowHeaderCheckbox",
649
+ RowGroupControl = "RowGroupControl",
650
+ RowGroupHeader = "RowGroupHeader",
651
+ RowCountLabel = "RowCountLabel",
652
+ RowHeader = "RowHeader",
653
+ AllCheckbox = "AllCheckbox",
654
+ FillHandler = "FillHandler",
655
+ Blank = "Blank",
656
+ None = "None"
657
+ }
658
+ type ICellRange = [colIndex: number, rowIndex: number];
659
+ type IColumnRange = [colStartIndex: number, colEndIndex: number];
660
+ type IRowRange = [rowStartIndex: number, rowEndIndex: number];
661
+ type IRange = ICellRange | IColumnRange | IRowRange;
662
+ interface IMouseState extends IRegionPosition {
663
+ type: RegionType;
664
+ isOutOfBounds: boolean;
665
+ }
666
+ interface IColumnStatistics {
667
+ [columnId: string]: IColumnStatistic | null;
668
+ }
669
+ interface IColumnStatistic {
670
+ total: string;
671
+ [key: string]: string;
672
+ }
673
+ interface IGridColumn {
674
+ id?: string;
675
+ name: string;
676
+ icon?: string;
677
+ width?: number;
678
+ hasMenu?: boolean;
679
+ readonly?: boolean;
680
+ isPrimary?: boolean;
681
+ description?: string;
682
+ statisticLabel?: {
683
+ showAlways: boolean;
684
+ label: string;
685
+ };
686
+ customTheme?: Partial<IGridTheme>;
687
+ }
688
+ interface IColumnResizeState {
689
+ columnIndex: number;
690
+ width: number;
691
+ x: number;
692
+ }
693
+ interface IColumnFreezeState {
694
+ sourceIndex: number;
695
+ targetIndex: number;
696
+ isFreezing: boolean;
697
+ }
698
+ interface IDragState {
699
+ type: DragRegionType;
700
+ delta: number;
701
+ ranges: IRange[];
702
+ isDragging: boolean;
703
+ }
704
+ declare enum DragRegionType {
705
+ Rows = "Rows",
706
+ Columns = "Columns",
707
+ None = "None"
708
+ }
709
+ type IScrollDirection = -1 | 0 | 1;
710
+ declare enum MouseButtonType {
711
+ Left = 0,
712
+ Center = 1,
713
+ Right = 2
714
+ }
715
+ declare enum RowControlType {
716
+ Spacer = "Spacer",
717
+ Drag = "Drag",
718
+ Expand = "Expand",
719
+ Checkbox = "Checkbox"
720
+ }
721
+ interface IRowControlItem {
722
+ type: RowControlType;
723
+ icon?: string;
724
+ }
725
+ type ICellItem = [colIndex: number, rowIndex: number];
726
+ type ICollaborator = {
727
+ activeCell?: ICellItem;
728
+ activeCellId: [recordId: string, field: string];
729
+ user: Omit<IUser, "phone">;
730
+ borderColor: string;
731
+ timeStamp: number;
732
+ }[];
733
+ type ICellPosition = [x: number, y: number];
734
+ interface IPositionWithBounds {
735
+ bounds: IRectangle;
736
+ eventPosition: IPosition;
737
+ }
738
+ declare enum DraggableType {
739
+ All = "all",
740
+ None = "none",
741
+ Column = "column",
742
+ Row = "row"
743
+ }
744
+ declare enum GridCustomIcon {
745
+ Description = "description"
746
+ }
747
+ declare enum SelectableType {
748
+ All = "all",
749
+ None = "none",
750
+ Column = "column",
751
+ Row = "row",
752
+ Cell = "cell"
753
+ }
754
+ interface IActiveCellBound {
755
+ rowIndex: number;
756
+ columnIndex: number;
757
+ width: number;
758
+ height: number;
759
+ totalHeight: number;
760
+ scrollTop: number;
761
+ scrollEnable: boolean;
762
+ }
763
+ declare enum LinearRowType {
764
+ Group = 0,
765
+ Row = 1,
766
+ Append = 2
767
+ }
768
+ interface IGroupHeaderPoint {
769
+ id: string;
770
+ type: LinearRowType.Group;
771
+ depth: number;
772
+ value?: unknown;
773
+ isCollapsed?: boolean;
774
+ }
775
+ interface IGroupRowPoint {
776
+ type: LinearRowType.Row;
777
+ count: number;
778
+ }
779
+ interface IGroupAddButtonPoint {
780
+ type: LinearRowType.Append;
781
+ }
782
+ type IGroupPoint = IGroupHeaderPoint | IGroupRowPoint | IGroupAddButtonPoint;
783
+ type ILinearRow = {
784
+ type: LinearRowType.Row;
785
+ displayIndex: number;
786
+ realIndex: number;
787
+ } | {
788
+ id: string;
789
+ type: LinearRowType.Group;
790
+ value: unknown;
791
+ depth: number;
792
+ realIndex: number;
793
+ isCollapsed: boolean;
794
+ } | {
795
+ type: LinearRowType.Append;
796
+ value: unknown;
797
+ realIndex: number;
798
+ };
799
+ interface IGroupCollection {
800
+ groupColumns: IGridColumn[];
801
+ getGroupCell: (cellValue: unknown, depth: number) => ICell;
802
+ }
803
+ interface IColumnLoading {
804
+ index: number;
805
+ progress: number;
806
+ onCancel?: () => void;
807
+ }
808
+ interface ICellError {
809
+ cellItem: ICellItem;
810
+ errorMsg: string;
811
+ onRetry?: () => void;
812
+ onDismiss?: () => void;
813
+ }
814
+
815
+ /** 视口坐标里的矩形(弹出菜单、面板按它定位) */
816
+ interface BaseGridAnchor {
817
+ x: number;
818
+ y: number;
819
+ width: number;
820
+ height: number;
821
+ }
822
+ interface BaseGridViewProps {
823
+ doc: Y.Doc;
824
+ tableId: string;
825
+ viewId: string;
826
+ readOnly?: boolean;
827
+ /** 本端写操作的 origin,撤销只撤它;默认每个组件实例一个 */
828
+ origin?: unknown;
829
+ /** 其他协作者正在看的格子(来自 awareness) */
830
+ collaborators?: ICollaborator;
831
+ onActiveCellChange?: (cell: {
832
+ recordId: string;
833
+ fieldId: string;
834
+ } | null) => void;
835
+ style?: CSSProperties;
836
+ /** 记录详情里打开的那条,表格上高亮这一行 */
837
+ highlightedRecordId?: string | null;
838
+ /** 行首的展开按钮、空格键:打开记录详情 */
839
+ onExpandRecord?: (recordId: string) => void;
840
+ /** 表头的下拉箭头、表头右键:字段菜单。fieldIds 是选中的列,第一个是点的那列 */
841
+ onFieldMenu?: (fieldIds: string[], anchor: BaseGridAnchor) => void;
842
+ /** 表头末尾的「+」:新增字段;不给时直接加一个文本字段 */
843
+ onAddField?: (anchor: BaseGridAnchor) => void;
844
+ /** 统计栏的某一格:选统计方式 */
845
+ onStatClick?: (fieldId: string, anchor: BaseGridAnchor) => void;
846
+ /** 单元格、行号右键:记录菜单 */
847
+ onRecordMenu?: (recordIds: string[], anchor: BaseGridAnchor) => void;
848
+ /** 轻提示:复制了几条记录、粘贴超出上限等 */
849
+ onNotice?: (message: string) => void;
850
+ /** 搜索:关键字与当前定位到第几个结果 */
851
+ search?: {
852
+ query: string;
853
+ index: number;
854
+ } | null;
855
+ /** 搜索结果数变了 */
856
+ onSearchResult?: (count: number) => void;
857
+ }
858
+ interface BaseGridViewHandle {
859
+ /** 滚到某条记录(并选中它的第一格) */
860
+ scrollToRecord: (recordId: string) => void;
861
+ /** 撤销 / 重做(工具栏按钮用) */
862
+ undo: () => void;
863
+ redo: () => void;
864
+ }
865
+ /** 行高四档(飞书:低 / 中等 / 高 / 超高) */
866
+ declare const ROW_HEIGHTS: {
867
+ readonly 1: 32;
868
+ readonly 2: 54;
869
+ readonly 3: 88;
870
+ readonly 4: 124;
871
+ };
872
+ declare const BaseGridView: react.ForwardRefExoticComponent<BaseGridViewProps & react.RefAttributes<BaseGridViewHandle>>;
873
+
874
+ interface BaseThemeStyleProps {
875
+ /** 视觉风格,默认飞书 */
876
+ visualTheme?: EditorVisualTheme;
877
+ }
878
+ /**
879
+ * 多维表格只注入主题变量和表格自己的样式,不像 EditorThemeStyle 那样把整套文档编辑器样式带进来。
880
+ * 宿主页面已经有 EditorThemeStyle 时也可以不挂它(表格样式已登记在 COMPONENT_STYLES 里)。
881
+ */
882
+ declare function BaseThemeStyle({ visualTheme }: BaseThemeStyleProps): react.JSX.Element;
883
+
884
+ interface BaseViewProps {
885
+ doc: Y.Doc;
886
+ readOnly?: boolean;
887
+ /** 其他协作者正在看的格子(来自 awareness) */
888
+ collaborators?: ICollaborator;
889
+ /** 本端选中的格子变了(宿主拿去发 awareness) */
890
+ onActiveCellChange?: (cell: {
891
+ tableId: string;
892
+ recordId: string;
893
+ fieldId: string;
894
+ } | null) => void;
895
+ /** 默认打开的数据表 / 视图;不给时开第一个 */
896
+ initialTableId?: string;
897
+ initialViewId?: string;
898
+ /** 切换数据表 / 视图(宿主可以写进地址栏) */
899
+ onNavigate?: (target: {
900
+ tableId: string;
901
+ viewId: string;
902
+ }) => void;
903
+ /** 本端写操作的 origin,撤销只撤它 */
904
+ origin?: unknown;
905
+ style?: CSSProperties;
906
+ className?: string;
907
+ }
908
+ declare function BaseView({ doc, readOnly, collaborators, onActiveCellChange, initialTableId, initialViewId, onNavigate, origin: originProp, style, className, }: BaseViewProps): react.JSX.Element;
909
+
910
+ export { Grid as BaseGrid, type BaseGridAnchor, BaseGridView, type BaseGridViewHandle, type BaseGridViewProps, BaseThemeStyle, type BaseThemeStyleProps, BaseView, type BaseViewProps, CellRegionType, CellType, ChartType, DragRegionType, DraggableType, EditorType, GRID_DEFAULT, GridCustomIcon, type IActiveCellBound, type IBaseCell, type IBaseCellRenderer, type IBooleanCell, type IButtonCell, type IButtonClickStatusHook, type ICell, type ICellClickCallback, type ICellClickProps, type ICellError, type ICellItem, type ICellMeasureProps, type ICellMeasureResult, type ICellPosition, type ICellRange, type ICellRegion, type ICellRegionWithBlank, type ICellRegionWithData, type ICellRenderProps, type IChartCell, type ICollaborator, type IColumnFreezeState, type IColumnLoading, type IColumnRange, type IColumnResizeState, type IColumnStatistic, type IColumnStatistics, type ICustomEditor, type IDragState, type IEditableCell, type IGridColumn, type IGridExternalProps, type IGridProps, type IGridRef, type IGridTheme, type IGroupAddButtonPoint, type IGroupCollection, type IGroupHeaderPoint, type IGroupPoint, type IGroupRowPoint, type IImageCell, type IImageData, type IInnerCell, type IInternalCellRenderer, type ILinearRow, type ILinkCell, type ILoadingCell, type IMouseState, type INumberCell, type INumberShowAs, type IPosition, type IPositionWithBounds, type IProvideEditorCallback, type IRange, type IRatingCell, type IRecord, type IRectangle, type IRegionPosition, type IRowControlItem, type IRowRange, type IScrollDirection, type IScrollState, type ISelectCell, type ISelectChoice, type ISelectChoiceSorted, type ITextCell, type IUser, type IUserCell, type IUserData, LinearRowType, MouseButtonType, NumberDisplayType, ROW_HEIGHTS, RegionType, RowControlType, SelectableType, SelectionRegionType, gridTheme };