New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@glideapps/glide-data-grid

Package Overview
Dependencies
Maintainers
8
Versions
294
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glideapps/glide-data-grid - npm Package Compare versions

Comparing version 5.1.0-alpha2 to 5.1.0-alpha3

5

dist/ts/common/styles.d.ts
import React from "react";
/** @category Theme */
export declare function makeCSSStyle(theme: Theme): Record<string, string>;
/** @category Theme */
export interface Theme {

@@ -37,4 +39,7 @@ accentColor: string;

}
/** @category Theme */
export declare function getDataEditorTheme(): Theme;
/** @category Theme */
export declare const ThemeContext: React.Context<Theme>;
/** @category Hooks */
export declare function useTheme(): Theme;

2

dist/ts/common/utils.d.ts

@@ -14,2 +14,2 @@ import * as React from "react";

export declare function getScrollBarWidth(): number;
export declare function useStateWithReactiveInput<T>(inputState: T): [T, React.Dispatch<React.SetStateAction<T>>, {}];
export declare function useStateWithReactiveInput<T>(inputState: T): [T, React.Dispatch<React.SetStateAction<T>>, () => void];
import * as React from "react";
import { EditableGridCell, GridCell, GridSelection, Rectangle, ProvideEditorCallback, DrawCustomCellCallback, GridColumn, GroupHeaderClickedEventArgs, HeaderClickedEventArgs, CellClickedEventArgs, Item, ValidatedGridCell } from "../data-grid/data-grid-types";
import { EditableGridCell, GridCell, GridSelection, Rectangle, ProvideEditorCallback, DrawCustomCellCallback, GridColumn, GroupHeaderClickedEventArgs, HeaderClickedEventArgs, CellClickedEventArgs, Item, ValidatedGridCell, ImageEditorType } from "../data-grid/data-grid-types";
import { DataGridSearchProps } from "../data-grid-search/data-grid-search";
import type { OverlayImageEditorProps } from "../data-grid-overlay-editor/private/image-overlay-editor";
import { Theme } from "../common/styles";

@@ -10,3 +9,2 @@ import type { DataGridRef } from "../data-grid/data-grid";

declare type Props = Omit<DataGridSearchProps, "accessibilityHeight" | "canvasRef" | "cellXOffset" | "cellYOffset" | "className" | "clientSize" | "columns" | "disabledRows" | "drawCustomCell" | "enableGroups" | "firstColAccessible" | "firstColSticky" | "freezeColumns" | "getCellContent" | "getCellRenderer" | "getCellsForSelection" | "gridRef" | "groupHeaderHeight" | "headerHeight" | "isFilling" | "isFocused" | "lockColumns" | "maxColumnWidth" | "minColumnWidth" | "onCanvasBlur" | "onCanvasFocused" | "onCellFocused" | "onContextMenu" | "onDragEnd" | "onMouseDown" | "onMouseMove" | "onMouseUp" | "onSearchResultsChanged" | "onVisibleRegionChanged" | "rowHeight" | "scrollRef" | "searchColOffset" | "selectedColumns" | "selection" | "theme" | "trailingRowType" | "translateX" | "translateY" | "verticalBorder">;
declare type ImageEditorType = React.ComponentType<OverlayImageEditorProps>;
declare type EditListItem = {

@@ -16,3 +14,2 @@ location: Item;

};
declare type ReplaceReturnType<T extends (...a: any) => any, TNewReturn> = (...a: Parameters<T>) => TNewReturn;
declare type EmitEvents = "copy" | "paste" | "delete" | "fill-right" | "fill-down";

