@longline/aqua-ui 1.0.85 → 1.0.87

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.
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Selector } from '../../inputs/Selector';
3
3
  var Body = function (props) {
4
- return (React.createElement("tbody", null, props.data.map(function (row, index) {
4
+ return (React.createElement("tbody", null, Array.isArray(props.data) && props.data.map(function (row, index) {
5
5
  return React.createElement("tr", { key: index,
6
6
  // Set classnames for tr; styles are in Table.
7
7
  className: [
@@ -13,14 +13,12 @@ import * as React from 'react';
13
13
  import { HeaderCell } from './HeaderCell';
14
14
  import { Selector } from '../../inputs/Selector';
15
15
  import { SVG } from '../../svg';
16
- import { useTheme } from 'styled-components';
17
16
  import { HeaderButton } from './HeaderButton';
18
17
  var Header = function (props) {
19
- var theme = useTheme();
20
18
  // Are ALL items checked?
21
- var allChecked = props.data.map(function (x) { return !!x.checked; }).reduce(function (acc, cur) { return acc && !!cur; }, true) == true;
19
+ var allChecked = Array.isArray(props.data) ? props.data.map(function (x) { return !!x.checked; }).reduce(function (acc, cur) { return acc && !!cur; }, true) == true : false;
22
20
  // Are NO items checked?
23
- var noneChecked = props.data.map(function (x) { return !!x.checked; }).reduce(function (acc, cur) { return acc || !!cur; }, false) == false;
21
+ var noneChecked = Array.isArray(props.data) ? props.data.map(function (x) { return !!x.checked; }).reduce(function (acc, cur) { return acc || !!cur; }, false) == false : true;
24
22
  var indeterminate = !allChecked && !noneChecked;
25
23
  return (React.createElement("thead", null,
26
24
  React.createElement("tr", null,
@@ -2,7 +2,7 @@ interface IListViewProps {
2
2
  /**
3
3
  * Array of data to show in the table
4
4
  */
5
- data: any[];
5
+ data: any[] | null | undefined;
6
6
  /**
7
7
  * If set, show no header.
8
8
  * @default false
@@ -46,9 +46,10 @@ var ListViewBase = function (props) {
46
46
  var sortColumn = (_a = columns.find(function (c) { return c.defaultSort; })) !== null && _a !== void 0 ? _a : columns[0];
47
47
  var _e = React.useState(sortColumn.sort), sort = _e[0], setSort = _e[1];
48
48
  var _f = React.useState((_b = sortColumn.reverse) !== null && _b !== void 0 ? _b : false), reverse = _f[0], setReverse = _f[1];
49
- var _g = React.useState(sortItems(props.data, sort, reverse)), data = _g[0], setData = _g[1];
49
+ var _g = React.useState(null), data = _g[0], setData = _g[1];
50
50
  React.useEffect(function () {
51
- setData(sortItems(props.data, sort, reverse));
51
+ if (Array.isArray(props.data))
52
+ setData(sortItems(props.data, sort, reverse));
52
53
  }, [props.data, sort, reverse]);
53
54
  // If children change, then update columns state.
54
55
  React.useEffect(function () {
@@ -70,6 +71,8 @@ var ListViewBase = function (props) {
70
71
  var handleCheck = function (index) {
71
72
  if (!props.onCheck)
72
73
  return;
74
+ if (!Array.isArray(data))
75
+ return;
73
76
  var newData = data.map(function (d, idx) {
74
77
  if (index === true)
75
78
  return __assign(__assign({}, d), { checked: true });
@@ -3,7 +3,7 @@ interface IProps {
3
3
  /** @ignore */
4
4
  className?: string;
5
5
  /**
6
- * Component to show when there is no data (data is `null` or data is `[]`).
6
+ * Component to show when there is no data (data is `null`, `undefined` or `[]`).
7
7
  * The component is placed under the header, and the component is responsible
8
8
  * for any styling.
9
9
  * If not set, a default component is shown.
@@ -24,7 +24,7 @@ var NoDataBase = function (props) {
24
24
  !props.component && React.createElement(DefaultMessage, null, "Your query returned no data. Your filter might be too restrictive.")));
25
25
  };
26
26
  var DefaultMessage = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n"], ["\n"])));
27
- var NoDataStyled = styled(NoDataBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 64px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n ", " {\n margin: 0 16px 0 16px;\n color: ", ";\n user-select: none;\n padding: 8px 16px 8px 16px;\n border-radius: ", "px;\n background: ", ";\n }\n"], ["\n position: absolute;\n top: 64px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n ", " {\n margin: 0 16px 0 16px;\n color: ", ";\n user-select: none;\n padding: 8px 16px 8px 16px;\n border-radius: ", "px;\n background: ", ";\n }\n"])), DefaultMessage, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.dark ? p.theme.colors.neutral[10] : p.theme.colors.neutral[10]; });
27
+ var NoDataStyled = styled(NoDataBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 64px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n z-index: 1;\n ", " {\n margin: 0 16px 0 16px;\n color: ", ";\n user-select: none;\n padding: 8px 16px 8px 16px;\n border-radius: ", "px;\n background: ", ";\n }\n"], ["\n position: absolute;\n top: 64px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n z-index: 1;\n ", " {\n margin: 0 16px 0 16px;\n color: ", ";\n user-select: none;\n padding: 8px 16px 8px 16px;\n border-radius: ", "px;\n background: ", ";\n }\n"])), DefaultMessage, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.dark ? p.theme.colors.neutral[10] : p.theme.colors.neutral[10]; });
28
28
  var NoData = function (props) { return React.createElement(NoDataStyled, __assign({}, props)); };
29
29
  export { NoData };
30
30
  var templateObject_1, templateObject_2;
@@ -77,14 +77,14 @@ var TableBase = function (_a) {
77
77
  props.columnsMode &&
78
78
  React.createElement(Anchor, { right: "32px", top: "64px" },
79
79
  React.createElement(ColumnsManager, { columns: props.columns, onChange: props.onChangeColumns, onClose: props.onCloseColumns, onReset: props.onResetColumns })),
80
- (props.data == null || props.data.length == 0) &&
80
+ (!Array.isArray(props.data) || props.data.length == 0) &&
81
81
  React.createElement(NoData, { dark: props.dark, component: props.noData }),
82
- React.createElement(AuxHolder, { ref: auxRef, style: { visibility: (props.active && props.aux && props.data.includes(props.active)) ? 'visible' : 'hidden' } }, (props.active && props.aux && props.data.includes(props.active)) && React.cloneElement(props.aux, { value: props.active })),
82
+ React.createElement(AuxHolder, { ref: auxRef, style: { visibility: (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) ? 'visible' : 'hidden' } }, (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) && React.cloneElement(props.aux, { value: props.active })),
83
83
  React.createElement(Inner, { onScroll: handleScroll, ref: innerRef },
84
84
  React.createElement("table", { className: className },
85
85
  props.noheader != true && React.createElement(Header, __assign({}, props, { columns: activeColumns, onOpenColumns: props.onOpenColumns })),
86
86
  React.createElement(Body, __assign({}, props, { columns: activeColumns })))),
87
- props.total && React.createElement(Total, { value: props.data.length, singular: props.singular, plural: props.plural })));
87
+ props.total && Array.isArray(props.data) && React.createElement(Total, { value: props.data.length, singular: props.singular, plural: props.plural })));
88
88
  };
89
89
  var AuxHolder = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n // The AuxHolder is 16px right of the table. Its \"top\" position will\n // be set by the table scroll handler.\n left: calc(100% + 16px);\n z-index: 1;\n"], ["\n position: absolute;\n // The AuxHolder is 16px right of the table. Its \"top\" position will\n // be set by the table scroll handler.\n left: calc(100% + 16px);\n z-index: 1;\n"])));
90
90
  var Wrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Size and position. A table fills its container.\n position: relative;\n width: 100%;\n height: 100%;\n background-color: ", ";\n"], ["\n // Size and position. A table fills its container.\n position: relative;\n width: 100%;\n height: 100%;\n background-color: ", ";\n"])), function (p) { return p.$dark ? p.theme.colors.primary[3] : p.theme.colors.neutral[100]; });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",