Members
Methods
# static arrayToDisplay(value, prop, delim) → {array}
Convert an array of objects into a string using prop
Parameters:
Name | Type | Description |
---|---|---|
value |
Array
|
Array to process |
prop |
string
|
Display property (also used for sorting) |
delim |
string
|
String to place between each value |
array
# static arrayToUrls(value, slug, sameTab, displayProp, idProp) → {object}
Convert an object or array of objects to urls. Intended for use with DetailList/DetailContent component
Parameters:
Name | Type | Description |
---|---|---|
value |
Object
|
Array
|
thing or things to turn into urls |
slug |
string
|
url slug |
sameTab |
boolean
|
open in same tab |
displayProp |
string
|
display property for sorthing and link text |
idProp |
string
|
id to use with slug to generate url |
object
# static capitalizeFirstLetter(string) → {string}
Method to capitalize the first letter of a string
Parameters:
Name | Type | Description |
---|---|---|
string |
string
|
The capitalized string
string
Examples
capitalizeFirstLetter('hello') => 'Hello'
capitalizeFirstLetter('Hello') => 'Hello'
# static caseless(valueA, valueB) → {number}
Cases, we don't need no stinking cases.
Parameters:
Name | Type | Description |
---|---|---|
valueA |
*
|
|
valueB |
*
|
- 0 if equal, -1 if valueA < valueB, 1 if valueA > valueB
number
Examples
const result = caseless('a', 'A');
// result === 0
const result = caseless('a', 'b');
// result === -1
const result = caseless('b', 'a');
// result === 1
const result = caseless('a', '');
// result === -1
# static convertToLinkFormat(linkFormat, dataNode) → {string}
Replaces placeholders in a link format string with values from a data node object.
Parameters:
Name | Type | Description |
---|---|---|
linkFormat |
string
|
The link format string with placeholders wrapped in curly braces. |
dataNode |
Object
|
The data node object containing values to replace the placeholders. |
The link format string with placeholders replaced with values from the data node object.
string
# static createZoomOption(label, value, extent) → {object}
Create a zoom option object
Parameters:
Name | Type | Description |
---|---|---|
label |
*
|
|
value |
*
|
|
extent |
*
|
- zoom option object
object
# static currencyFormatter(inc) → {string}
Return a currency string from either an ag grid cell object or string
Parameters:
Name | Type | Description |
---|---|---|
inc |
object
|
string
|
ag grid cell params |
a currency string
string
Example
currencyFormatter(1234.56) => '$1,234.56'
# static dateFormatter(inc) → {string}
Return a date string from either an ag grid cell object or string
Parameters:
Name | Type | Description |
---|---|---|
inc |
string
|
object
|
The date string or ag grid cell object |
The date as a string
string
# static dateToString(date) → {string}
Convert a date to a string with zero padding
Parameters:
Name | Type | Description |
---|---|---|
date |
Date
|
The date as a string
string
# static floatCompare(valueA, valueB) → {number}
Used to correctly handle sorting floats
Parameters:
Name | Type | Description |
---|---|---|
valueA |
||
valueB |
- 0 if equal, -1 if valueA < valueB, 1 if valueA > valueB
number
Examples
const result = floatCompare('1.1', '1.2');
// result === -1
const result = floatCompare('1.2', '1.1');
// result === 1
const result = floatCompare('1.1', '1.1');
// result === 0
# static floatFormatter(inc, decimalPlaces) → {string}
Return a currency string from either an ag grid cell object or string
Parameters:
Name | Type | Description |
---|---|---|
inc |
object
|
string
|
ag grid cell params |
decimalPlaces |
number
|
number of decimal places to round to |
string
# static headerColor(theme) → {string}
Get the color for the header text
Parameters:
Name | Type | Description |
---|---|---|
theme |
object
|
The color for the header text
string
# static isObject(objValue) → {boolean}
Check if a value is an object
Parameters:
Name | Type | Description |
---|---|---|
objValue |
any
|
- true if object, false if not
boolean
Examples
const result = isObject({ a: 1 });
// result === true
const result = isObject(1);
// result === false
const result = isObject(null);
// result === false
const result = isObject(undefined);
// result === false
const result = isObject('a');
// result === false
const result = isObject([1, 2, 3]);
// result === false
const result = isObject(new Date());
// result === false
const result = isObject(new Map());
// result === false
# static mergeDeep(target, source) → {object}
Deeply clone an object.
Parameters:
Name | Type | Description |
---|---|---|
target |
object
|
object to merge things into |
source |
object
|
data source |
- cloned object
object
Examples
const result = mergeDeep({ a: 1 }, { b: 2 });
// result === { a: 1, b: 2 }
const result = mergeDeep({ a: 1 }, { a: 2 });
// result === { a: 2 }
# static modifyColorOpacity(color, opacity) → {string}
Useful when you want/need to share an RGBA color in more than one place with different opacity levels.
If you want to show a color on a map with opacity 0.6 but want the legend value to use the same color
but with opacity 1.0.
Parameters:
Name | Type | Description |
---|---|---|
color |
string
|
an rgba color |
opacity |
number
|
the opacity to convert to |
An rgba color with it's opacity modified
string
# static objectReducer(obj, path, separator) → {any}
Given an object and a path, return the value at that path. If the path is not found, return undefined.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object
|
object to search |
path |
string
|
path to value |
separator |
string
|
separator for path (default: '.') |
value at path
any
Example
const obj = { a: { b: { c: 1 } } };
const result = objectReducer(obj, 'a.b.c');
// result === 1
# static objectsToString(items, key, separator) → {string}
Convert array of objects to a string for a given key and separator
Parameters:
Name | Type | Description |
---|---|---|
items |
||
key |
string
|
|
separator |
string
|
string
# static processGenericLayout(layout) → {object}
Process a layout object
Parameters:
Name | Type | Description |
---|---|---|
layout |
object
|
- The processed layout object
object
# static processLayout(layout) → {object}
Simple layout process method to convert the layout object into a format that the layout builder can use.
If you are using GenericForm you should be using the useFormLayout and parseFormLayout methods instead.
Parameters:
Name | Type | Description |
---|---|---|
layout |
object
|
The layout object to process |
- The processed layout object
object
# static sortOn(items, prop) → {Array}
Sorts array of objects by a given prop and returns a copy
Parameters:
Name | Type | Description |
---|---|---|
items |
||
prop |
- sorted array
Array
Example
const result = sortOn([{ label: 'b' }, { label: 'a' }], 'label');
// result === [{ label: 'a' }, { label: 'b' }]
# static specialColor(theme) → {string}
Get the color for the special text
Parameters:
Name | Type | Description |
---|---|---|
theme |
object
|
The color for the special text
string
# static zeroPad(num, size) → {string}
Number with zero padding
Parameters:
Name | Type | Description |
---|---|---|
num |
number
|
Number to pad |
size |
number
|
amount of padding |
The padded number
string
# static zoomableOption(item, labelProp, valueProp) → {object}
Create a zoom option object from a zoomable item
Parameters:
Name | Type | Description |
---|---|---|
item |
object
|
|
fields |
object
|
fields object |
fields.extent |
object
|
extent object |
labelProp |
string
|
|
valueProp |
string
|
- zoom option object
object
# static zoomablesOptions(zoomables, labelProp, valueProp) → {Array.<Object>}
Get a list of zoom options from a list of zoomable items
Parameters:
Name | Type | Description |
---|---|---|
zoomables |
Array.<Object>
|
list of zoomable items |
labelProp |
string
|
property to use for label |
valueProp |
string
|
property to use for value |
Array.<Object>
# inner isEmpty(value) → {boolean}
Helper method to check if a value is null, undefined, or ''
Parameters:
Name | Type | Description |
---|---|---|
value |
string
|
number
|
- true if empty, false if not
boolean
Example
isEmpty('') // true
isEmpty(null) // true
isEmpty(undefined) // true
isEmpty(0) // false