diff --git a/lib/SmartDataTable.tsx b/lib/SmartDataTable.tsx index c6bfd3a..7bb7207 100644 --- a/lib/SmartDataTable.tsx +++ b/lib/SmartDataTable.tsx @@ -17,27 +17,27 @@ import * as constants from './helpers/constants' import * as utils from './helpers/functions' import './css/basic.css' -const EMPTY_HEADERS = {} as utils.Headers -const EMPTY_ORDERED_HEADERS: string[] = [] -const EMPTY_REQUEST_OPTIONS: RequestInit = {} -const NOOP_ROW_CLICK = () => null +const emptyHeaders = {} as utils.Headers +const emptyOrderedHeaders: string[] = [] +const emptyRequestOptions: RequestInit = {} +const noopRowClick = () => null function SmartDataTable({ className = '', data, dataKey = constants.DEFAULT_DATA_KEY, dataKeyResolver = null, - dataRequestOptions = EMPTY_REQUEST_OPTIONS, + dataRequestOptions = emptyRequestOptions, dataSampling = 0, dynamic = false, emptyTable = null, filterValue = '', - headers = EMPTY_HEADERS as utils.Headers, + headers = emptyHeaders as utils.Headers, hideUnordered = false, loader = null, name = 'reactsmartdatatable', - onRowClick = NOOP_ROW_CLICK, - orderedHeaders = EMPTY_ORDERED_HEADERS, + onRowClick = noopRowClick, + orderedHeaders = emptyOrderedHeaders, paginator: PaginatorComponent = Paginator, parseBool = false, parseImg = false, diff --git a/lib/components/CellValue.tsx b/lib/components/CellValue.tsx index 2cd14c3..65cd1a2 100644 --- a/lib/components/CellValue.tsx +++ b/lib/components/CellValue.tsx @@ -73,7 +73,7 @@ const CellValue: FC> = ({ const highlightedValue = highlightValue() if (utils.isEmpty(grabLinks)) { - if (utils.isDataURL(value)) { + if (utils.isDataUrl(value)) { return renderImage({ bypass: true }) } diff --git a/lib/helpers/functions.table.test.ts b/lib/helpers/functions.table.test.ts index 3e20e17..4b75ada 100644 --- a/lib/helpers/functions.table.test.ts +++ b/lib/helpers/functions.table.test.ts @@ -10,7 +10,7 @@ import { getRenderValue, getSampleElement, highlightValueParts, - isDataURL, + isDataUrl, isImage, parseDataForColumns, parseDataForRows, @@ -588,11 +588,11 @@ test('sortData(), should return a properly sorted array', () => { ) }) -describe('isDataURL(), should return true if data is an enconded image', () => { +describe('isDataUrl(), should return true if data is an enconded image', () => { const tests: [unknown, boolean][] = [...negativeImgTests, [imgb64, true]] test.each(tests)('Testing data type %#', (data, expected) => { - expect(isDataURL(data)).toBe(expected) + expect(isDataUrl(data)).toBe(expected) }) }) diff --git a/lib/helpers/functions.ts b/lib/helpers/functions.ts index 04da686..d34adef 100644 --- a/lib/helpers/functions.ts +++ b/lib/helpers/functions.ts @@ -17,13 +17,13 @@ export type ParseImg = { className: string } -export type TransformFN = ( +export type TransformFn = ( value: unknown, index: number, row: T, ) => ReactNode -export type RowClickFN = ( +export type RowClickFn = ( event: MouseEvent, { rowData, @@ -32,7 +32,7 @@ export type RowClickFN = ( }: { rowData: T; rowIndex: number; tableData: T[] }, ) => void -export type RowClassNameFN = ( +export type RowClassNameFn = ( rowData: T, rowIndex: number, tableData: T[], @@ -49,7 +49,7 @@ export interface Column { sortable: HeaderSortable filterable: boolean isImg: boolean - transform?: TransformFN + transform?: TransformFn } export type Headers = Record> @@ -72,11 +72,11 @@ export interface RenderOptions { parseBool?: boolean | ParseBool } -export type KeyResolverFN = (args: T) => T[] +export type KeyResolverFn = (args: T) => T[] export interface FetchDataOptions { dataKey?: string - dataKeyResolver?: KeyResolverFN + dataKeyResolver?: KeyResolverFn options?: RequestInit } @@ -495,7 +495,7 @@ export function sortData( return filterRows(filterValue, sortedRows, colProperties) } -export function isDataURL(url: unknown): boolean { +export function isDataUrl(url: unknown): boolean { // Checks if the data is a valid base64 enconded string const regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/ @@ -529,7 +529,7 @@ export function isDataURL(url: unknown): boolean { } export function isImage(url: unknown): boolean { - const isImgDataURL = isDataURL(url) + const isImgDataURL = isDataUrl(url) if (isImgDataURL) { return isImgDataURL diff --git a/lib/hooks/useAsyncData.ts b/lib/hooks/useAsyncData.ts index 07d024b..eb0a773 100644 --- a/lib/hooks/useAsyncData.ts +++ b/lib/hooks/useAsyncData.ts @@ -8,7 +8,7 @@ import * as utils from '../helpers/functions' interface UseAsyncDataOptions { data: string | T[] dataKey: string - dataKeyResolver: utils.KeyResolverFN + dataKeyResolver: utils.KeyResolverFn dataRequestOptions: RequestInit headers: utils.Headers orderedHeaders: string[] diff --git a/lib/types.ts b/lib/types.ts index eb1a74a..34192ea 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -7,7 +7,7 @@ export interface SmartDataTableProps { className: string data: string | T[] dataKey: string - dataKeyResolver: utils.KeyResolverFN + dataKeyResolver: utils.KeyResolverFn dataRequestOptions: RequestInit dataSampling: number dynamic: boolean @@ -17,13 +17,13 @@ export interface SmartDataTableProps { hideUnordered: boolean loader: ReactNode name: string - onRowClick: utils.RowClickFN + onRowClick: utils.RowClickFn orderedHeaders: string[] paginator: ComponentType parseBool: boolean | utils.ParseBool parseImg: boolean | utils.ParseImg perPage: number - rowClassName: utils.RowClassNameFN + rowClassName: utils.RowClassNameFn sortable: boolean withFooter: boolean withHeader: boolean