@@ -34,66 +31,354 @@ interface Keybinds {

}
/**
* @category DataEditor
*/
export interface DataEditorProps extends Props {
/** Emitted whenever the user has requested the deletion of the selection.
* @group Editing
*/
readonly onDelete?: (selection: GridSelection) => boolean | GridSelection;
/** Emitted whenever a cell edit is completed.
* @group Editing
*/
readonly onCellEdited?: (cell: Item, newValue: EditableGridCell) => void;
/** Emitted whenever a cell mutation is completed and provides all edits inbound as a single batch.
* @group Editing
*/
readonly onCellsEdited?: (newValues: readonly EditListItem[]) => boolean | void;
/** Emitted whenever a row append operation is requested. Append location can be set in callback.
* @group Editing
*/
readonly onRowAppended?: () => Promise<"top" | "bottom" | number | undefined> | void;
/** Emitted when a column header should show a context menu. Usually right click.
* @group Events
*/
readonly onHeaderClicked?: (colIndex: number, event: HeaderClickedEventArgs) => void;
/** Emitted when a group header is clicked.
* @group Events
*/
readonly onGroupHeaderClicked?: (colIndex: number, event: GroupHeaderClickedEventArgs) => void;
/** Emitted whe the user wishes to rename a group.
* @group Events
*/
readonly onGroupHeaderRenamed?: (groupName: string, newVal: string) => void;
/** Emitted when a cell is clicked.
* @group Events
*/
readonly onCellClicked?: (cell: Item, event: CellClickedEventArgs) => void;
/** Emitted when a cell is activated, by pressing Enter, Space or double clicking it.
* @group Events
*/
readonly onCellActivated?: (cell: Item) => void;
/** Emitted when editing has finished, regardless of data changing or not.
* @group Editing
*/
readonly onFinishedEditing?: (newValue: GridCell | undefined, movement: Item) => void;
/** Emitted when a column header should show a context menu. Usually right click.
* @group Events
*/
readonly onHeaderContextMenu?: (colIndex: number, event: HeaderClickedEventArgs) => void;
/** Emitted when a group header should show a context menu. Usually right click.
* @group Events
*/
readonly onGroupHeaderContextMenu?: (colIndex: number, event: GroupHeaderClickedEventArgs) => void;
/** Emitted when a cell should show a context menu. Usually right click.
* @group Events
*/
readonly onCellContextMenu?: (cell: Item, event: CellClickedEventArgs) => void;
/** Used for validating cell values during editing.
* @group Editing
* @param cell The cell which is being validated.
* @param newValue The new value being proposed.
* @param prevValue The previous value before the edit.
* @returns A return of false indicates the value will not be accepted. A value of
* true indicates the value will be accepted. Returning a new GridCell will immediately coerce the value to match.
*/
readonly validateCell?: (cell: Item, newValue: EditableGridCell, prevValue: GridCell) => boolean | ValidatedGridCell;
/** The columns to display in the data grid.
* @group Data
*/
readonly columns: readonly GridColumn[];
/** Controls the trailing row used to insert new data into the grid.
* @group Editing
*/
readonly trailingRowOptions?: {
/** If the trailing row should be tinted */
readonly tint?: boolean;
/** A hint string displayed on hover. Usually something like "New row" */
readonly hint?: string;
/** When set to true, the trailing row is always visible. */
readonly sticky?: boolean;
/** The icon to use for the cell. Either a GridColumnIcon or a member of the passed headerIcons */
readonly addIcon?: string;
/** Overrides the column to focus when a new row is created. */
readonly targetColumn?: number | GridColumn;
};
/** Controls the height of the header row
* @defaultValue 36
* @group Style
*/
readonly headerHeight?: number;
/** Controls the header of the group header row
* @defaultValue `headerHeight`
* @group Style
*/
readonly groupHeaderHeight?: number;
/** Determins if row markers should be automatically added to the grid.
* @defaultValue `none`
* @group Style
*/
readonly rowMarkers?: "checkbox" | "number" | "clickable-number" | "both" | "none";
/**
* Sets the width of row markers in pixels, if unset row markers will automatically size.
* @group Style
*/
readonly rowMarkerWidth?: number;
/** Changes the starting index for row markers.
* @defaultValue 1
* @group Style
*/
readonly rowMarkerStartIndex?: number;
/** Sets the width of the data grid.
* @group Style
*/
readonly width?: number | string;
/** Sets the height of the data grid.
* @group Style
*/
readonly height?: number | string;
/** Custom classname for data grid wrapper.
* @group Style
*/
readonly className?: string;
/** If set to `default`, `gridSelection` will be coerced to always include full spans.
* @group Selection
* @defaultValue `default`
*/
readonly spanRangeBehavior?: "default" | "allowPartial";
/** Controls which types of selections can exist at the same time in the grid. If selection blending is set to
* exclusive, the grid will clear other types of selections when the exclusive selection is made. By default row,
* column, and range selections are exclusive.
* @group Selection
* @defaultValue `exclusive`
* */
readonly rangeSelectionBlending?: SelectionBlending;
/** {@inheritDoc rangeSelectionBlending}
* @group Selection
*/
readonly columnSelectionBlending?: SelectionBlending;
/** {@inheritDoc rangeSelectionBlending}
* @group Selection
*/
readonly rowSelectionBlending?: SelectionBlending;
/** Controls if multi-selection is allowed. If disabled, shift/ctrl/command clicking will work as if no modifiers
* are pressed.
*
* When range select is set to cell, only one cell may be selected at a time. When set to rect one one rect at a
* time. The multi variants allow for multiples of the rect or cell to be selected.
* @group Selection
* @defaultValue `rect`
*/
readonly rangeSelect?: "none" | "cell" | "rect" | "multi-cell" | "multi-rect";
/** {@inheritDoc rangeSelect}
* @group Selection
* @defaultValue `multi`
*/
readonly columnSelect?: "none" | "single" | "multi";
/** {@inheritDoc rangeSelect}
* @group Selection
* @defaultValue `multi`
*/
readonly rowSelect?: "none" | "single" | "multi";
/** Sets the initial scroll Y offset.
* @see {@link scrollOffsetX}
* @group Advanced
*/
readonly scrollOffsetY?: number;
/** Sets the initial scroll X offset
* @see {@link scrollOffsetY}
* @group Advanced
*/
readonly scrollOffsetX?: number;
/** Determins the height of each row.
* @group Style
* @defaultValue 34
*/
readonly rowHeight?: DataGridSearchProps["rowHeight"];
/** Fires whenever the mouse moves
* @group Events
* @param args
*/
readonly onMouseMove?: DataGridSearchProps["onMouseMove"];
/**
* The minimum width a column can be resized to.
* @defaultValue 50
* @group Style
*/
readonly minColumnWidth?: DataGridSearchProps["minColumnWidth"];
/**
* The maximum width a column can be resized to.
* @defaultValue 500
* @group Style
*/
readonly maxColumnWidth?: DataGridSearchProps["maxColumnWidth"];
/**
* The maximum width a column can be automatically sized to.
* @defaultValue `maxColumnWidth`
* @group Style
*/
readonly maxColumnAutoWidth?: number;
/**
* Used to provide an override to the default image editor for the data grid. `provideEditor` may be a better
* choice for most people.
* @group Advanced
* */
readonly imageEditorOverride?: ImageEditorType;
/**
* If specified, it will be used to render Markdown, instead of the default Markdown renderer used by the Grid.
* You'll want to use this if you need to process your Markdown for security purposes, or if you want to use a
* renderer with different Markdown features.
* @group Advanced
*/
readonly markdownDivCreateNode?: (content: string) => DocumentFragment;
/** Callback for providing a custom editor for a cell.
* @group Editing
*/
readonly provideEditor?: ProvideEditorCallback<GridCell>;
/**
* Allows coercion of pasted values.
* @group Editing
* @param val The pasted value
* @param cell The cell being pasted into
* @returns `undefined` to accept default behavior or a `GridCell` which should be used to represent the pasted value.
*/
readonly coercePasteValue?: (val: string, cell: GridCell) => GridCell | undefined;
/**
* Emitted when the grid selection is cleared.
* @group Selection
*/
readonly onSelectionCleared?: () => void;
/**
* Callback used to override the rendering of any cell.
* @group Drawing
*/
readonly drawCell?: DrawCustomCellCallback;
/**
* The current selection of the data grid. Contains all selected cells, ranges, rows, and columns.
* @group Selection
*/
readonly gridSelection?: GridSelection;
/**
* Emitted whenever the grid selection changes.
* @param newSelection The new gridSelection as created by user input.
* @group Selection
*/
readonly onGridSelectionChange?: (newSelection: GridSelection) => void;
/**
* Emitted whenever the visible cells change, usually due to scrolling.
* @group Events
* @param range An inclusive range of all visible cells. May include cells obscured by UI elements such
* as headers.
* @param tx The x transform of the cell region.
* @param ty The y transform of the cell region.
* @param extras Contains information about the selected cell and
* any visible freeze columns.
*/
readonly onVisibleRegionChanged?: (range: Rectangle, tx?: number, ty?: number, extras?: {
/** The selected item if visible */
selected?: Item;
/** A selection of visible freeze columns */
freezeRegion?: Rectangle;
}) => void;
readonly getCellContent: ReplaceReturnType<DataGridSearchProps["getCellContent"], GridCell>;
/**
* The primary callback for getting cell data into the data grid.
* @group Data
* @param cell The location of the cell being requested.
* @returns A valid GridCell to be rendered by the Grid.
*/
readonly getCellContent: (cell: Item) => GridCell;
/**
* Determines if row selection requires a modifier key to enable multi-selection or not. In auto mode it adapts to
* touch or mouse environments automatically, in multi-mode it always acts as if the multi key (Ctrl) is pressed.
* @group Editing
* @defaultValue `auto`
*/
readonly rowSelectionMode?: "auto" | "multi";
/**
* Determins which keybindings are enabled.
* @group Editing
* @defaultValue is
{
selectAll: true,
selectRow: true,
selectColumn: true,
downFill: false,
rightFill: false,
pageUp: false,
pageDown: false,
clear: true,
copy: true,
paste: true,
search: false,
first: true,
last: true,
}
*/
readonly keybindings?: Partial<Keybinds>;
/**
* Used to fetch large amounts of cells at once. Used for copy/paste, if unset copy will not work.
*
* `getCellsForSelection` is called when the user copies a selection to the clipboard or the data editor needs to
* inspect data which may be outside the curently visible range. It must return a two-dimensional array (an array of
* rows, where each row is an array of cells) of the cells in the selection's rectangle. Note that the rectangle can
* include cells that are not currently visible.
*
* If `true` is passed instead of a callback, the data grid will internally use the `getCellContent` callback to
* provide a basic implementation of `getCellsForSelection`. This can make it easier to light up more data grid
* functionality, but may have negative side effects if your data source is not able to handle being queried for
* data outside the normal window.
*
* If `getCellsForSelection` returns a thunk, the data may be loaded asynchronously, however the data grid may be
* unable to properly react to column spans when performing range selections. Copying large amounts of data out of
* the grid will depend on the performance of the thunk as well.
* @group Data
* @param {Rectangle} selection The range of requested cells
* @param {AbortSignal} abortSignal A signal indicating the requested cells are no longer needed
* @returns A row-major collection of cells or an async thunk which returns a row-major collection.
*/
readonly getCellsForSelection?: DataGridSearchProps["getCellsForSelection"] | true;
/** The number of columns which should remain in place when scrolling horizontally. The row marker column, if
* enabled is always frozen and is not included in this count.
* @defaultValue 0
* @group Style
*/
readonly freezeColumns?: DataGridSearchProps["freezeColumns"];
/**
* Controls the drawing of the left hand vertical border of a column. If set to a boolean value it controls all
* borders.
* @defaultValue `true`
* @group Style
*/
readonly verticalBorder?: DataGridSearchProps["verticalBorder"] | boolean;
/**
* Called when data is pasted into the grid. If left undefined, the `DataEditor` will operate in a
* fallback mode and attempt to paste the text buffer into the current cell assuming the current cell is not
* readonly and can accept the data type. If `onPaste` is set to false or the function returns false, the grid will
* simply ignore paste. If `onPaste` evaluates to true the grid will attempt to split the data by tabs and newlines
* and paste into available cells.
*
* The grid will not attempt to add additional rows if more data is pasted then can fit. In that case it is
* advisable to simply return false from onPaste and handle the paste manually.
* @group Editing
*/
readonly onPaste?: ((target: Item, values: readonly (readonly string[])[]) => boolean) | boolean;
/**
* The theme used by the data grid to get all color and font information
* @group Style
*/
readonly theme?: Partial<Theme>;
/**
* An array of custom renderers which can be used to extend the data grid.
* @group Advanced
*/
readonly customRenderers?: readonly CustomRenderer[];

@@ -111,11 +396,37 @@ }

}) => void;
/** @category DataEditor */
export interface DataEditorRef {
/**
* Programatically appends a row.
* @param col The column index to focus in the new row.
* @returns A promise which waits for the append to complete.
*/
appendRow: (col: number) => Promise<void>;
/**
* Triggers cells to redraw.
*/
updateCells: DataGridRef["damage"];
/**
* Gets the screen space bounds of the requested item.
*/
getBounds: DataGridRef["getBounds"];
/**
* Triggers the data grid to focus itself or the correct accessibility element.
*/
focus: DataGridRef["focus"];
/**
* Generic API for emitting events as if they had been triggered via user interaction.
*/
emit: (eventName: EmitEvents) => Promise<void>;
/**
* Scrolls to the desired cell or location in the grid.
*/
scrollTo: ScrollToFn;
}
/**
* The primary component of Glide Data Grid.
* @category DataEditor
* @param {DataEditorProps} props
*/
export declare const DataEditor: React.ForwardRefExoticComponent<DataEditorProps & React.RefAttributes<DataEditorRef>>;
export {};

