Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,20 +743,20 @@ const columns: readonly Column<Row>[] = [
];
```

#### `textEditor<TRow, TSummaryRow>(props: RenderEditCellProps<TRow, TSummaryRow>)`
#### `renderTextEditor<TRow, TSummaryRow>(props: RenderEditCellProps<TRow, TSummaryRow>)`

A basic text editor provided for convenience.

**Example:**

```tsx
import { textEditor, type Column } from 'react-data-grid';
import { renderTextEditor, type Column } from 'react-data-grid';

const columns: readonly Column<Row>[] = [
{
key: 'title',
name: 'Title',
renderEditCell: textEditor
renderEditCell: renderTextEditor
}
];
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function autoFocusAndSelect(input: HTMLInputElement | null) {
input?.select();
}

export default function textEditor<TRow, TSummaryRow>({
export default function textTextEditor<TRow, TSummaryRow>({
row,
column,
onRowChange,
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export { default as Row } from './Row';
export { default as Cell } from './Cell';
export * from './Columns';
export * from './cellRenderers';
export { default as textEditor } from './editors/textEditor';
export { default as renderTextEditor } from './editors/renderTextEditor';
export { default as renderHeaderCell } from './renderHeaderCell';
export { renderSortIcon, renderSortPriority } from './sortStatus';
export { useRowSelection, useHeaderRowSelection } from './hooks';
Expand All @@ -34,6 +34,7 @@ export type {
ColumnOrColumnGroup,
ColumnWidth,
ColumnWidths,
Direction,
FillEvent,
RenderCellProps,
RenderCheckboxProps,
Expand Down
4 changes: 2 additions & 2 deletions test/browser/TreeDataGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { page, userEvent } from 'vitest/browser';

import type { Column } from '../../src';
import { SelectColumn, textEditor, TreeDataGrid } from '../../src';
import { renderTextEditor, SelectColumn, TreeDataGrid } from '../../src';
import { focusSinkClassname } from '../../src/style/core';
import { rowSelected } from '../../src/style/row';
import {
Expand Down Expand Up @@ -40,7 +40,7 @@ const columns: readonly Column<Row, SummaryRow>[] = [
{
key: 'country',
name: 'Country',
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'year',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { page, userEvent } from 'vitest/browser';

import { DataGrid, textEditor } from '../../src';
import { DataGrid, renderTextEditor } from '../../src';
import type { Column } from '../../src';

interface Row {
Expand All @@ -12,7 +12,7 @@ const columns: readonly Column<Row>[] = [
{
key: 'name',
name: 'Name',
renderEditCell: textEditor,
renderEditCell: renderTextEditor,
editorOptions: {
commitOnOutsideClick: false
}
Expand All @@ -26,7 +26,7 @@ function Test() {
return <DataGrid columns={columns} rows={rows} onRowsChange={setRows} />;
}

test('TextEditor', async () => {
test('renderTextEditor', async () => {
await page.render(<Test />);
const cell = page.getByRole('gridcell');
await expect.element(cell).toHaveTextContent(/^Tacitus Kilgore$/);
Expand Down
24 changes: 12 additions & 12 deletions website/routes/AllFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';
import clsx from 'clsx';

import { DataGrid, SelectColumn, textEditor } from '../../src';
import { DataGrid, renderTextEditor, SelectColumn } from '../../src';
import type { CalculatedColumn, CellCopyArgs, CellPasteArgs, Column, FillEvent } from '../../src';
import { textEditorClassname } from '../../src/editors/textEditor';
import { textEditorClassname } from '../../src/editors/renderTextEditor';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down Expand Up @@ -132,71 +132,71 @@ const columns: readonly Column<Row>[] = [
width: 200,
resizable: true,
frozen: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'lastName',
name: 'Last Name',
width: 200,
resizable: true,
frozen: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'email',
name: 'Email',
width: 'max-content',
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'street',
name: 'Street',
width: 200,
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'zipCode',
name: 'ZipCode',
width: 200,
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'date',
name: 'Date',
width: 200,
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'bs',
name: 'bs',
width: 200,
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'catchPhrase',
name: 'Catch Phrase',
width: 'max-content',
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'companyName',
name: 'Company Name',
width: 200,
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'sentence',
name: 'Sentence',
width: 'max-content',
resizable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
}
];

Expand Down
3 changes: 1 addition & 2 deletions website/routes/Animation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useState } from 'react';
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down
3 changes: 1 addition & 2 deletions website/routes/ColumnGrouping.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DataGrid } from '../../src';
import type { ColumnOrColumnGroup } from '../../src';
import { DataGrid, type ColumnOrColumnGroup } from '../../src';
import { renderCoordinates } from '../renderers';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/ColumnSpanning.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { renderCoordinates } from '../renderers';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/ColumnsReordering.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback, useMemo, useState } from 'react';

import { DataGrid } from '../../src';
import type { Column, ColumnWidths, SortColumn } from '../../src';
import { DataGrid, type Column, type ColumnWidths, type SortColumn } from '../../src';
import { startViewTransition } from '../utils';
import { useDirection } from '../directionContext';

Expand Down
18 changes: 9 additions & 9 deletions website/routes/CommonFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { css } from '@linaria/core';

import {
DataGrid,
renderTextEditor,
SelectCellFormatter,
SelectColumn,
textEditor,
type Column,
type DataGridHandle,
type Direction,
type SortColumn
} from '../../src';
import { textEditorClassname } from '../../src/editors/textEditor';
import type { Direction } from '../../src/types';
import { textEditorClassname } from '../../src/editors/renderTextEditor';
import { exportToCsv, exportToPdf } from '../utils';
import { useDirection } from '../directionContext';

Expand Down Expand Up @@ -96,7 +96,7 @@ function getColumns(
key: 'title',
name: 'Task',
frozen: true,
renderEditCell: textEditor,
renderEditCell: renderTextEditor,
renderSummaryCell({ row }) {
return `${row.totalCount} records`;
}
Expand All @@ -106,12 +106,12 @@ function getColumns(
name: 'Client',
width: 'max-content',
draggable: true,
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'area',
name: 'Area',
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'country',
Expand All @@ -132,12 +132,12 @@ function getColumns(
{
key: 'contact',
name: 'Contact',
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'assignee',
name: 'Assignee',
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'progress',
Expand Down Expand Up @@ -219,7 +219,7 @@ function getColumns(
{
key: 'version',
name: 'Version',
renderEditCell: textEditor
renderEditCell: renderTextEditor
},
{
key: 'available',
Expand Down
3 changes: 1 addition & 2 deletions website/routes/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { createPortal } from 'react-dom';
import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down
4 changes: 2 additions & 2 deletions website/routes/CustomizableRenderers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo, useState } from 'react';
import { css } from '@linaria/core';

import { Row as BaseRow, Cell, DataGrid, SelectColumn, textEditor } from '../../src';
import { Row as BaseRow, Cell, DataGrid, renderTextEditor, SelectColumn } from '../../src';
import type {
CellRendererProps,
Column,
Expand Down Expand Up @@ -69,7 +69,7 @@ const columns: readonly Column<Row>[] = [
{
key: 'task',
name: 'Title',
renderEditCell: textEditor,
renderEditCell: renderTextEditor,
sortable: true
},
{
Expand Down
3 changes: 1 addition & 2 deletions website/routes/HeaderFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { createContext, useContext, useMemo, useState } from 'react';
import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column, RenderHeaderCellProps } from '../../src';
import { DataGrid, type Column, type RenderHeaderCellProps } from '../../src';
import type { Omit } from '../../src/types';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/InfiniteScrolling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useState } from 'react';
import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down
4 changes: 1 addition & 3 deletions website/routes/MasterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useMemo, useState } from 'react';
import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';

import { DataGrid } from '../../src';
import type { Column, RowsChangeData } from '../../src';
import type { Direction } from '../../src/types';
import { DataGrid, type Column, type Direction, type RowsChangeData } from '../../src';
import { CellExpanderFormatter } from '../components';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/MillionCells.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { renderCoordinates } from '../renderers';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/NoRows.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useState } from 'react';
import { css } from '@linaria/core';

import { DataGrid, SelectColumn } from '../../src';
import type { Column } from '../../src';
import { DataGrid, SelectColumn, type Column } from '../../src';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down
3 changes: 1 addition & 2 deletions website/routes/ResizableGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DataGrid } from '../../src';
import type { Column } from '../../src';
import { DataGrid, type Column } from '../../src';
import { renderCoordinates } from '../renderers';
import { useDirection } from '../directionContext';

Expand Down
3 changes: 1 addition & 2 deletions website/routes/RowGrouping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useState } from 'react';
import { faker } from '@faker-js/faker';
import { css } from '@linaria/core';

import { SelectColumn, TreeDataGrid } from '../../src';
import type { Column } from '../../src';
import { SelectColumn, TreeDataGrid, type Column } from '../../src';
import { useDirection } from '../directionContext';

export const Route = createFileRoute({
Expand Down
Loading