# new SortMenu(props) → {React.ReactElement}
Overview
Displays categories and orders to sort by. Categories are stored inside a virtualized list.Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object | Any other props will be forwarded to the Menu component. |
|
ContentProps |
Object |
<optional> |
Props applied to content elements. |
ContentProps.categories |
Array.<Object> |
<optional> |
The array of categories to sort by. |
ContentProps.categories[].label |
string |
<optional> |
The label of a category. |
ContentProps.categories[].value |
string |
<optional> |
The value of a category. |
ContentProps.chooseOrder |
boolean |
<optional> |
If |
ContentProps.onCategoryChange |
function |
<optional> |
The callback fired when category was changed. |
ContentProps.onOrderChange |
function |
<optional> |
The callback fired when order was changed. |
ContentProps.order |
"asc" | "desc" |
<optional> |
The currently selected order. |
ContentProps.RadioComponent |
React.ReactNode |
<optional> |
The component used to render radio button elements. |
ContentProps.rowHeight |
number | string |
<optional> |
The height of a row in the virtualized radio button group. |
ContentProps.value |
string |
<optional> |
The currently selected category. |
Methods
# static compareValues(key, orderopt) → {function}
Overview
Compares property values from sorted objects.Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string | The value of a property from sorted objects. |
||
order |
"asc" | "desc" |
<optional> |
"asc" | The order of sorting. |
- The function that compares objects.
# static createCategories(categories, noneLabelopt, noneValueopt) → {Array.<Object>}
Overview
Creates categories where labels and values are the same.Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
categories |
Array.<string> | The array of strings that will be used as labels and values. |
||
noneLabel |
string |
<optional> |
"none" | The label used to reset filtration. |
noneValue |
string |
<optional> |
"" | The value associated with |
- The array of categories.
# static createFullCategories(labels, values, noneLabelopt, noneValueopt) → {Array.<Object>}
Overview
Creates an array of "label-value" pairs that represent categories used to sort given data set. Values should be unique. Labels don't have this restriction.Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
labels |
Array.<string> | The array of labels used to sort a given set of data. |
||
values |
Array.<string> | The array of values associated with |
||
noneLabel |
string |
<optional> |
"none" | The label used to reset filtration. |
noneValue |
string |
<optional> |
"" | The value associated with |
- The array of categories.
# static simpleSort(objects, category, order) → {Array.<Object>}
Overview
Sorts an array of given objects by category in given order. UsescompareValues
to compare objects.
Parameters:
Name | Type | Description |
---|---|---|
objects |
Array.<Object> | The array of objects that is going to be sorted. |
category |
string | The name of a property to sort by. |
order |
"asc" | "desc" | The order of sorting. |
- Sorted array of objects.