Skip to content

Commit

Permalink
Fixed #2374 - Improve Column attributes for Data components
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 31, 2021
1 parent 07ddf59 commit 86ea12b
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 58 deletions.
40 changes: 15 additions & 25 deletions api-generator/components/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ const ColumnProps = [
default: 'null',
description: 'Body content of the column.'
},
{
name: 'loadingBody',
type: 'function',
default: 'null',
description: 'Function to return the body content of the column to display when virtual scroll loads the new data.'
},
{
name: 'footer',
type: 'any',
Expand Down Expand Up @@ -210,43 +204,43 @@ const ColumnProps = [
description: 'Function to provide the cell editor input.'
},
{
name: 'editorValidator',
name: 'cellEditValidator',
type: 'function',
default: 'null',
description: 'Validator function to validate the cell input value.'
},
{
name: 'editorValidatorEvent',
name: 'cellEditValidatorEvent',
type: 'string',
default: 'click',
description: 'Event to trigger the validation, possible values are "click" and "blur".'
},
{
name: 'onBeforeEditorShow',
name: 'onBeforeCellEditShow',
type: 'function',
default: 'null',
description: 'Callback to invoke before the cell editor is shown.'
},
{
name: 'onBeforeEditorHide',
name: 'onBeforeCellEditHide',
type: 'function',
default: 'null',
description: 'Callback to invoke before the cell editor is hidden.'
},
{
name: 'onEditorInit',
name: 'onCellEditInit',
type: 'function',
default: 'null',
description: 'Callback to invoke when cell edit is initiated.'
},
{
name: 'onEditorSubmit',
name: 'onCellEditComplete',
type: 'function',
default: 'null',
description: 'Callback to execute when editor is submitted.'
},
{
name: 'onEditorCancel',
name: 'onCellEditCancel',
type: 'function',
default: 'null',
description: 'Callback to execute when editor is cancelled.'
Expand Down Expand Up @@ -285,11 +279,7 @@ const ColumnProps = [

const ColumnEvents = [
{
name: 'loadingBody',
description: 'TODO',
},
{
name: 'onEditorInit',
name: 'onCellEditInit',
description: 'TODO',
arguments: [
{
Expand All @@ -300,7 +290,7 @@ const ColumnEvents = [
]
},
{
name: 'onEditorSubmit',
name: 'onCellEditComplete',
description: 'TODO',
arguments: [
{
Expand All @@ -311,7 +301,7 @@ const ColumnEvents = [
]
},
{
name: 'onEditorCancel',
name: 'onCellEditCancel',
description: 'TODO',
arguments: [
{
Expand Down Expand Up @@ -354,7 +344,7 @@ const ColumnEvents = [
]
},
{
name: 'editorValidator',
name: 'cellEditValidator',
description: 'TODO',
arguments: [
{
Expand All @@ -365,7 +355,7 @@ const ColumnEvents = [
]
},
{
name: 'editorValidator',
name: 'cellEditValidator',
description: 'TODO',
arguments: [
{
Expand All @@ -376,7 +366,7 @@ const ColumnEvents = [
]
},
{
name: 'editorValidator',
name: 'cellEditValidator',
description: 'TODO',
arguments: [
{
Expand All @@ -387,7 +377,7 @@ const ColumnEvents = [
]
},
{
name: 'onBeforeEditorHide',
name: 'onBeforeCellEditHide',
description: 'TODO',
arguments: [
{
Expand All @@ -398,7 +388,7 @@ const ColumnEvents = [
]
},
{
name: 'onBeforeEditorShow',
name: 'onBeforeCellEditShow',
description: 'TODO',
arguments: [
{
Expand Down
119 changes: 110 additions & 9 deletions src/components/column/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,53 @@ type ColumnSelectionModeType = 'single' | 'multiple';

type ColumnSortOrderType = 1 | 0 | -1 | undefined | null;

type ColumnDataType = 'text' | 'numeric' | 'date' | string;

type ColumnAlignFrozenType = 'left' | 'right';

type ColumnFilterOperatorType = 'and' | 'or';

type ColumnFilterClearType = React.ReactNode | ((options: ColumnFilterClearTemplateOptions) => React.ReactNode);

type ColumnFilterApplyType = React.ReactNode | ((options: ColumnFilterApplyTemplateOptions) => React.ReactNode);

type ColumnFilterHeaderType = React.ReactNode | ((options: ColumnFilterHeaderTemplateOptions) => React.ReactNode);

type ColumnFilterFooterType = React.ReactNode | ((options: ColumnFilterFooterTemplateOptions) => React.ReactNode);

type ColumnFilterElementType = React.ReactNode | ((options: ColumnFilterElementTemplateOptions) => React.ReactNode);

type ColumnFilterModelType = ColumnFilterMetaData | ColumnFilterMetaDataWithConstraint;

interface ColumnFilterModelOptions {
[key: string]: ColumnFilterModelType;
}

interface ColumnFilterClearTemplateOptions {
field: string;
filterModel: ColumnFilterModelOptions;
filterClearCallback(): void;
}

interface ColumnFilterApplyTemplateOptions {
field: string;
filterModel: ColumnFilterModelOptions;
filterApplyCallback(value?: any, index?: number): void;
}

interface ColumnFilterHeaderTemplateOptions extends ColumnFilterApplyTemplateOptions {}

interface ColumnFilterFooterTemplateOptions extends ColumnFilterApplyTemplateOptions {}

interface ColumnFilterElementTemplateOptions {
field: string;
index: number;
filterModel: ColumnFilterModelOptions;
value: any;
filterApplyCallback(value?: any, index?: number): void;
filterCallback(value?: any, index?: number): void;
}

interface ColumnEventParams {
originalEvent: React.SyntheticEvent;
columnProps: ColumnProps;
Expand All @@ -23,6 +70,33 @@ interface ColumnFilterMetaData {
matchMode: ColumnFilterMatchModeType;
}

interface ColumnFilterMetaDataWithConstraint {
operator: ColumnFilterOperatorType;
constraints: ColumnFilterMetaData[];
}

interface ColumnFilterApplyClickParams {
field: string;
constraints: ColumnFilterMetaData[];
}

interface ColumnFilterMatchModeChangeParams {
field: string;
matchMode: ColumnFilterMatchModeType;
}

interface ColumnFilterOperatorChangeParams {
field: string;
operator: ColumnFilterOperatorType;
}

interface ColumnFilterConstraintAddParams {
field: string;
constraing: ColumnFilterMetaData;
}

interface ColumnFilterConstraintRemoveParams extends ColumnFilterConstraintAddParams {}

interface ColumnFilterMeta {
[key: string]: ColumnFilterMetaData;
}
Expand All @@ -38,6 +112,10 @@ interface ColumnFilterParams {
}
}

interface ColumnFilterMatchModeOptions {
[key: string]: string;
}

export interface ColumnProps {
columnKey?: string;
field?: string;
Expand All @@ -48,14 +126,38 @@ export interface ColumnProps {
footer?: React.ReactNode;
sortable?: boolean;
sortableDisabled?: boolean;
dataType?: ColumnDataType;
filter?: boolean;
filterMatchMode?: ColumnFilterMatchModeType;
filterPlaceholder?: string;
filterType?: string;
filterMaxLength?: number;
filterElement?: React.ReactNode;
filterElement?: ColumnFilterElementType;
filterHeaderStyle?: object;
filterHeaderClassName?: string;
showFilterMenu?: boolean;
showFilterOperator?: boolean;
showClearButton?: boolean;
showApplyButton?: boolean;
showFilterMatchModes?: boolean;
showFilterMenuOptions?: boolean;
showAddButton?: boolean;
filterMatchModeOptions?: ColumnFilterMatchModeOptions;
maxConstraints?: number;
filterMenuClassName?: string;
filterMenuStyle?: object;
alignFrozen?: ColumnAlignFrozenType;
hidden?: boolean;
onFilterClear?(): void;
onFilterApplyClick?(e: ColumnFilterApplyClickParams): void;
onFilterMatchModeChange?(e: ColumnFilterMatchModeChangeParams): void;
onFilterOperatorChange?(e: ColumnFilterOperatorChangeParams): void;
onFilterConstraintAdd?(e: ColumnFilterConstraintAddParams): void;
onFilterConstraintRemove?(e: ColumnFilterConstraintRemoveParams): void;
filterClear?: ColumnFilterClearType;
filterApply?: ColumnFilterApplyType;
filterHeader?: ColumnFilterHeaderType;
filterFooter?: ColumnFilterFooterType;
style?: object;
className?: string;
headerStyle?: object;
Expand All @@ -71,21 +173,20 @@ export interface ColumnProps {
rowSpan?: number;
rowReorder?: boolean;
rowReorderIcon?: string;
editorValidatorEvent?: string;
cellEditValidatorEvent?: string;
rowEditor?: boolean;
exportable?: boolean;
reorderable?: boolean;
excludeGlobalFilter?: boolean;
loadingBody?(): React.ReactNode;
onEditorInit?(e: ColumnEventParams): void;
onEditorSubmit?(e: ColumnEventParams): void;
onEditorCancel?(e: ColumnEventParams): void;
onCellEditInit?(e: ColumnEventParams): void;
onCellEditComplete?(e: ColumnEventParams): void;
onCellEditCancel?(e: ColumnEventParams): void;
sortFunction?(e: ColumnSortParams): void;
filterFunction?(value: any, filter: any, filterLocale: string, params: ColumnFilterParams): void;
editor?(props: ColumnProps): React.ReactNode;
editorValidator?(e: ColumnEventParams): boolean;
onBeforeEditorHide?(e: ColumnEventParams): void;
onBeforeEditorShow?(e: ColumnEventParams): void;
cellEditValidator?(e: ColumnEventParams): boolean;
onBeforeCellEditHide?(e: ColumnEventParams): void;
onBeforeCellEditShow?(e: ColumnEventParams): void;
}

export declare class Column extends React.Component<ColumnProps, any> { }

0 comments on commit 86ea12b

Please sign in to comment.