@@ -6,2 +6,3 @@ import type { Theme } from "../common/styles";

export declare function measureColumn(ctx: CanvasRenderingContext2D, theme: Theme, c: GridColumn, colIndex: number, selectedData: CellArray, minColumnWidth: number, maxColumnWidth: number, removeOutliers: boolean, getCellRenderer: GetCellRendererCallback): SizedGridColumn;
/** @category Hooks */
export declare function useColumnSizer(columns: readonly GridColumn[], rows: number, getCellsForSelection: DataGridSearchProps["getCellsForSelection"], clientWidth: number, minColumnWidth: number, maxColumnWidth: number, theme: Theme, getCellRenderer: GetCellRendererCallback, abortController: AbortController): readonly InnerGridColumn[];
import type { CustomRenderer } from "../data-grid/cells/cell-types";
import { CustomCell } from "../data-grid/data-grid-types";
import type { DataEditorProps } from "./data-editor";
/**
* @category Renderers
* @deprecated use CustomRenderer instead
*/
export declare type CustomCellRenderer<T extends CustomCell> = Omit<CustomRenderer<T>, "kind">;
/**
* @category Hooks
* @deprecated use customRenderers instead.

@@ -7,0 +12,0 @@ * @param cells

@@ -6,6 +6,42 @@ import * as React from "react";

export interface DataGridDndProps extends Props {
/**
* Called whenever a row re-order operation is completed. Setting the callback enables re-ordering by dragging the
* first column of a row.
* @group Drag and Drop
*/
readonly onRowMoved?: (startIndex: number, endIndex: number) => void;
/**
* Called when the user finishes moving a column. `startIndex` is the index of the column that was moved, and
* `endIndex` is the index at which it should end up. Note that you have to effect the move of the column, and pass
* the reordered columns back in the `columns` property.
* @group Drag and Drop
*/
readonly onColumnMoved?: (startIndex: number, endIndex: number) => void;
/**
* Called when the user is resizing a column. `newSize` is the new size of the column. Note that you have change
* the size of the column in the `GridColumn` and pass it back to the grid in the `columns` property.
* @group Drag and Drop
* @param column The `GridColumn` being resized
* @param newSize The new size of the grid column
* @param colIndex The index of the column
* @param newSizeWithGrow The new size of the column including any addition pixels added by the grow parameter
*/
readonly onColumnResize?: (column: GridColumn, newSize: number, colIndex: number, newSizeWithGrow: number) => void;
/**
* Called when the user starts resizing a column. `newSize` is the new size of the column.
* @group Drag and Drop
* @param column The `GridColumn` being resized
* @param newSize The new size of the grid column
* @param colIndex The index of the column
* @param newSizeWithGrow The new size of the column including any addition pixels added by the grow parameter
*/
readonly onColumnResizeStart?: (column: GridColumn, newSize: number, colIndex: number, newSizeWithGrow: number) => void;
/**
* Called when the user finishes resizing a column. `newSize` is the new size of the column.
* @group Drag and Drop
* @param column The `GridColumn` being resized
* @param newSize The new size of the grid column
* @param colIndex The index of the column
* @param newSizeWithGrow The new size of the column including any addition pixels added by the grow parameter
*/
readonly onColumnResizeEnd?: (column: GridColumn, newSize: number, colIndex: number, newSizeWithGrow: number) => void;

