Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flashOnUpdate for columns #246

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ function InfiniteTableColumnCellFn<T>(props: InfiniteTableColumnCellProps<T>) {

const rowDisabled = rowInfo.rowDisabled;

// const flashOnUpdate = column.computedFlashOnUpdate;
const visibleColumnsIds = computed.computedVisibleColumns.map((x) => x.id);
const colRenderingParams = getColumnRenderingParams({
horizontalLayoutPageIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
InfiniteTableProps,
InfiniteTablePropEditable,
InfiniteTablePropSortable,
InfiniteTablePropFlashOnUpdate,
} from '../types/InfiniteTableProps';
import type { GetComputedColumnsResult } from '../utils/getComputedColumns';
import { getComputedColumns } from '../utils/getComputedColumns';
Expand All @@ -39,6 +40,7 @@ type UseComputedColumnsParam<T> = {
columnDefaultWidth?: number;
columnDefaultFlex?: number;
sortable?: InfiniteTablePropSortable<T>;
flashOnUpdate?: InfiniteTablePropFlashOnUpdate<T>;
draggableColumns?: boolean;
columnDefaultDraggable?: boolean;
multiSort: boolean;
Expand All @@ -51,6 +53,7 @@ type UseComputedColumnsParam<T> = {
columnDefaultEditable?: InfiniteTableProps<T>['columnDefaultEditable'];
columnDefaultFilterable?: InfiniteTableProps<T>['columnDefaultFilterable'];
columnDefaultSortable?: InfiniteTableProps<T>['columnDefaultSortable'];
columnDefaultFlashOnUpdate?: InfiniteTableProps<T>['columnDefaultFlashOnUpdate'];
columnPinning: InfiniteTablePropColumnPinning;
columnSizing: InfiniteTablePropColumnSizing;
columnTypes: InfiniteTablePropColumnTypes<T>;
Expand Down Expand Up @@ -105,9 +108,11 @@ export const useComputedColumns = <T extends unknown>({
columnOrder,
columnPinning,
editable,
flashOnUpdate,
columnDefaultEditable,
columnDefaultFilterable,
columnDefaultSortable,
columnDefaultFlashOnUpdate,
scrollbarWidth,
columnTypes,
pinnedEndMaxWidth,
Expand Down Expand Up @@ -149,6 +154,7 @@ export const useComputedColumns = <T extends unknown>({
columnMinWidth,
columnMaxWidth,
columnDefaultWidth,
columnDefaultFlashOnUpdate,
columnDefaultFlex,
columnCssEllipsis,
columnHeaderCssEllipsis,
Expand All @@ -173,7 +179,7 @@ export const useComputedColumns = <T extends unknown>({
columnDefaultFilterable,
columnDefaultSortable,
editable,

flashOnUpdate,
columnSizing,
columnTypes,

Expand Down
20 changes: 20 additions & 0 deletions source/src/components/InfiniteTable/types/InfiniteTableColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,22 @@ export type InfiniteTableColumnSortable<T> =
| boolean
| InfiniteTableColumnSortableFn<T>;

export type InfiniteTableColumnFlashOptions<_T> = {
onlyForApiUpdates?: boolean;
};
export type InfiniteTableColumnFlashOnUpdate<T> =
| boolean
| InfiniteTableColumnFlashOptions<T>
| InfiniteTableColumnFlashOnUpdateFn<T>;

export type InfiniteTableColumnFlashOnUpdateParams<T> =
InfiniteTableColumnContentFocusableParams<T> & {
oldValue: any;
};

export type InfiniteTableColumnFlashOnUpdateFn<T> = (
params: InfiniteTableColumnFlashOnUpdateParams<T>,
) => boolean | InfiniteTableColumnFlashOptions<T>;
/**
* Defines a column in the table.
*
Expand Down Expand Up @@ -453,6 +469,7 @@ export type InfiniteTableColumn<DATA_TYPE> = {
) => any | Promise<any>;

comparer?: InfiniteTableColumnComparer<DATA_TYPE>;
defaultFlashOnUpdate?: InfiniteTableColumnFlashOnUpdate<DATA_TYPE>;
defaultHiddenWhenGroupedBy?:
| '*'
| true
Expand Down Expand Up @@ -602,6 +619,9 @@ type InfiniteTableComputedColumnBase<T> = {
computedFirst: boolean;
computedLast: boolean;
computedEditable: NonUndefined<InfiniteTableColumn<T>['defaultEditable']>;
computedFlashOnUpdate: NonUndefined<
InfiniteTableColumn<T>['defaultFlashOnUpdate']
>;
computedSortable: NonUndefined<InfiniteTableColumn<T>['defaultSortable']>;
colType: InfiniteTableColumnType<T>;
id: string;
Expand Down
15 changes: 15 additions & 0 deletions source/src/components/InfiniteTable/types/InfiniteTableProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Renderable } from '../../types/Renderable';
import type {
InfiniteTableColumn,
InfiniteTableColumnEditableFn,
InfiniteTableColumnFlashOnUpdate,
InfiniteTableColumnRenderFunction,
InfiniteTableColumnRenderFunctionForGroupRows,
InfiniteTableColumnSortable,
Expand Down Expand Up @@ -145,6 +146,7 @@ export type InfiniteTableColumnType<T> = {
defaultSortable?: InfiniteTableColumn<T>['defaultSortable'];
defaultEditable?: InfiniteTableColumn<T>['defaultEditable'];
defaultFilterable?: InfiniteTableColumn<T>['defaultFilterable'];
defaultFlashOnUpdate?: InfiniteTableColumn<T>['defaultFlashOnUpdate'];

columnGroup?: string;

Expand Down Expand Up @@ -561,6 +563,10 @@ export type InfiniteTablePropSortable<T> =
| InfiniteTableColumnSortable<T>
| undefined;

export type InfiniteTablePropFlashOnUpdate<T> =
| InfiniteTableColumnFlashOnUpdate<T>
| undefined;

export type InfiniteTablePropOnEditAcceptedParams<T> =
InfiniteTableRowInfoDataDiscriminatorWithColumnAndApis<T> & {
initialValue: any;
Expand Down Expand Up @@ -617,8 +623,17 @@ export interface InfiniteTableProps<T> {
InfiniteTableColumn<T> & InfiniteTablePivotFinalColumn<T>
>;

/**
* Default behavior for column filtering. Defaults to true.
*
* This is overriden by all other props that can control filtering behavior (`column.defaultFilterable`, `columnType.defaultFilterable`, `filterable`).
*/
columnDefaultFilterable?: boolean;

columnDefaultEditable?: boolean;
columnDefaultFlashOnUpdate?: boolean;

flashOnUpdate?: InfiniteTablePropFlashOnUpdate<T>;

/**
* Default behavior for column sorting. Defaults to true.
Expand Down
13 changes: 13 additions & 0 deletions source/src/components/InfiniteTable/utils/getComputedColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
InfiniteTableProps,
InfiniteTablePropEditable,
InfiniteTablePropSortable,
InfiniteTablePropFlashOnUpdate,
} from '../types/InfiniteTableProps';

import { adjustColumnOrderForPinning } from './adjustColumnOrderForPinning';
Expand Down Expand Up @@ -139,10 +140,12 @@ type GetComputedVisibleColumnsParam<T> = {
columnOrder: InfiniteTablePropColumnOrder;
columnPinning: InfiniteTablePropColumnPinning;
editable: InfiniteTablePropEditable<T>;
flashOnUpdate: InfiniteTablePropFlashOnUpdate<T>;
columnDefaultEditable: InfiniteTableProps<T>['columnDefaultEditable'];
columnDefaultFilterable: InfiniteTableProps<T>['columnDefaultFilterable'];
columnDefaultSortable: InfiniteTableProps<T>['columnDefaultSortable'];
columnDefaultDraggable: InfiniteTableProps<T>['columnDefaultDraggable'];
columnDefaultFlashOnUpdate: InfiniteTableProps<T>['columnDefaultFlashOnUpdate'];
columnSizing: InfiniteTablePropColumnSizing;
columnTypes: InfiniteTablePropColumnTypes<T>;
columnVisibility: InfiniteTablePropColumnVisibility;
Expand Down Expand Up @@ -178,6 +181,8 @@ export const getComputedColumns = <T extends unknown>({
columnPinning,
editable,
columnDefaultEditable,
flashOnUpdate,
columnDefaultFlashOnUpdate,
columnDefaultFilterable,
columnDefaultSortable,
columnSizing,
Expand Down Expand Up @@ -540,6 +545,13 @@ export const getComputedColumns = <T extends unknown>({
columnDefaultEditable ??
false;

const computedFlashOnUpdate =
flashOnUpdate ??
c.defaultFlashOnUpdate ??
colType.defaultFlashOnUpdate ??
columnDefaultFlashOnUpdate ??
false;

const computedDataType =
c.dataType ||
colType.dataType ||
Expand Down Expand Up @@ -628,6 +640,7 @@ export const getComputedColumns = <T extends unknown>({
computedFlex,
computedDataType,
computedEditable,
computedFlashOnUpdate,
computedSortType,
computedFilterType,
cssEllipsis,
Expand Down
Loading