orc-shared 5.10.1-dev.5 → 5.10.1-dev.7
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/dist/components/AppFrame/MenuItem.js +3 -12
- package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
- package/dist/components/ToastList.js +95 -64
- package/dist/getTheme.js +0 -5
- package/dist/utils/toastHelper.js +52 -0
- package/package.json +1 -1
- package/src/components/AppFrame/MenuItem.js +1 -9
- package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
- package/src/components/MaterialUI/DataDisplay/Table.test.js +20 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
- package/src/components/ToastList.js +79 -90
- package/src/components/ToastList.test.js +29 -103
- package/src/getTheme.js +0 -5
- package/src/utils/toastHelper.js +8 -0
- package/src/utils/toastHelper.test.js +41 -0
- package/dist/components/CategoryList.js +0 -197
- package/dist/components/List/DataCell.js +0 -129
- package/dist/components/List/HeadCell.js +0 -125
- package/dist/components/List/HeadRow.js +0 -73
- package/dist/components/List/List.js +0 -274
- package/dist/components/List/Row.js +0 -109
- package/dist/components/List/enhanceColumnDefs.js +0 -111
- package/dist/components/List/index.js +0 -59
- package/src/components/CategoryList.js +0 -140
- package/src/components/CategoryList.test.js +0 -667
- package/src/components/List/DataCell.js +0 -77
- package/src/components/List/DataCell.test.js +0 -357
- package/src/components/List/HeadCell.js +0 -105
- package/src/components/List/HeadCell.test.js +0 -331
- package/src/components/List/HeadRow.js +0 -21
- package/src/components/List/HeadRow.test.js +0 -27
- package/src/components/List/List.js +0 -162
- package/src/components/List/List.test.js +0 -705
- package/src/components/List/Row.js +0 -72
- package/src/components/List/Row.test.js +0 -194
- package/src/components/List/enhanceColumnDefs.js +0 -54
- package/src/components/List/enhanceColumnDefs.test.js +0 -179
- package/src/components/List/index.js +0 -6
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import transition from "styled-transition-group";
|
|
4
|
-
import { TransitionGroup } from "react-transition-group";
|
|
5
2
|
import ReactDOM from "react-dom";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
5
|
+
import Icon from "./MaterialUI/DataDisplay/Icon";
|
|
6
|
+
import { getToastColor } from "../utils/toastHelper";
|
|
7
|
+
import { CSSTransition, TransitionGroup } from "react-transition-group";
|
|
10
8
|
|
|
11
9
|
const portal = document.getElementById("toast") || document.createElement("div");
|
|
12
10
|
/* istanbul ignore else */
|
|
@@ -15,100 +13,91 @@ if (!portal.parent) {
|
|
|
15
13
|
document.body.appendChild(portal);
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
const
|
|
16
|
+
const useStyles = makeStyles(theme => ({
|
|
17
|
+
toastBox: props => {
|
|
18
|
+
const toastColor = getToastColor(theme, props.toastType);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
return {
|
|
21
|
+
display: "flex",
|
|
22
|
+
width: "390px",
|
|
23
|
+
marginTop: "10px",
|
|
24
|
+
padding: "17px",
|
|
25
|
+
borderRadius: "5px",
|
|
26
|
+
fontSize: "14px",
|
|
27
|
+
color: "white",
|
|
28
|
+
backgroundColor: toastColor,
|
|
29
|
+
zIndex: 10000,
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
&:enter {
|
|
37
|
-
transform: translateX(200%);
|
|
38
|
-
}
|
|
39
|
-
&:enter-active {
|
|
40
|
-
transform: translateX(0);
|
|
41
|
-
transition: transform ${toastTransitionTime}ms ease-out;
|
|
42
|
-
}
|
|
43
|
-
&:exit {
|
|
44
|
-
transform-origin: top;
|
|
45
|
-
transform: scale(1,1);
|
|
46
|
-
}
|
|
47
|
-
&:exit ~ & {
|
|
48
|
-
transform: translateY(0);
|
|
49
|
-
}
|
|
50
|
-
&:exit-active {
|
|
51
|
-
transform: scale(1, 0.001);
|
|
52
|
-
transition: transform ${toastTransitionTime}ms ease-out;
|
|
53
|
-
}
|
|
54
|
-
&:exit-active ~ & {
|
|
55
|
-
transition: transform ${toastTransitionTime}ms ease-out;
|
|
56
|
-
transform: translateY(-100%);
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
ToastBox.defaultProps = {
|
|
60
|
-
timeout: toastTransitionTime,
|
|
61
|
-
unmountOnExit: true,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const ToastIcon = styled(Icon).attrs(props => ({
|
|
65
|
-
id: getThemeProp(["icons", "toast", props => props.type], "bubble-chat-2")(props),
|
|
66
|
-
}))`
|
|
67
|
-
font-size: 20px;
|
|
68
|
-
margin-right: 16px;
|
|
69
|
-
stroke-width: 2px;
|
|
70
|
-
`;
|
|
31
|
+
"& > *": {
|
|
32
|
+
marginTop: "auto",
|
|
33
|
+
marginBottom: "auto",
|
|
34
|
+
},
|
|
71
35
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
36
|
+
"&.enter": {
|
|
37
|
+
transform: "translateX(200%)",
|
|
38
|
+
},
|
|
39
|
+
"&.enter-active": {
|
|
40
|
+
transform: "translateX(0)",
|
|
41
|
+
transition: "transform 300ms ease-out",
|
|
42
|
+
},
|
|
43
|
+
"&.exit": {
|
|
44
|
+
transformOrigin: "top",
|
|
45
|
+
transform: "scale(1,1)",
|
|
46
|
+
},
|
|
47
|
+
"&.exit ~ &": {
|
|
48
|
+
transform: "translateY(0)",
|
|
49
|
+
},
|
|
50
|
+
"&.exit-active": {
|
|
51
|
+
transform: "scale(1, 0.001)",
|
|
52
|
+
transition: "transform 300ms ease-out",
|
|
53
|
+
},
|
|
54
|
+
"&.exit-active ~ &": {
|
|
55
|
+
transition: "transform 300ms ease-out",
|
|
56
|
+
transform: "translateY(-100%)",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
listWrapper: {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
top: "40px",
|
|
63
|
+
right: "16px",
|
|
64
|
+
display: "flex",
|
|
65
|
+
flexDirection: "column",
|
|
66
|
+
},
|
|
67
|
+
closeIcon: {
|
|
68
|
+
padding: "2px",
|
|
69
|
+
borderRadius: "2px",
|
|
70
|
+
strokeWidth: "2px",
|
|
71
|
+
cursor: "pointer",
|
|
72
|
+
marginLeft: "auto",
|
|
73
|
+
fontSize: "20px",
|
|
74
|
+
},
|
|
75
|
+
}));
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
77
|
+
export const Toast = ({ message = "[No message]", type = "", closeFunc, ...props }) => {
|
|
78
|
+
const classes = useStyles({ toastType: type });
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
return (
|
|
81
|
+
<CSSTransition in={props.in} timeout={300} unmountOnExit>
|
|
82
|
+
<div className={classes.toastBox}>
|
|
83
|
+
<span>{typeof message === "string" ? message : <FormattedMessage {...message} />}</span>
|
|
84
|
+
{closeFunc ? <Icon id="close" className={classes.closeIcon} onClick={closeFunc} /> : null}
|
|
85
|
+
</div>
|
|
86
|
+
</CSSTransition>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
95
89
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
top: 40px;
|
|
99
|
-
right: 16px;
|
|
100
|
-
display: flex;
|
|
101
|
-
flex-direction: column;
|
|
102
|
-
`;
|
|
90
|
+
export const ToastList = ({ toasts }) => {
|
|
91
|
+
const classes = useStyles();
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<ListWrapper>
|
|
93
|
+
return ReactDOM.createPortal(
|
|
94
|
+
<TransitionGroup className={classes.listWrapper}>
|
|
107
95
|
{toasts.map((props, idx) => (
|
|
108
96
|
<Toast key={"toast" + idx} {...props} />
|
|
109
97
|
))}
|
|
110
|
-
</
|
|
98
|
+
</TransitionGroup>,
|
|
111
99
|
portal,
|
|
112
100
|
);
|
|
101
|
+
};
|
|
113
102
|
|
|
114
103
|
export default ToastList;
|
|
@@ -3,10 +3,9 @@ import ReactDOM from "react-dom";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { IntlProvider } from "react-intl";
|
|
5
5
|
import { Ignore } from "unexpected-reaction";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import FullToastList, { Toast, ToastBox, ToastIcon, CloseIcon } from "./ToastList";
|
|
6
|
+
import Icon from "./MaterialUI/DataDisplay/Icon";
|
|
7
|
+
import FullToastList, { Toast } from "./ToastList";
|
|
8
|
+
import { CSSTransition } from "react-transition-group";
|
|
10
9
|
|
|
11
10
|
class RenderToast extends React.Component {
|
|
12
11
|
render() {
|
|
@@ -47,10 +46,11 @@ describe("ToastList", () => {
|
|
|
47
46
|
return expect(
|
|
48
47
|
toastRoot,
|
|
49
48
|
"to contain",
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
<CSSTransition in>
|
|
50
|
+
<div>
|
|
51
|
+
<span>[No message]</span>
|
|
52
|
+
</div>
|
|
53
|
+
</CSSTransition>,
|
|
54
54
|
);
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -70,10 +70,11 @@ describe("Toast", () => {
|
|
|
70
70
|
</Provider>,
|
|
71
71
|
"when mounted",
|
|
72
72
|
"to satisfy",
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
<CSSTransition in>
|
|
74
|
+
<div>
|
|
75
|
+
<span>this is a toast</span>
|
|
76
|
+
</div>
|
|
77
|
+
</CSSTransition>,
|
|
77
78
|
));
|
|
78
79
|
|
|
79
80
|
it("shows a translated message", () =>
|
|
@@ -91,10 +92,11 @@ describe("Toast", () => {
|
|
|
91
92
|
</Provider>,
|
|
92
93
|
"when mounted",
|
|
93
94
|
"to satisfy",
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
<CSSTransition in>
|
|
96
|
+
<div>
|
|
97
|
+
<span>This is a toast</span>
|
|
98
|
+
</div>
|
|
99
|
+
</CSSTransition>,
|
|
98
100
|
));
|
|
99
101
|
|
|
100
102
|
it("shows an icon", () =>
|
|
@@ -110,10 +112,11 @@ describe("Toast", () => {
|
|
|
110
112
|
</Provider>,
|
|
111
113
|
"when mounted",
|
|
112
114
|
"to satisfy",
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
<CSSTransition in>
|
|
116
|
+
<div>
|
|
117
|
+
<Ignore />
|
|
118
|
+
</div>
|
|
119
|
+
</CSSTransition>,
|
|
117
120
|
));
|
|
118
121
|
|
|
119
122
|
it("shows a close icon if a close function is given", () =>
|
|
@@ -129,88 +132,11 @@ describe("Toast", () => {
|
|
|
129
132
|
</Provider>,
|
|
130
133
|
"when mounted",
|
|
131
134
|
"to satisfy",
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
<CSSTransition in>
|
|
136
|
+
<div>
|
|
137
|
+
<Ignore />
|
|
138
|
+
<Icon id="close" onClick={expect.it("to be a function")} />
|
|
139
|
+
</div>
|
|
140
|
+
</CSSTransition>,
|
|
137
141
|
));
|
|
138
|
-
|
|
139
|
-
describe("with types", () => {
|
|
140
|
-
let theme;
|
|
141
|
-
beforeEach(() => {
|
|
142
|
-
theme = {
|
|
143
|
-
colors: {
|
|
144
|
-
toasts: {
|
|
145
|
-
test: "#ff0000",
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
icons: {
|
|
149
|
-
toast: {
|
|
150
|
-
test: "test-icon",
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("renders a default type", () =>
|
|
157
|
-
expect(
|
|
158
|
-
<Provider
|
|
159
|
-
store={{
|
|
160
|
-
subscribe: () => {},
|
|
161
|
-
dispatch: () => {},
|
|
162
|
-
getState: () => ({}),
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
<ThemeProvider theme={theme}>
|
|
166
|
-
<Toast in />
|
|
167
|
-
</ThemeProvider>
|
|
168
|
-
</Provider>,
|
|
169
|
-
"when mounted",
|
|
170
|
-
"to have style rules satisfying",
|
|
171
|
-
"to contain",
|
|
172
|
-
"background-color: #999;",
|
|
173
|
-
).and("when mounted", "to contain", <Icon id="bubble-chat-2" />));
|
|
174
|
-
|
|
175
|
-
it("renders a set type", () =>
|
|
176
|
-
expect(
|
|
177
|
-
<Provider
|
|
178
|
-
store={{
|
|
179
|
-
subscribe: () => {},
|
|
180
|
-
dispatch: () => {},
|
|
181
|
-
getState: () => ({}),
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
<ThemeProvider theme={theme}>
|
|
185
|
-
<Toast in type="test" />
|
|
186
|
-
</ThemeProvider>
|
|
187
|
-
</Provider>,
|
|
188
|
-
"when mounted",
|
|
189
|
-
"to have style rules satisfying",
|
|
190
|
-
"to contain",
|
|
191
|
-
"background-color: #ff0000;",
|
|
192
|
-
).and("when mounted", "to contain", <Icon id="test-icon" />));
|
|
193
|
-
|
|
194
|
-
it("darkens close icon background on hover", () =>
|
|
195
|
-
expect(
|
|
196
|
-
<ThemeProvider theme={theme}>
|
|
197
|
-
<CloseIcon type="" />
|
|
198
|
-
</ThemeProvider>,
|
|
199
|
-
"when mounted",
|
|
200
|
-
"to have style rules satisfying",
|
|
201
|
-
"to contain",
|
|
202
|
-
":hover {background-color: " + shade(0.3, "#999") + ";}",
|
|
203
|
-
));
|
|
204
|
-
|
|
205
|
-
it("darkens close icon background on hover with set type", () =>
|
|
206
|
-
expect(
|
|
207
|
-
<ThemeProvider theme={theme}>
|
|
208
|
-
<CloseIcon type="test" />
|
|
209
|
-
</ThemeProvider>,
|
|
210
|
-
"when mounted",
|
|
211
|
-
"to have style rules satisfying",
|
|
212
|
-
"to contain",
|
|
213
|
-
":hover {background-color: " + shade(0.3, "#ff0000") + ";}",
|
|
214
|
-
));
|
|
215
|
-
});
|
|
216
142
|
});
|
package/src/getTheme.js
CHANGED
|
@@ -54,11 +54,6 @@ const baseTheme = {
|
|
|
54
54
|
Sale: "sales-scope",
|
|
55
55
|
Dependant: "dependent-scope",
|
|
56
56
|
},
|
|
57
|
-
// toast: {
|
|
58
|
-
// confirm: "checkmark-circle",
|
|
59
|
-
// warn: "warning",
|
|
60
|
-
// error: "cross-circle",
|
|
61
|
-
// },
|
|
62
57
|
prev: "arrow-small-left",
|
|
63
58
|
next: "arrow-small-right",
|
|
64
59
|
menu: "app-list",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getToastColor } from "./toastHelper";
|
|
2
|
+
|
|
3
|
+
describe("getToastColor", () => {
|
|
4
|
+
const theme = {
|
|
5
|
+
palette: {
|
|
6
|
+
error: {
|
|
7
|
+
main: "#FF0000",
|
|
8
|
+
},
|
|
9
|
+
warning: {
|
|
10
|
+
main: "#FFA500",
|
|
11
|
+
},
|
|
12
|
+
success: {
|
|
13
|
+
main: "#00FF00",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
it("should return error color", () => {
|
|
19
|
+
const toastColor = getToastColor(theme, "error");
|
|
20
|
+
|
|
21
|
+
return expect(toastColor, "to be", "#FF0000");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should return warning color", () => {
|
|
25
|
+
const toastColor = getToastColor(theme, "warn");
|
|
26
|
+
|
|
27
|
+
return expect(toastColor, "to be", "#FFA500");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should return success color", () => {
|
|
31
|
+
const toastColor = getToastColor(theme, "confirm");
|
|
32
|
+
|
|
33
|
+
return expect(toastColor, "to be", "#00FF00");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should return default color", () => {
|
|
37
|
+
const toastColor = getToastColor(theme, "test");
|
|
38
|
+
|
|
39
|
+
return expect(toastColor, "to be", "red");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = exports.CategoryRow = exports.CategoryList = exports.CategoryIndicator = exports.CategoryHeader = void 0;
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
|
-
var _recompose = require("recompose");
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
var _withScrollBox = _interopRequireDefault(require("../hocs/withScrollBox"));
|
|
10
|
-
var _useViewState3 = _interopRequireDefault(require("../hooks/useViewState"));
|
|
11
|
-
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
12
|
-
var _Row = _interopRequireDefault(require("./List/Row"));
|
|
13
|
-
var _HeadRow = _interopRequireDefault(require("./List/HeadRow"));
|
|
14
|
-
var _List = require("./List/List");
|
|
15
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
(function () {
|
|
19
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
20
|
-
enterModule && enterModule(module);
|
|
21
|
-
})();
|
|
22
|
-
(function () {
|
|
23
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
24
|
-
enterModule && enterModule(module);
|
|
25
|
-
})();
|
|
26
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
27
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
29
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
30
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
31
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
32
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
33
|
-
return a;
|
|
34
|
-
};
|
|
35
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
36
|
-
return a;
|
|
37
|
-
};
|
|
38
|
-
/*
|
|
39
|
-
Multiple lists with a single header, aligned with each other
|
|
40
|
-
No virtualization or page loading
|
|
41
|
-
Categories can be folded up to hide content
|
|
42
|
-
Sortable, within categories
|
|
43
|
-
*/
|
|
44
|
-
var arrayToggle = function arrayToggle(array, item) {
|
|
45
|
-
return array.includes(item) ? array.filter(function (x) {
|
|
46
|
-
return x !== item;
|
|
47
|
-
}) : array.concat(item);
|
|
48
|
-
};
|
|
49
|
-
var CategoryRow = exports.CategoryRow = _styledComponents.default.tr.withConfig({
|
|
50
|
-
displayName: "CategoryList__CategoryRow",
|
|
51
|
-
componentId: "sc-rh0l6t-0"
|
|
52
|
-
})([""]);
|
|
53
|
-
var CategoryHeader = exports.CategoryHeader = _styledComponents.default.td.withConfig({
|
|
54
|
-
displayName: "CategoryList__CategoryHeader",
|
|
55
|
-
componentId: "sc-rh0l6t-1"
|
|
56
|
-
})(["border:0 solid ", ";border-top-width:1px;tr:first-child &{border-top-width:0;}tr:last-child &{border-bottom-width:1px;}position:relative;padding:11px 45px;background-color:#f1eae0;", " cursor:pointer;"], (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc"), (0, _utils.ifFlag)("closed", (0, _styledComponents.css)(["border-bottom:1px solid ", ";"], (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc"))));
|
|
57
|
-
var CategoryIndicator = exports.CategoryIndicator = (0, _styledComponents.default)(_Icon.default).attrs(function (props) {
|
|
58
|
-
return {
|
|
59
|
-
id: (0, _utils.ifFlag)("closed", (0, _utils.getThemeProp)(["icons", "indicators", "right"], "chevron-right"), (0, _utils.getThemeProp)(["icons", "indicators", "down"], "chevron-down"))(props)
|
|
60
|
-
};
|
|
61
|
-
}).withConfig({
|
|
62
|
-
displayName: "CategoryList__CategoryIndicator",
|
|
63
|
-
componentId: "sc-rh0l6t-2"
|
|
64
|
-
})(["font-size:12px;position:absolute;left:22px;top:15px;"]);
|
|
65
|
-
var CategoryList = exports.CategoryList = function CategoryList(_ref) {
|
|
66
|
-
var name = _ref.name,
|
|
67
|
-
_ref$columnDefs = _ref.columnDefs,
|
|
68
|
-
columnDefs = _ref$columnDefs === void 0 ? [] : _ref$columnDefs,
|
|
69
|
-
_ref$rows = _ref.rows,
|
|
70
|
-
rows = _ref$rows === void 0 ? [] : _ref$rows,
|
|
71
|
-
rowOnClick = _ref.rowOnClick,
|
|
72
|
-
placeholder = _ref.placeholder,
|
|
73
|
-
_ref$keyField = _ref.keyField,
|
|
74
|
-
keyField = _ref$keyField === void 0 ? ["id"] : _ref$keyField,
|
|
75
|
-
_ref$categoryField = _ref.categoryField,
|
|
76
|
-
categoryField = _ref$categoryField === void 0 ? ["category"] : _ref$categoryField,
|
|
77
|
-
_ref$openAll = _ref.openAll,
|
|
78
|
-
openAll = _ref$openAll === void 0 ? false : _ref$openAll,
|
|
79
|
-
height = _ref.height,
|
|
80
|
-
_ref$rowBackgroundGet = _ref.rowBackgroundGetter,
|
|
81
|
-
rowBackgroundGetter = _ref$rowBackgroundGet === void 0 ? function () {} : _ref$rowBackgroundGet;
|
|
82
|
-
var _useListState = (0, _List.useListState)(name, columnDefs),
|
|
83
|
-
_useListState2 = _slicedToArray(_useListState, 2),
|
|
84
|
-
enhancedColumnDefs = _useListState2[0],
|
|
85
|
-
selection = _useListState2[1];
|
|
86
|
-
var _useViewState = (0, _useViewState3.default)(name),
|
|
87
|
-
_useViewState2 = _slicedToArray(_useViewState, 2),
|
|
88
|
-
_useViewState2$0$clos = _useViewState2[0].closedCategories,
|
|
89
|
-
closedCategories = _useViewState2$0$clos === void 0 ? [] : _useViewState2$0$clos,
|
|
90
|
-
updateViewState = _useViewState2[1];
|
|
91
|
-
if (columnDefs.length === 0) return null;
|
|
92
|
-
var rowIds = [],
|
|
93
|
-
rowCategories = {};
|
|
94
|
-
rows.forEach(function (row, index) {
|
|
95
|
-
var id = _utils.safeGet.apply(void 0, [row].concat(keyField)) + ""; // Ensure rowId is string
|
|
96
|
-
var category = _utils.safeGet.apply(void 0, [row].concat(categoryField)) || "";
|
|
97
|
-
rowIds.push(id);
|
|
98
|
-
if (!rowCategories[category]) {
|
|
99
|
-
rowCategories[category] = [];
|
|
100
|
-
}
|
|
101
|
-
rowCategories[category].push(/*#__PURE__*/_react.default.createElement(_Row.default, {
|
|
102
|
-
columnDefs: enhancedColumnDefs,
|
|
103
|
-
key: id,
|
|
104
|
-
rowId: id,
|
|
105
|
-
row: row,
|
|
106
|
-
rowOnClick: rowOnClick,
|
|
107
|
-
selected: selection.indexOf(id) !== -1,
|
|
108
|
-
bgColor: rowBackgroundGetter(row, index)
|
|
109
|
-
}));
|
|
110
|
-
});
|
|
111
|
-
var rowElements = [];
|
|
112
|
-
if (Object.keys(rowCategories).length === 0) {
|
|
113
|
-
if (placeholder) {
|
|
114
|
-
rowElements.push(/*#__PURE__*/_react.default.createElement(_List.Placeholder, {
|
|
115
|
-
key: "placeholder",
|
|
116
|
-
width: columnDefs.length,
|
|
117
|
-
height: height - _List.HEADER_HEIGHT
|
|
118
|
-
}, placeholder));
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
Object.entries(rowCategories).forEach(function (_ref2) {
|
|
122
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
123
|
-
key = _ref3[0],
|
|
124
|
-
rows = _ref3[1];
|
|
125
|
-
var clickHandler = function clickHandler() {
|
|
126
|
-
return updateViewState("closedCategories", arrayToggle(closedCategories, key));
|
|
127
|
-
};
|
|
128
|
-
var closed = !openAll && closedCategories.includes(key);
|
|
129
|
-
rowElements.push(/*#__PURE__*/_react.default.createElement(CategoryRow, {
|
|
130
|
-
key: "category_" + key
|
|
131
|
-
}, /*#__PURE__*/_react.default.createElement(CategoryHeader, {
|
|
132
|
-
"data-test-id": "category_" + key,
|
|
133
|
-
closed: closed,
|
|
134
|
-
colSpan: columnDefs.length,
|
|
135
|
-
onClick: clickHandler
|
|
136
|
-
}, /*#__PURE__*/_react.default.createElement(CategoryIndicator, {
|
|
137
|
-
closed: closed
|
|
138
|
-
}), key)));
|
|
139
|
-
if (!closed) {
|
|
140
|
-
rowElements.push.apply(rowElements, rows);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return /*#__PURE__*/_react.default.createElement(_List.Table, null, /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement(_HeadRow.default, {
|
|
145
|
-
columnDefs: enhancedColumnDefs,
|
|
146
|
-
rowIds: rowIds,
|
|
147
|
-
allSelected: rows.length === selection.length && rows.length !== 0
|
|
148
|
-
})), /*#__PURE__*/_react.default.createElement("tbody", null, rowElements));
|
|
149
|
-
};
|
|
150
|
-
__signature__(CategoryList, "useListState{[enhancedColumnDefs, selection]}\nuseViewState{[{ closedCategories = [] }, updateViewState]}", function () {
|
|
151
|
-
return [_List.useListState, _useViewState3.default];
|
|
152
|
-
});
|
|
153
|
-
__signature__(CategoryList, "useListState{[enhancedColumnDefs, selection]}\nuseViewState{[{ closedCategories = [] }, updateViewState]}", function () {
|
|
154
|
-
return [_List.useListState, _useViewState3.default];
|
|
155
|
-
});
|
|
156
|
-
var StatefulCategoryList = (0, _recompose.compose)((0, _recompose.setDisplayName)("CategoryList"), _withScrollBox.default)(CategoryList);
|
|
157
|
-
var _default = StatefulCategoryList;
|
|
158
|
-
var _default2 = _default;
|
|
159
|
-
var _default3 = exports.default = _default2;
|
|
160
|
-
;
|
|
161
|
-
(function () {
|
|
162
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
163
|
-
if (!reactHotLoader) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
reactHotLoader.register(arrayToggle, "arrayToggle", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
167
|
-
reactHotLoader.register(CategoryRow, "CategoryRow", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
168
|
-
reactHotLoader.register(CategoryHeader, "CategoryHeader", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
169
|
-
reactHotLoader.register(CategoryIndicator, "CategoryIndicator", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
170
|
-
reactHotLoader.register(CategoryList, "CategoryList", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
171
|
-
reactHotLoader.register(StatefulCategoryList, "StatefulCategoryList", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
172
|
-
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
173
|
-
})();
|
|
174
|
-
;
|
|
175
|
-
(function () {
|
|
176
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
177
|
-
leaveModule && leaveModule(module);
|
|
178
|
-
})();
|
|
179
|
-
;
|
|
180
|
-
(function () {
|
|
181
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
182
|
-
if (!reactHotLoader) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
reactHotLoader.register(arrayToggle, "arrayToggle", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
186
|
-
reactHotLoader.register(CategoryRow, "CategoryRow", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
187
|
-
reactHotLoader.register(CategoryHeader, "CategoryHeader", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
188
|
-
reactHotLoader.register(CategoryIndicator, "CategoryIndicator", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
189
|
-
reactHotLoader.register(CategoryList, "CategoryList", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
190
|
-
reactHotLoader.register(StatefulCategoryList, "StatefulCategoryList", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
191
|
-
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/CategoryList.js");
|
|
192
|
-
})();
|
|
193
|
-
;
|
|
194
|
-
(function () {
|
|
195
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
196
|
-
leaveModule && leaveModule(module);
|
|
197
|
-
})();
|