all utils functions.
Members
Methods
# static exports.columnsMinWidthCalc(headings, data, ref, style) → {array}
Calculate the min-width for each column (heading + data).
Uses the Canvas API to measure the length of the text of each cell and return the max for each column
Takes into account of the font style, cell inter text length and the sorting image of column headers.
Parameters:
Name | Type | Description |
---|---|---|
headings |
array | the headings array. |
data |
array | the data array. |
ref |
HTMLElement | the ref to the pluggin html element, to recover font size and font family. |
style |
object | the style state from the store. |
- minwidth value for each column (in px) in the same sequence as the headings array.
array
# static exports.convertLengthUnit(length) → {number}
take a length to analyze value and unit and then return the value converted in pixel if needed.
Support px and rem input, return the unconverted value + a warn for other units.
Parameters:
Name | Type | Description |
---|---|---|
length |
string | number | the length as a string as it is set in customStyle prop or returned by getComputedStyle(). |
- the value converted into pixel length.
number
# static exports.formatDisplayedData(input, format) → {string}
Format an input with the given format.
If format is a function, returns the result of the funciton with input as parameter.
If format is a string (keyword), returns a a formated input according to the scheme.
Default case returns the unformated data.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | number | boolean | the input to format. |
format |
string | function | the format to apply. |
- the formated input as a string.
string
# static exports.getCellInterTextLength(style) → {number}
Sum the padding left + right + vertical border of the cell to return the length between txt of 2 adjacent cells.
Parameters:
Name | Type | Description |
---|---|---|
style |
object | the style state of the store. |
the lentgh between the text of 2 adjacent cells .
number
# static exports.getTableBorderWidth(style) → {number}
Calculate the total width of border of the table (body, head and cell) to take into account in the width of table.
Parameters:
Name | Type | Description |
---|---|---|
style |
object | the style state of the store. |
the sum of the widths of the table borders .
number
# static exports.renderWithStore(ui, contextValues, renderOptions) → {React.ReactElement}
Gives a provider fortesting of each needing the access to the store
Parameters:
Name | Type | Description |
---|---|---|
ui |
React.ReactElement | array | the component(s) to test |
contextValues |
object | the values of the states used by the component and needed for test |
renderOptions |
object | option oject to pass to the render method |
- the result of the render method with the ui being wrapped by the provider
React.ReactElement
# static exports.resolveCellFontStyle(ref, style) → {object}
take the style and root html node style to resolve the font style of the cell (converting inherit or undefined into actual style).
Parameters:
Name | Type | Description |
---|---|---|
ref |
HTMLElement | the root html node. |
style |
object | the style state of the store. |
- the head and body font style object with keys fontFamily, fontSize and fontWeight.
object