@longline/aqua-ui 1.0.259 → 1.0.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controls/ListView/Column.d.ts +5 -0
- package/controls/ListView/ListView.d.ts +3 -0
- package/controls/ListView/ListView.js +11 -3
- package/controls/ListView/elements/sortItems.d.ts +1 -1
- package/controls/ListView/elements/sortItems.js +2 -2
- package/controls/PrimaryButton/PrimaryButton.js +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,11 @@ interface IColumnProps {
|
|
|
19
19
|
* Optional sort key. If not specified, column is not sortable.
|
|
20
20
|
*/
|
|
21
21
|
sort?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional function that, given any item, must return the value that
|
|
24
|
+
* sorting must work on.
|
|
25
|
+
*/
|
|
26
|
+
sortValue?: (item: any) => any;
|
|
22
27
|
/**
|
|
23
28
|
* If set, this is the default sort column. If not set, the first column will
|
|
24
29
|
* be the sort column.
|
|
@@ -10,6 +10,9 @@ interface IProps extends IListViewProps {
|
|
|
10
10
|
*/
|
|
11
11
|
children?: React.ReactElement<IColumnProps> | React.ReactElement<IColumnProps>[];
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Customizable `ListView` component.
|
|
15
|
+
*/
|
|
13
16
|
declare const ListView: {
|
|
14
17
|
({ data, dark, noheader, hover, striped, grid, total, singular, plural, shadow, ghost, rowHeight, columnsEditable, expanded, focusActive, virtual, overscan, ...props }: IProps): React.JSX.Element;
|
|
15
18
|
displayName: string;
|
|
@@ -71,8 +71,14 @@ var ListViewBase = function (props) {
|
|
|
71
71
|
var _f = React.useState((_b = sortColumn.reverse) !== null && _b !== void 0 ? _b : false), reverse = _f[0], setReverse = _f[1];
|
|
72
72
|
var _g = React.useState(null), data = _g[0], setData = _g[1];
|
|
73
73
|
React.useEffect(function () {
|
|
74
|
-
if
|
|
75
|
-
|
|
74
|
+
// Don't sort if no data is available yet:
|
|
75
|
+
if (!Array.isArray(props.data))
|
|
76
|
+
return;
|
|
77
|
+
// Find column corresponding to sort key. Abort if column now found.
|
|
78
|
+
var sortColumn = columns.find(function (c) { return c.sort == sort; });
|
|
79
|
+
if (!sortColumn)
|
|
80
|
+
return;
|
|
81
|
+
setData(sortItems(props.data, sort, reverse, sortColumn.sortValue));
|
|
76
82
|
}, [props.data, sort, reverse]);
|
|
77
83
|
// If children change, then update columns state.
|
|
78
84
|
React.useEffect(function () {
|
|
@@ -124,7 +130,9 @@ var ListViewBase = function (props) {
|
|
|
124
130
|
}
|
|
125
131
|
return (React.createElement(Table, __assign({}, otherProps, { data: data, columns: columns, sort: sort, reverse: reverse, onSortClick: handleSort, columnsMode: columnsMode, onOpenColumns: handleColumns, onCheck: props.onCheck ? handleCheck : null, onChangeColumns: handleChangeColumns, onCloseColumns: function () { return setColumnsMode(false); }, onResetColumns: handleResetColumns })));
|
|
126
132
|
};
|
|
127
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Customizable `ListView` component.
|
|
135
|
+
*/
|
|
128
136
|
var ListView = function (_a) {
|
|
129
137
|
var _b = _a.data, data = _b === void 0 ? null : _b, _c = _a.dark, dark = _c === void 0 ? false : _c, _d = _a.noheader, noheader = _d === void 0 ? false : _d, _e = _a.hover, hover = _e === void 0 ? false : _e, _f = _a.striped, striped = _f === void 0 ? false : _f, _g = _a.grid, grid = _g === void 0 ? false : _g, _h = _a.total, total = _h === void 0 ? false : _h, _j = _a.singular, singular = _j === void 0 ? "record" : _j, _k = _a.plural, plural = _k === void 0 ? "records" : _k, _l = _a.shadow, shadow = _l === void 0 ? false : _l, _m = _a.ghost, ghost = _m === void 0 ? false : _m, _o = _a.rowHeight, rowHeight = _o === void 0 ? 48 : _o, _p = _a.columnsEditable, columnsEditable = _p === void 0 ? false : _p, _q = _a.expanded, expanded = _q === void 0 ? false : _q, _r = _a.focusActive, focusActive = _r === void 0 ? false : _r, _s = _a.virtual, virtual = _s === void 0 ? false : _s, _t = _a.overscan, overscan = _t === void 0 ? 10 : _t, props = __rest(_a, ["data", "dark", "noheader", "hover", "striped", "grid", "total", "singular", "plural", "shadow", "ghost", "rowHeight", "columnsEditable", "expanded", "focusActive", "virtual", "overscan"]);
|
|
130
138
|
return React.createElement(ListViewBase, __assign({ data: data, dark: dark, noheader: noheader, hover: hover, striped: striped, grid: grid, total: total, singular: singular, plural: plural, shadow: shadow, ghost: ghost, rowHeight: rowHeight, columnsEditable: columnsEditable, expanded: expanded, focusActive: focusActive, virtual: virtual, overscan: overscan }, props));
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Sort function. By default, this sorts items by comparing the "sort" field.
|
|
3
3
|
* However, a custom value retrieval function can be provided.
|
|
4
4
|
*/
|
|
5
|
-
declare const sortItems: (items: any[], sort: string, reverse: boolean, onSortValue?: (item: any
|
|
5
|
+
declare const sortItems: (items: any[], sort: string, reverse: boolean, onSortValue?: (item: any) => any) => any[];
|
|
6
6
|
export { sortItems };
|
|
@@ -17,8 +17,8 @@ var sortItems = function (items, sort, reverse, onSortValue) {
|
|
|
17
17
|
var _a, _b;
|
|
18
18
|
if (a == null || b == null)
|
|
19
19
|
return 0;
|
|
20
|
-
var vA = (_a = (onSortValue ? onSortValue(a
|
|
21
|
-
var vB = (_b = (onSortValue ? onSortValue(b
|
|
20
|
+
var vA = (_a = (onSortValue ? onSortValue(a) : a[sort])) !== null && _a !== void 0 ? _a : "";
|
|
21
|
+
var vB = (_b = (onSortValue ? onSortValue(b) : b[sort])) !== null && _b !== void 0 ? _b : "";
|
|
22
22
|
// Trim strings, because leading spaces will throw sort off.
|
|
23
23
|
if (typeof vA === 'string')
|
|
24
24
|
vA = vA.trim();
|
|
@@ -54,7 +54,7 @@ var PrimaryButtonStyled = styled(PrimaryButtonBase).attrs(function (p) {
|
|
|
54
54
|
outlineColor: (p.positive || p.negative) ? p.theme.colors.primary[1]
|
|
55
55
|
: p.theme.colors.accent
|
|
56
56
|
};
|
|
57
|
-
})(templateObject_2 || (templateObject_2 = __makeTemplateObject([" \n // Size:\n height:
|
|
57
|
+
})(templateObject_2 || (templateObject_2 = __makeTemplateObject([" \n // Size:\n height: 46px; // was 56\n padding-left: 12px; // was 16\n padding-right: 12px; // was 16\n min-width: 90px;\n \n // Font:\n font: ", ";\n color: ", ";\n\n // Presentation:\n background-color: ", ";\n transition: \n background-color ease-in-out ", "ms, \n box-shadow ease-in-out ", "ms;\n border-radius: ", "px;\n border: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n\n // Content:\n display: flex;\n align-items: center;\n white-space: nowrap;\n flex-wrap: nowrap; \n justify-content: center; \n gap: 2px; // was 4\n\n box-shadow: ", ";\n &:hover {\n background-color: ", ";\n box-shadow: ", ";\n }\n &:active {\n background-color: ", ";\n box-shadow: none;\n }\n &:focus {\n outline: solid 2px ", ";\n }\n \n svg {\n width: 24px;\n height: 24px; \n }\n\n ", "\n"], [" \n // Size:\n height: 46px; // was 56\n padding-left: 12px; // was 16\n padding-right: 12px; // was 16\n min-width: 90px;\n \n // Font:\n font: ", ";\n color: ", ";\n\n // Presentation:\n background-color: ", ";\n transition: \n background-color ease-in-out ", "ms, \n box-shadow ease-in-out ", "ms;\n border-radius: ", "px;\n border: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n\n // Content:\n display: flex;\n align-items: center;\n white-space: nowrap;\n flex-wrap: nowrap; \n justify-content: center; \n gap: 2px; // was 4\n\n box-shadow: ", ";\n &:hover {\n background-color: ", ";\n box-shadow: ", ";\n }\n &:active {\n background-color: ", ";\n box-shadow: none;\n }\n &:focus {\n outline: solid 2px ", ";\n }\n \n svg {\n width: 24px;\n height: 24px; \n }\n\n ", "\n"
|
|
58
58
|
/**
|
|
59
59
|
* Primary buttons denote the primary action. They may have icons or not and
|
|
60
60
|
* have three colors: `positive`, `negative`, and themed (the default).
|