Comparing version 8.11.0 to 8.12.0
@@ -200,3 +200,3 @@ import { ActionType, InsertRowPosition } from './enums'; | ||
type: ActionType; | ||
column: Column; | ||
column: Column<any>; | ||
index: number; | ||
@@ -203,0 +203,0 @@ }; |
import * as React from 'react'; | ||
import * as actionCreators from '../../actionCreators'; | ||
import { ControlledPropsKeys, DispatchFunc, FilterFunc, FormatFunc, NoData, OnDispatchFunc, SearchFunc, SortFunc, ValidationFunc } from '../../types'; | ||
import { ControlledPropsKeys, CustomReducerFunc, DispatchFunc, FilterFunc, FormatFunc, NoData, OnDispatchFunc, SearchFunc, SortFunc, ValidationFunc } from '../../types'; | ||
import { EditableCell, PagingOptions } from '../../models'; | ||
@@ -20,2 +20,3 @@ import { EditingMode, FilteringMode, SortingMode } from '../../enums'; | ||
dispatch: DispatchFunc; | ||
customReducer?: CustomReducerFunc; | ||
} | ||
@@ -25,3 +26,3 @@ export interface ITableProps<TData = any> { | ||
columnResizing?: boolean; | ||
columns: Column[]; | ||
columns: Column<TData>[]; | ||
groupedColumns?: GroupedColumn[]; | ||
@@ -32,8 +33,8 @@ data?: TData[]; | ||
editingMode?: EditingMode; | ||
extendedFilter?: (data: any[]) => any[]; | ||
extendedSort?: (data: any[], columns: Column[]) => any[]; | ||
filter?: FilterFunc; | ||
extendedFilter?: (data: TData[]) => TData[]; | ||
extendedSort?: (data: TData[], columns: Column[]) => TData[]; | ||
filter?: FilterFunc<TData>; | ||
filteringMode?: FilteringMode; | ||
focused?: Focused; | ||
format?: FormatFunc; | ||
format?: FormatFunc<TData>; | ||
groups?: Group[]; | ||
@@ -50,3 +51,3 @@ groupsExpanded?: any[][]; | ||
rowReordering?: boolean; | ||
search?: SearchFunc; | ||
search?: SearchFunc<TData>; | ||
searchText?: string; | ||
@@ -58,3 +59,3 @@ selectedRows?: any[]; | ||
sortingMode?: SortingMode; | ||
validation?: ValidationFunc; | ||
validation?: ValidationFunc<TData>; | ||
virtualScrolling?: VirtualScrolling; | ||
@@ -61,0 +62,0 @@ width?: number | string; |
@@ -61,3 +61,5 @@ "use strict"; | ||
changeTableProps(function (prevState) { | ||
var nextState = (0, kaReducer_1.kaReducer)(prevState, action); | ||
var _a, _b; | ||
var nextStateDefault = (0, kaReducer_1.kaReducer)(prevState, action); | ||
var nextState = ((_a = props.table) === null || _a === void 0 ? void 0 : _a.customReducer) ? ((_b = props.table.customReducer(nextStateDefault, action, prevState)) !== null && _b !== void 0 ? _b : nextStateDefault) : nextStateDefault; | ||
setTimeout(function () { | ||
@@ -64,0 +66,0 @@ var _a, _b; |
@@ -0,9 +1,11 @@ | ||
import { CustomReducerFunc, OnDispatchFunc } from '../types'; | ||
import { ITableInstance, ITableProps } from '../Components/Table/Table'; | ||
import { OnDispatchFunc } from '../types'; | ||
export declare const getTable: (options?: { | ||
changeProps?: React.Dispatch<React.SetStateAction<ITableProps>>; | ||
onDispatch?: OnDispatchFunc; | ||
customReducer?: CustomReducerFunc; | ||
}) => ITableInstance; | ||
export declare const useTable: (options?: { | ||
onDispatch?: OnDispatchFunc; | ||
customReducer?: CustomReducerFunc; | ||
}) => ITableInstance; |
@@ -40,3 +40,3 @@ "use strict"; | ||
var getTable = function (options) { | ||
var _a = options || {}, changeProps = _a.changeProps, onDispatch = _a.onDispatch; | ||
var _a = options || {}, changeProps = _a.changeProps, onDispatch = _a.onDispatch, customReducer = _a.customReducer; | ||
var propsResult = {}; | ||
@@ -53,3 +53,3 @@ return __assign(__assign({}, Object.keys(actionCreators).reduce(function (acc, key) { | ||
return acc; | ||
}, {})), { props: propsResult, changeProps: changeProps || (function () { }), dispatch: function () { }, onDispatch: onDispatch || (function () { }) }); | ||
}, {})), { props: propsResult, changeProps: changeProps || (function () { }), dispatch: function () { }, onDispatch: onDispatch || (function () { }), customReducer: customReducer }); | ||
}; | ||
@@ -56,0 +56,0 @@ exports.getTable = getTable; |
@@ -5,3 +5,3 @@ /// <reference types="react" /> | ||
import { PopupPosition } from './PopupPosition'; | ||
export declare class Column { | ||
export declare class Column<TData = any> { | ||
colGroup?: React.ColHTMLAttributes<HTMLElement>; | ||
@@ -15,5 +15,5 @@ dataType?: DataType; | ||
headerFilterListItems?: (props: { | ||
data?: any[]; | ||
data?: TData[]; | ||
}) => any[]; | ||
filter?: (value: any, filterValue: any, rowData?: any) => boolean; | ||
filter?: (value: any, filterValue: any, rowData?: TData) => boolean; | ||
isHeaderFilterPopupShown?: boolean; | ||
@@ -20,0 +20,0 @@ isEditable?: boolean; |
{ | ||
"name": "ka-table", | ||
"version": "8.11.0", | ||
"version": "8.12.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": "github:komarovalexander/ka-table", |
@@ -17,26 +17,27 @@ /// <reference types="react" /> | ||
export type DispatchFunc = (action: any) => void; | ||
export type CustomReducerFunc = (nextState: ITableProps, action: any, prevState: ITableProps) => ITableProps; | ||
export type OnDispatchFunc = (action: any, tableProps: ITableProps) => void; | ||
export type ControlledPropsKeys = (keyof ITableProps)[]; | ||
export type Field = string; | ||
export type FormatFunc = (props: { | ||
export type FormatFunc<TData = any> = (props: { | ||
value: any; | ||
column: Column; | ||
rowData?: any; | ||
rowData?: TData; | ||
}) => any; | ||
export type FilterFunc = (props: { | ||
export type FilterFunc<TData = any> = (props: { | ||
column: Column; | ||
}) => ((value: any, filterRowValue: any, rowData?: any) => boolean) | void; | ||
}) => ((value: any, filterRowValue: any, rowData?: TData) => boolean) | void; | ||
export type SortFunc = (props: { | ||
column: Column; | ||
}) => ((value1: any, value2: any) => 0 | 1 | -1) | void; | ||
export type SearchFunc = (props: { | ||
export type SearchFunc<TData = any> = (props: { | ||
searchText: string; | ||
rowData: any; | ||
rowData: TData; | ||
column: Column; | ||
}) => boolean; | ||
export type ValidationFunc = (props: { | ||
}) => boolean | void; | ||
export type ValidationFunc<TData = any> = (props: { | ||
value: any; | ||
rowData: any; | ||
rowData: TData; | ||
column: Column; | ||
}) => string | void; | ||
export {}; |
import { Column } from '../models'; | ||
import { Field } from '../types'; | ||
export declare const getColumn: (columns: Column[], columnKey: string) => Column; | ||
export declare const getColumn: (columns: Column[], columnKey: string) => Column<any>; | ||
export declare const getField: (column: Column) => Field; | ||
@@ -5,0 +5,0 @@ export declare const getLastField: (field: Field) => Field; |
@@ -17,5 +17,5 @@ import { ChildAttributesItem, DispatchFunc } from '../types'; | ||
export declare const prepareTableOptions: (props: ITableProps) => { | ||
columns: Column[]; | ||
columns: Column<any>[]; | ||
groupColumnsCount: number; | ||
groupedColumns: Column[]; | ||
groupedColumns: Column<any>[]; | ||
groupedData: any[]; | ||
@@ -22,0 +22,0 @@ }; |
@@ -20,3 +20,3 @@ import { ITableProps } from '../'; | ||
columnResizing?: boolean; | ||
columns: Column[]; | ||
columns: Column<any>[]; | ||
groupedColumns?: import("../Models/GroupedColumn").GroupedColumn[]; | ||
@@ -28,6 +28,6 @@ data?: any[]; | ||
extendedFilter?: (data: any[]) => any[]; | ||
extendedSort?: (data: any[], columns: Column[]) => any[]; | ||
filter?: import("../types").FilterFunc; | ||
extendedSort?: (data: any[], columns: Column<any>[]) => any[]; | ||
filter?: import("../types").FilterFunc<any>; | ||
filteringMode?: import("../enums").FilteringMode; | ||
format?: import("../types").FormatFunc; | ||
format?: import("../types").FormatFunc<any>; | ||
groups?: import("../models").Group[]; | ||
@@ -44,3 +44,3 @@ groupsExpanded?: any[][]; | ||
rowReordering?: boolean; | ||
search?: import("../types").SearchFunc; | ||
search?: import("../types").SearchFunc<any>; | ||
searchText?: string; | ||
@@ -52,3 +52,3 @@ selectedRows?: any[]; | ||
sortingMode?: import("../enums").SortingMode; | ||
validation?: ValidationFunc; | ||
validation?: ValidationFunc<any>; | ||
virtualScrolling?: import("../models").VirtualScrolling; | ||
@@ -55,0 +55,0 @@ width?: string | number; |
import { SortingMode } from '../enums'; | ||
import { Column } from '../Models/Column'; | ||
import { SortFunc } from '../types'; | ||
export declare const sortColumns: (columns: Column[]) => Column[]; | ||
export declare const sortColumns: (columns: Column[]) => Column<any>[]; | ||
export declare const sortData: (columns: Column[], data: any, sort?: SortFunc) => any[]; | ||
@@ -6,0 +6,0 @@ export declare const isTripleStateSorting: (sortingMode: SortingMode) => boolean; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
394187
8072