Comparing version 2.1.1 to 2.2.1
@@ -0,15 +1,37 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import * as React from 'react'; | ||
import { ActionType } from '../../enums'; | ||
import { ActionType, EditingMode } from '../../enums'; | ||
import { getField } from '../../Utils/ColumnUtils'; | ||
import { isEmpty } from '../../Utils/CommonUtils'; | ||
var CellText = function (_a) { | ||
var format = _a.column.format, column = _a.column, rowData = _a.rowData, rowKeyField = _a.rowKeyField, dispatch = _a.dispatch; | ||
import { mergeProps } from '../../Utils/PropsUtils'; | ||
var CellText = function (props) { | ||
var childAttributes = props.childAttributes, column = props.column, format = props.column.format, dispatch = props.dispatch, editingMode = props.editingMode, rowData = props.rowData, rowKeyField = props.rowKeyField; | ||
var field = getField(column); | ||
var value = rowData[field]; | ||
var formatedValue = format ? format(value) : !isEmpty(value) && value.toString(); | ||
return (React.createElement("div", { className: 'ka-cell-text', onClick: function () { | ||
var cell = { columnKey: column.key, rowKey: rowData[rowKeyField] }; | ||
dispatch(ActionType.OpenEditor, { cell: cell }); | ||
} }, formatedValue || React.createElement(React.Fragment, null, "\u00A0"))); | ||
var componentProps = { | ||
className: 'ka-cell-text', | ||
onClick: function () { | ||
if (editingMode === EditingMode.Cell) { | ||
var cell = { columnKey: column.key, rowKey: rowData[rowKeyField] }; | ||
dispatch(ActionType.OpenEditor, { cell: cell }); | ||
} | ||
}, | ||
}; | ||
var divProps = componentProps; | ||
if (childAttributes && childAttributes.cell) { | ||
divProps = mergeProps(componentProps, props, childAttributes.cell); | ||
} | ||
return (React.createElement("div", __assign({}, divProps), formatedValue || React.createElement(React.Fragment, null, "\u00A0"))); | ||
}; | ||
export default CellText; |
@@ -6,7 +6,7 @@ import React from 'react'; | ||
var DataRowContent = function (_a) { | ||
var columns = _a.columns, dispatch = _a.dispatch, editableCells = _a.editableCells, editingMode = _a.editingMode, isSelectedRow = _a.isSelectedRow, rowData = _a.rowData, rowKeyField = _a.rowKeyField; | ||
var childAttributes = _a.childAttributes, columns = _a.columns, dispatch = _a.dispatch, editableCells = _a.editableCells, editingMode = _a.editingMode, isSelectedRow = _a.isSelectedRow, rowData = _a.rowData, rowKeyField = _a.rowKeyField; | ||
var rowKeyValue = rowData[rowKeyField]; | ||
var rowEditableCells = getRowEditableCells(rowKeyValue, editableCells); | ||
return (React.createElement(React.Fragment, null, columns.map(function (column) { return (React.createElement(CellComponent, { column: column, editingMode: editingMode, isEditableCell: isEditableCell(editingMode, column, rowEditableCells), isSelectedRow: isSelectedRow, key: column.key, dispatch: dispatch, rowData: rowData, rowKeyField: rowKeyField })); }))); | ||
return (React.createElement(React.Fragment, null, columns.map(function (column) { return (React.createElement(CellComponent, { column: column, childAttributes: childAttributes, editingMode: editingMode, isEditableCell: isEditableCell(editingMode, column, rowEditableCells), isSelectedRow: isSelectedRow, key: column.key, dispatch: dispatch, rowData: rowData, rowKeyField: rowKeyField })); }))); | ||
}; | ||
export default DataRowContent; |
@@ -0,2 +1,5 @@ | ||
export * from './Models/AttributeTableData'; | ||
export * from './Models/AttributeTableData'; | ||
export * from './Models/Cell'; | ||
export * from './Models/ChildAttributes'; | ||
export * from './Models/Column'; | ||
@@ -6,2 +9,3 @@ export * from './Models/CssClasses'; | ||
export * from './Models/Group'; | ||
export * from './Models/GroupRowData'; | ||
export * from './Models/GroupRowData'; | ||
export * from './Models/VirtualScrolling'; |
@@ -0,2 +1,5 @@ | ||
export * from './Models/AttributeTableData'; | ||
export * from './Models/AttributeTableData'; | ||
export * from './Models/Cell'; | ||
export * from './Models/ChildAttributes'; | ||
export * from './Models/Column'; | ||
@@ -7,1 +10,2 @@ export * from './Models/CssClasses'; | ||
export * from './Models/GroupRowData'; | ||
export * from './Models/VirtualScrolling'; |
{ | ||
"name": "ka-table", | ||
"version": "2.1.1", | ||
"version": "2.2.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": "github:komarovalexander/ka-table", |
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/komarovalexander/ka-table/blob/master/LICENSE) | ||
[![npm version](https://img.shields.io/npm/v/ka-table.svg?style=flat-square)](https://www.npmjs.com/package/ka-table) | ||
[![Build Status](https://travis-ci.com/komarovalexander/ka-table.svg?token=9QUEx9r7MWqF44f9VDer&branch=dev)](https://travis-ci.com/komarovalexander/ka-table) | ||
[![Coverage Status](https://coveralls.io/repos/github/komarovalexander/ka-table/badge.svg?branch=master)](https://coveralls.io/github/komarovalexander/ka-table?branch=master) | ||
[![Build Status](https://travis-ci.com/komarovalexander/ka-table.svg?token=9QUEx9r7MWqF44f9VDer&branch=master)](https://travis-ci.com/komarovalexander/ka-table) | ||
@@ -130,3 +131,2 @@ # Overview | ||
| onEvent | (type: string, data: any) => void | Executes each time when dispatch is called [Events](https://komarovalexander.github.io/ka-table/#/events) | | ||
| onActionRejected | (type: string, data: any, command: [ActionCommand](#ActionCommand)) => void | Executes each time after action has been rejected [Command Column](https://komarovalexander.github.io/ka-table/#/command-column) | | ||
| groupsExpanded | any[][] | Groups that are expanded in the grid | | ||
@@ -133,0 +133,0 @@ | rowKeyField | string | Data's field which is used to identify row | |
16
types.ts
@@ -8,5 +8,14 @@ import { PropsWithChildren } from 'react'; | ||
import { Column } from './models'; | ||
import { AttributeTableData } from './Models/AttributeTableData'; | ||
export type DispatchFunc = (type: string, data: any) => void; | ||
export type EventFunc = (type: string, data: any) => void; | ||
type AddParameters<T> = | ||
T extends (e: infer E) => void ? ( | ||
(e: E, extendedEvent: AttributeTableData) => void | ||
) : T; | ||
type WithExtraParameters<T> = { | ||
[P in keyof T ] : AddParameters<T[P]>; | ||
}; | ||
export type ChildProps = ICellContentProps; | ||
export type CellFunc = (props: CellFuncPropsWithChildren) => any; | ||
@@ -17,7 +26,10 @@ export type CellFuncPropsWithChildren = PropsWithChildren<ICellContentProps>; | ||
export type DataRowFuncPropsWithChildren = PropsWithChildren<IDataRowProps>; | ||
export type DispatchFunc = (type: string, data: any) => void; | ||
export type EditorFunc = (props: EditorFuncPropsWithChildren) => any; | ||
export type EditorFuncPropsWithChildren = PropsWithChildren<ICellEditorProps>; | ||
export type EventFunc = (type: string, data: any) => void; | ||
export type FilterRowFunc = (props: FilterRowFuncPropsWithChildren) => any; | ||
export type FilterRowFuncPropsWithChildren = PropsWithChildren<IFilterRowEditorProps>; | ||
export type FormatFunc = (value: any) => any; | ||
export type ChildAttributesItem = WithExtraParameters<React.HTMLAttributes<HTMLElement>>; | ||
export type HeaderCellFunc = (props: HeaderCellFuncPropsWithChildren) => any; | ||
@@ -24,0 +36,0 @@ export type HeaderCellFuncPropsWithChildren = PropsWithChildren<IHeadCellProps>; |
@@ -53,2 +53,8 @@ var __assign = (this && this.__assign) || function () { | ||
return Boolean(value); | ||
}; | ||
}; | ||
export function isFunction(variableToCheck) { | ||
if (variableToCheck instanceof Function) { | ||
return true; | ||
} | ||
return false; | ||
} |
@@ -33,1 +33,8 @@ import { DataType } from '../enums'; | ||
}; | ||
export function isFunction(variableToCheck: any) { | ||
if (variableToCheck instanceof Function) { | ||
return true; | ||
} | ||
return false; | ||
} |
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 not supported yet
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 not supported yet
Sorry, the diff of this file is not supported yet
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
185728
132
3151