@@ -16,6 +52,4 @@ readonly gridRef?: React.MutableRefObject<DataGridRef | null>;

readonly lockColumns: number;
readonly smoothScrollX?: boolean;
readonly smoothScrollY?: boolean;
}
declare const DataGridDnd: React.FunctionComponent<DataGridDndProps>;
export default DataGridDnd;
import * as React from "react";
/** @category Types */
export interface OverlayImageEditorProps {

@@ -10,3 +11,3 @@ readonly urls: readonly string[];

}
declare const ImageOverlayEditor: React.FunctionComponent<OverlayImageEditorProps>;
export default ImageOverlayEditor;
/** @category Renderers */
export declare const ImageOverlayEditor: React.FunctionComponent<OverlayImageEditorProps>;

@@ -7,3 +7,11 @@ import * as React from "react";

readonly onSearchResultsChanged?: (results: readonly Item[], navIndex: number) => void;
/**
* Controls the visibility of the search overlay.
* @group Search
*/
readonly showSearch?: boolean;
/**
* Emitted when the search window close event is triggered.
* @group Search
*/
readonly onSearchClose?: () => void;

@@ -10,0 +18,0 @@ }

@@ -19,5 +19,7 @@ import type { Theme } from "../..";

}
/** @category Drawing */
export interface DrawArgs<T extends InnerGridCell> extends BaseDrawArgs {
cell: T;
}
/** @category Drawing */
export interface PrepResult {

@@ -29,5 +31,5 @@ font: string | undefined;

}
/** @category Renderers */
export declare type DrawCallback<T extends InnerGridCell> = (args: DrawArgs<T>, cell: T) => void;
declare type PrepCallback = (args: BaseDrawArgs, lastPrep?: PrepResult) => Partial<PrepResult>;
declare type DeprepCallback = (args: Pick<BaseDrawArgs, "ctx">) => void;
interface BaseCellRenderer<T extends InnerGridCell> {

@@ -37,3 +39,2 @@ readonly kind: T["kind"];

readonly drawPrep?: PrepCallback;
readonly drawDeprep?: DeprepCallback;
readonly needsHover?: boolean;

@@ -61,2 +62,3 @@ readonly needsHoverPosition?: boolean;

}
/** @category Renderers */
export interface InternalCellRenderer<T extends InnerGridCell> extends BaseCellRenderer<T> {

@@ -67,2 +69,3 @@ readonly useLabel?: boolean;

}
/** @category Renderers */
export interface CustomRenderer<T extends CustomCell = CustomCell> extends BaseCellRenderer<T> {

@@ -72,4 +75,6 @@ readonly isMatch: (cell: CustomCell) => cell is T;

}
/** @category Renderers */
export declare type CellRenderer<T extends InnerGridCell> = [T] extends [CustomCell<infer DataType>] ? CustomRenderer<CustomCell<DataType>> : InternalCellRenderer<T>;
/** @category Renderers */
export declare type GetCellRendererCallback = <T extends InnerGridCell>(cell: T) => CellRenderer<T> | undefined;
export {};

@@ -1,3 +0,8 @@

