Namespace: utils

utils

Utilities for data manipulation.
Source:

Methods

(static) columnSelected(data, excludeKeys) → {Array.<Object>}

Filters out specified keys from each object in the data array. This is useful for selectively displaying certain columns from a dataset.
Parameters:
Name Type Description
data Array.<Object> Array of objects to be processed.
excludeKeys Array.<string> Keys to be excluded from each object.
Source:
Returns:
A new array of objects, without excluded keys.
Type
Array.<Object>

(static) columns(data, position) → {Array.<{Header: string, dataKey: string}>}

Converts data into an array of columns by flattening each object. Useful for preparing data for components like tables.
Parameters:
Name Type Description
data Array.<Object> Array of objects to process.
position boolean If true, formats the column headers.
Source:
Returns:
An array of objects with Header and dataKey.
Type
Array.<{Header: string, dataKey: string}>

(static) flattenObject(obj) → {Object}

Flattens a nested object by transforming its nested properties into dot-separated keys. { a: { b: c }} becomes { 'a.b': c }. Arrays and null values are not flattened.
Parameters:
Name Type Description
obj Object The object to be flattened.
Source:
Returns:
A new object with flattened keys.
Type
Object

(static) formatIfDate(value) → {string|any}

Checks if a given value is a string that matches a date pattern. If so, it formats the string as a date in the 'dd/mm/yyyy' format. Otherwise, returns the value as is. Supported date formats include YYYY-MM-DD, MM/DD/YYYY, and ISO 8601 format.
Parameters:
Name Type Description
value string The value to be checked and potentially formatted as a date.
Source:
Returns:
The formatted date string if the value is a date, otherwise the original value.
Type
string | any

(static) renderCellValue(value) → {string}

Renders a cell value for display. It formats date strings, stringifies objects, and handles null or undefined values by returning a blank space. For non-object, non-null values, it applies date formatting if applicable.
Parameters:
Name Type Description
value any The value to be rendered in a cell.
Source:
Returns:
The rendered value as a string. If the value is null or undefined, returns a blank space.
Type
string

(static) usePaginationPerso(totalItems, itemsPerPage) → {Object}

A custom hook for managing pagination logic. It calculates total pages based on the total items and items per page, and provides functionality to navigate between pages.
Parameters:
Name Type Description
totalItems number The total number of items to be paginated.
itemsPerPage number The number of items to display per page.
Source:
Returns:
An object containing pagination state and control functions.
Type
Object