export declare function parseToRgba(color: string): [number, number, number, number];
/** @category Drawing */
export declare function parseToRgba(color: string): readonly [number, number, number, number];
/** @category Drawing */
export declare function withAlpha(color: string, alpha: number): string;
/** @category Drawing */
export declare function blend(color: string, background: string | undefined): string;
/** @category Drawing */
export declare function interpolateColors(leftColor: string, rightColor: string, val: number): string;
import type { Theme } from "../common/styles";
import { DrilldownCellData, Item, GridSelection, InnerGridCell, SizedGridColumn, Rectangle, BaseGridCell, BooleanEmpty, BooleanIndeterminate } from "./data-grid-types";
import type { BaseDrawArgs, PrepResult } from "./cells/cell-types";
import type { DrawArgs } from "../data-editor/custom-cell-draw-args";
export interface MappedGridColumn extends SizedGridColumn {

@@ -23,7 +22,12 @@ sourceIndex: number;

export declare function getRowIndexForY(targetY: number, height: number, hasGroups: boolean, headerHeight: number, groupHeaderHeight: number, rows: number, rowHeight: number | ((index: number) => number), cellYOffset: number, translateY: number, lastRowSticky: boolean): number | undefined;
/** @category Drawing */
export declare function measureTextCached(s: string, ctx: CanvasRenderingContext2D, font?: string): TextMetrics;
/** @category Drawing */
export declare function getMiddleCenterBias(ctx: CanvasRenderingContext2D, font: string | Theme): number;
/** @category Drawing */
export declare function drawWithLastUpdate(args: BaseDrawArgs, lastUpdate: number | undefined, frameTime: number, lastPrep: PrepResult | undefined, draw: () => void): boolean;
export declare function prepTextCell(args: BaseDrawArgs, lastPrep: PrepResult | undefined, overrideColor?: string): Partial<PrepResult>;
export declare function drawTextCellExternal(args: DrawArgs, data: string, contentAlign?: BaseGridCell["contentAlign"]): void;
/** @category Drawing */
export declare function drawTextCellExternal(args: BaseDrawArgs, data: string, contentAlign?: BaseGridCell["contentAlign"]): void;
/** @category Drawing */
export declare function drawTextCell(args: Pick<BaseDrawArgs, "rect" | "ctx" | "theme">, data: string, contentAlign?: BaseGridCell["contentAlign"], allowWrapping?: boolean, hyperWrapping?: boolean): void;

@@ -30,0 +34,0 @@ export declare function drawNewRowCell(args: BaseDrawArgs, data: string, icon?: string): void;

@@ -5,4 +5,7 @@ import type { Theme } from "../common/styles";

declare type Sprite = HeaderIconMap["headerArray"];
/** @category Columns */
export declare type SpriteMap = Record<string | HeaderIcon, Sprite>;
/** @category Columns */
export declare type SpriteVariant = "normal" | "selected" | "special";
/** @category Columns */
export declare class SpriteManager {

@@ -9,0 +12,0 @@ private onSettled;

@@ -6,2 +6,3 @@ import type { Theme } from "../common/styles";

import type { OverlayImageEditorProps } from "../data-grid-overlay-editor/private/image-overlay-editor";
/** @category Selection */
export interface GridSelection {

@@ -16,3 +17,5 @@ readonly current?: {

}
/** @category Types */
export declare type ImageEditorType = React.ComponentType<OverlayImageEditorProps>;
/** @category Types */
export declare type GridMouseEventArgs = GridMouseCellEventArgs | GridMouseHeaderEventArgs | GridMouseOutOfBoundsEventArgs | GridMouseGroupHeaderEventArgs;

@@ -22,8 +25,12 @@ interface PreventableEvent {

}
/** @category Types */
export interface CellClickedEventArgs extends GridMouseCellEventArgs, PreventableEvent {
}
/** @category Types */
export interface HeaderClickedEventArgs extends GridMouseHeaderEventArgs, PreventableEvent {
}
/** @category Types */
export interface GroupHeaderClickedEventArgs extends GridMouseGroupHeaderEventArgs, PreventableEvent {
}
/** @category Types */
export interface ImageWindowLoader {

@@ -34,5 +41,9 @@ setWindow(newWindow: Rectangle, freezeCols: number): void;

}
/** @category Types */
export declare const BooleanEmpty: null;
/** @category Types */
export declare const BooleanIndeterminate: undefined;
/** @category Types */
export declare type BooleanEmpty = null;
/** @category Types */
export declare type BooleanIndeterminate = undefined;

@@ -43,2 +54,3 @@ interface PositionableMouseEventArgs {

}
/** @category Types */
export interface BaseGridMouseEventArgs {

@@ -54,2 +66,3 @@ readonly shiftKey: boolean;

}
/** @category Types */
export interface GridMouseCellEventArgs extends BaseGridMouseEventArgs, PositionableMouseEventArgs {

@@ -61,5 +74,7 @@ readonly kind: "cell";

}
/** @category Types */
export declare const headerKind: "header";
/** @category Types */
export interface GridMouseHeaderEventArgs extends BaseGridMouseEventArgs, PositionableMouseEventArgs {
readonly kind: "header";
readonly kind: typeof headerKind;
readonly location: readonly [number, -1];

@@ -69,5 +84,7 @@ readonly bounds: Rectangle;

}
/** @category Types */
export declare const groupHeaderKind: "group-header";
/** @category Types */
export interface GridMouseGroupHeaderEventArgs extends BaseGridMouseEventArgs, PositionableMouseEventArgs {
readonly kind: "group-header";
readonly kind: typeof groupHeaderKind;
readonly location: readonly [number, -2];

@@ -77,8 +94,11 @@ readonly bounds: Rectangle;

}
/** @category Types */
export declare const outOfBoundsKind: "out-of-bounds";
/** @category Types */
export interface GridMouseOutOfBoundsEventArgs extends BaseGridMouseEventArgs {
readonly kind: "out-of-bounds";
readonly kind: typeof outOfBoundsKind;
readonly location: Item;
readonly direction: readonly [-1 | 0 | 1, -1 | 0 | 1];
}
/** @category Types */
export interface GridKeyEventArgs {

@@ -103,4 +123,7 @@ readonly bounds: Rectangle | undefined;

}
/** @category Types */
export declare type GridDragEventArgs = GridMouseEventArgs & DragHandler;
/** @category Types */
export declare type TrailingRowType = "sticky" | "appended" | "none";
/** @category Types */
export declare type DrawCustomCellCallback = (args: {

@@ -120,2 +143,3 @@ ctx: CanvasRenderingContext2D;

}) => boolean;
/** @category Types */
export declare type DrawHeaderCallback = (args: {

@@ -134,2 +158,3 @@ ctx: CanvasRenderingContext2D;

}) => boolean;
/** @category Cells */
export declare enum GridCellKind {

@@ -149,2 +174,3 @@ Uri = "uri",

}
/** @category Columns */
export declare enum GridColumnIcon {

@@ -180,7 +206,13 @@ HeaderRowID = "headerRowID",

}
/** @category Types */
export declare type CellArray = readonly (readonly GridCell[])[];
/** @category Types */
export declare type Item = readonly [col: number, row: number];
/** @category Types */
export declare const headerCellCheckboxPrefix = "___gdg_header_cell_";
/** @category Types */
export declare const headerCellCheckedMarker: string;
/** @category Types */
export declare const headerCellUnheckedMarker: string;
/** @category Types */
export declare const headerCellIndeterminateMarker: string;

@@ -204,3 +236,5 @@ interface BaseGridColumn {

}
/** @category Columns */
export declare function isSizedGridColumn(c: GridColumn): c is SizedGridColumn;
/** @category Columns */
export interface SizedGridColumn extends BaseGridColumn {

@@ -210,22 +244,38 @@ readonly width: number;

}
/** @category Columns */
export interface AutoGridColumn extends BaseGridColumn {
readonly id: string;
}
/** @category Types */
export declare function resolveCellsThunk(thunk: GetCellsThunk | CellArray): Promise<CellArray>;
/** @category Types */
export declare type GetCellsThunk = () => Promise<CellArray>;
/** @category Columns */
export declare type GridColumn = SizedGridColumn | AutoGridColumn;
/** @category Columns */
export declare type InnerGridColumn = SizedGridColumn & {
growOffset?: number;
};
/** @category Cells */
export declare type ReadWriteGridCell = TextCell | NumberCell | MarkdownCell | UriCell | CustomCell | BooleanCell;
/** @category Cells */
export declare type EditableGridCell = TextCell | ImageCell | BooleanCell | MarkdownCell | UriCell | NumberCell | CustomCell;
/** @category Cells */
export declare type EditableGridCellKind = EditableGridCell["kind"];
/** @category Cells */
export declare function isEditableGridCell(cell: GridCell): cell is ValidatedGridCell;
/** @category Cells */
export declare function isTextEditableGridCell(cell: GridCell): cell is ReadWriteGridCell;
/** @category Cells */
export declare function isInnerOnlyCell(cell: InnerGridCell): cell is InnerOnlyGridCell;
/** @category Cells */
export declare function isReadWriteCell(cell: GridCell): cell is ReadWriteGridCell;
/** @category Cells */
export declare type GridCell = EditableGridCell | BubbleCell | RowIDCell | LoadingCell | ProtectedCell | DrilldownCell | CustomCell;
declare type InnerOnlyGridCell = NewRowCell | MarkerCell;
/** @category Cells */
export declare type InnerGridCell = GridCell | InnerOnlyGridCell;
/** @category Cells */
export declare type CellList = readonly Item[];
/** @category Types */
export interface Rectangle {

@@ -237,2 +287,3 @@ x: number;

}
/** @category Cells */
export interface BaseGridCell {

@@ -247,8 +298,11 @@ readonly allowOverlay: boolean;

}
/** @category Cells */
export interface LoadingCell extends BaseGridCell {
readonly kind: GridCellKind.Loading;
}
/** @category Cells */
export interface ProtectedCell extends BaseGridCell {
readonly kind: GridCellKind.Protected;
}
/** @category Cells */
export interface TextCell extends BaseGridCell {

@@ -261,2 +315,3 @@ readonly kind: GridCellKind.Text;

}
/** @category Cells */
export interface NumberCell extends BaseGridCell {

@@ -268,2 +323,3 @@ readonly kind: GridCellKind.Number;

}
/** @category Cells */
export interface ImageCell extends BaseGridCell {

@@ -276,2 +332,3 @@ readonly kind: GridCellKind.Image;

}
/** @category Cells */
export interface BubbleCell extends BaseGridCell {

@@ -281,3 +338,5 @@ readonly kind: GridCellKind.Bubble;

}
/** @category Renderers */
export declare type SelectionRange = number | readonly [number, number];
/** @category Renderers */
export declare type ProvideEditorComponent<T extends InnerGridCell> = React.FunctionComponent<{

@@ -303,2 +362,3 @@ readonly onChange: (newValue: T) => void;

};
/** @category Renderers */
export declare type ProvideEditorCallbackResult<T extends InnerGridCell> = (ProvideEditorComponent<T> & {

@@ -308,7 +368,11 @@ disablePadding?: boolean;

}) | ObjectEditorCallbackResult<T> | undefined;
/** @category Renderers */
export declare function isObjectEditorCallbackResult<T extends InnerGridCell>(obj: ProvideEditorCallbackResult<T>): obj is ObjectEditorCallbackResult<T>;
/** @category Renderers */
export declare type ProvideEditorCallback<T extends InnerGridCell> = (cell: T) => ProvideEditorCallbackResult<T>;
/** @category Cells */
export declare type ValidatedGridCell = EditableGridCell & {
selectionRange?: SelectionRange;
};
/** @category Cells */
export interface CustomCell<T extends {} = {}> extends BaseGridCell {

@@ -320,2 +384,3 @@ readonly kind: GridCellKind.Custom;

}
/** @category Cells */
export interface DrilldownCellData {

@@ -325,2 +390,3 @@ readonly text: string;

}
/** @category Cells */
export interface DrilldownCell extends BaseGridCell {

@@ -330,2 +396,3 @@ readonly kind: GridCellKind.Drilldown;

}
/** @category Cells */
export interface BooleanCell extends BaseGridCell {

@@ -337,3 +404,5 @@ readonly kind: GridCellKind.Boolean;

}
/** @category Cells */
export declare function booleanCellIsEditable(cell: BooleanCell): boolean;
/** @category Cells */
export interface RowIDCell extends BaseGridCell {

@@ -344,2 +413,3 @@ readonly kind: GridCellKind.RowID;

}
/** @category Cells */
export interface MarkdownCell extends BaseGridCell {

@@ -350,2 +420,3 @@ readonly kind: GridCellKind.Markdown;

}
/** @category Cells */
export interface UriCell extends BaseGridCell {

@@ -356,2 +427,3 @@ readonly kind: GridCellKind.Uri;

}
/** @category Cells */
export declare enum InnerGridCellKind {

@@ -361,2 +433,3 @@ NewRow = "new-row",

}
/** @category Cells */
export interface NewRowCell extends BaseGridCell {

@@ -368,2 +441,3 @@ readonly kind: InnerGridCellKind.NewRow;

}
/** @category Cells */
export interface MarkerCell extends BaseGridCell {

@@ -377,4 +451,7 @@ readonly kind: InnerGridCellKind.Marker;

}
/** @category Selection */
export declare type Slice = [start: number, end: number];
/** @category Selection */
export declare type CompactSelectionRanges = readonly Slice[];
/** @category Selection */
export declare class CompactSelection {

@@ -381,0 +458,0 @@ private readonly items;

@@ -18,3 +18,11 @@ import * as React from "react";

readonly firstColAccessible: boolean;
/**
* Enables or disables the overlay shadow when scrolling horizontally
* @group Style
*/
readonly fixedShadowX?: boolean;
/**
* Enables or disables the overlay shadow when scrolling vertical
* @group Style
*/
readonly fixedShadowY?: boolean;

@@ -27,2 +35,6 @@ readonly allowResize?: boolean;

readonly columns: readonly InnerGridColumn[];
/**
* The number of rows in the grid.
* @group Data
*/
readonly rows: number;

@@ -37,11 +49,40 @@ readonly headerHeight: number;

readonly getCellContent: (cell: Item) => InnerGridCell;
/**
* Provides additional details about groups to extend group functionality.
* @group Data
*/
readonly getGroupDetails?: GroupDetailsCallback;
/**
* Provides per row theme overrides.
* @group Style
*/
readonly getRowThemeOverride?: GetRowThemeCallback;
/**
* Emitted when a header menu disclosure indicator is clicked.
* @group Events
*/
readonly onHeaderMenuClick?: (col: number, screenPosition: Rectangle) => void;
readonly selection: GridSelection;
readonly prelightCells?: readonly Item[];
/**
* Highlight regions provide hints to users about relations between cells and selections.
* @group Selection
*/
readonly highlightRegions?: readonly Highlight[];
/**
* Enabled/disables the fill handle.
* @defaultValue false
* @group Editing
*/
readonly fillHandle?: boolean;
readonly disabledRows?: CompactSelection;
/**
* Allows passing a custom image window loader.
* @group Advanced
*/
readonly imageWindowLoader?: ImageWindowLoader;
/**
* Emitted when an item is hovered.
* @group Events
*/
readonly onItemHovered?: (args: GridMouseEventArgs) => void;

@@ -56,13 +97,51 @@ readonly onMouseMove: (args: GridMouseEventArgs) => void;

readonly onMouseMoveRaw?: (event: MouseEvent) => void;
/**
* Emitted when the canvas receives a key down event.
* @group Events
*/
readonly onKeyDown?: (event: GridKeyEventArgs) => void;
/**
* Emitted when the canvas receives a key up event.
* @group Events
*/
readonly onKeyUp?: (event: GridKeyEventArgs) => void;
readonly verticalBorder: (col: number) => boolean;
/**
* Determines what can be dragged using HTML drag and drop
* @group Drag and Drop
*/
readonly isDraggable?: boolean | "cell" | "header";
/**
* If `isDraggable` is set, the grid becomes HTML draggable, and `onDragStart` will be called when dragging starts.
* You can use this to build a UI where the user can drag the Grid around.
* @group Drag and Drop
*/
readonly onDragStart?: (args: GridDragEventArgs) => void;
readonly onDragEnd?: () => void;
/** @group Drag and Drop */
readonly onDragOverCell?: (cell: Item, dataTransfer: DataTransfer | null) => void;
/** @group Drag and Drop */
readonly onDragLeave?: () => void;
/**
* Called when a HTML Drag and Drop event is ended on the data grid.
* @group Drag and Drop
*/
readonly onDrop?: (cell: Item, dataTransfer: DataTransfer | null) => void;
readonly drawCustomCell?: DrawCustomCellCallback;
/**
* Overrides the rendering of a header. The grid will call this for every header it needs to render. Header
* rendering is not as well optimized because they do not redraw as often, but very heavy drawing methods can
* negatively impact horizontal scrolling performance.
*
* It is possible to return `false` after rendering just a background and the regular foreground rendering
* will happen.
* @group Drawing
* @returns `false` if default header rendering should still happen, `true` to cancel rendering.
*/
readonly drawHeader?: DrawHeaderCallback;
/**
* Controls the drawing of the focus ring.
* @defaultValue true
* @group Style
*/
readonly drawFocusRing?: boolean;

@@ -73,2 +152,7 @@ readonly dragAndDropState?: {

};
/**
* Experimental features
* @group Advanced
* @experimental
*/
readonly experimental?: {

@@ -83,4 +167,28 @@ readonly paddingRight?: number;

};
/**
* Additional header icons for use by `GridColumn`.
*
* Providing custom header icons to the data grid must be done with a somewhat non-standard mechanism to allow
* theming and scaling. The `headerIcons` property takes a dictionary which maps icon names to functions which can
* take a foreground and background color and returns back a string representation of an svg. The svg should contain
* a header similar to this `<svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">` and
* interpolate the fg/bg colors into the string.
*
* We recognize this process is not fantastic from a graphics workflow standpoint, improvements are very welcome
* here.
*
* @group Style
*/
readonly headerIcons?: SpriteMap;
/** Controls smooth scrolling in the data grid. If smooth scrolling is not enabled the grid will always be cell
* aligned.
* @defaultValue `false`
* @group Style
*/
readonly smoothScrollX?: boolean;
/** Controls smooth scrolling in the data grid. If smooth scrolling is not enabled the grid will always be cell
* aligned.
* @defaultValue `false`
* @group Style
*/
readonly smoothScrollY?: boolean;

@@ -87,0 +195,0 @@ readonly theme: Theme;

@@ -9,3 +9,4 @@ import * as React from "react";

}
declare const GrowingEntry: React.FunctionComponent<Props>;
export default GrowingEntry;
/** @category Renderers */
export declare const GrowingEntry: React.FunctionComponent<Props>;
export {};

@@ -6,10 +6,10 @@ export type { OverlayImageEditorProps } from "./data-grid-overlay-editor/private/image-overlay-editor";

export type { CustomCellRenderer } from "./data-editor/use-custom-cells";
export type { DrawArgs } from "./data-editor/custom-cell-draw-args";
export type { CustomRenderer } from "./data-grid/cells/cell-types";
export type { SelectionBlending } from "./data-grid/use-selection-behavior";
export * from "./data-editor/data-editor";
export * from "./data-grid/data-grid-types";
export { default as ImageOverlayEditor } from "./data-grid-overlay-editor/private/image-overlay-editor";
export { ImageOverlayEditor } from "./data-grid-overlay-editor/private/image-overlay-editor";
export { default as MarkdownDiv } from "./markdown-div/markdown-div";
export { default as TextCellEntry } from "./growing-entry/growing-entry";
export { parseToRgba, withAlpha, blend } from "./data-grid/color-parser";
export { GrowingEntry as TextCellEntry } from "./growing-entry/growing-entry";
export { parseToRgba, withAlpha, blend, interpolateColors } from "./data-grid/color-parser";
export { measureTextCached, getMiddleCenterBias, drawTextCellExternal as drawTextCell, } from "./data-grid/data-grid-lib";

@@ -19,2 +19,6 @@ export { getDataEditorTheme as getDefaultTheme, useTheme } from "./common/styles";

export { useCustomCells } from "./data-editor/use-custom-cells";
/**
* @category DataEditor
* @hidden
*/
export { DataEditor as default } from "./data-editor/data-editor";
import React from "react";
/** @category Renderers */
export interface MarkdownDivProps {

@@ -6,2 +7,3 @@ contents: string;

}
/** @category Renderers */
export default class MarkdownDiv<TProps extends MarkdownDivProps, TState> extends React.PureComponent<TProps, TState> {

@@ -8,0 +10,0 @@ private targetElement;

@@ -7,10 +7,42 @@ import * as React from "react";

readonly onVisibleRegionChanged?: (range: Rectangle, clientWidth: number, clientHeight: number, rightElWidth: number, tx?: number, ty?: number) => void;
/**
* Causes the grid to scroll to the end when flipped to true
* @deprecated Use {@link DataEditorRef.scrollTo} instead
* @group Deprecated
*/
readonly scrollToEnd?: boolean;
readonly scrollRef?: React.MutableRefObject<HTMLDivElement | null>;
readonly smoothScrollX?: boolean;
readonly smoothScrollY?: boolean;
/**
* The overscroll properties are used to allow the grid to scroll past the logical end of the content by a fixed
* number of pixels. This is useful particularly on the X axis if you allow for resizing columns as it can make
* resizing the final column significantly easier.
*
* @group Advanced
*/
readonly overscrollX?: number;
/** {@inheritDoc overscrollX}
* @group Advanced
*/
readonly overscrollY?: number;
/**
* Provides an initial size for the grid which can prevent a flicker on load if the initial size is known prior to
* layout.
*
* @group Advanced
*/
readonly initialSize?: readonly [width: number, height: number];
/**
* Set to true to prevent any diagonal scrolling.
* @group Advanced
*/
readonly preventDiagonalScrolling?: boolean;
/**
* If `rightElementProps.sticky` is set to true the right element will be visible at all times, otherwise the user
* will need to scroll to the end to reveal it.
*
* If `rightElementProps.fill` is set, the right elements container will fill to consume all remaining space (if
* any) at the end of the grid. This does not play nice with growing columns.
*
* @group Advanced
*/
readonly rightElementProps?: {

@@ -20,3 +52,13 @@ readonly sticky?: boolean;

};
/**
* The right element is a DOM node which can be inserted at the end of the horizontal scroll region. This can be
* used to create a right handle panel, make a big add button, or display messages.
* @group Advanced
*/
readonly rightElement?: React.ReactNode;
/**
* Enables/disables the interactive minimap.
* @defaultValue false
* @group Advanced
*/
readonly showMinimap?: boolean;

@@ -23,0 +65,0 @@ readonly clientSize: readonly [number, number];

{
"name": "@glideapps/glide-data-grid",
"version": "5.1.0-alpha2",
"version": "5.1.0-alpha3",
"description": "Super fast, pure canvas Data Grid Editor",

@@ -75,4 +75,5 @@ "sideEffects": [

"react-resize-detector": "^7.1.2",
"tsc-esm-fix": "^2.7.8"
"tsc-esm-fix": "^2.7.8",
"typedoc": "^0.23.13"
}
}

@@ -9,3 +9,2 @@ <h1 align="center">

<picture>

@@ -90,3 +89,3 @@ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/glideapps/glide-data-grid/master/media/data-grid-dark.png">

allowOverlay: false,
displayData: person.firstName
displayData: person.firstName,
};

@@ -98,3 +97,3 @@ } else if (col === 1) {

allowOverlay: false,
displayData: person.lastName
displayData: person.lastName,
};

@@ -109,3 +108,3 @@ } else {

The full [API documentation is in the `API.md` file](API.md).
The full [API documentation is on the main site](https://grid.glideapps.com/docs/index.html).

@@ -159,2 +158,3 @@ # 📒 FAQ

home.tsx
```tsx

@@ -185,2 +185,3 @@ import type { NextPage } from "next";

grid.tsx
```tsx

@@ -187,0 +188,0 @@ import React from "react";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc