orc-shared 5.10.1-dev.7 → 5.10.1
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 +12 -3
- package/dist/components/CategoryList.js +197 -0
- package/dist/components/List/DataCell.js +129 -0
- package/dist/components/List/HeadCell.js +125 -0
- package/dist/components/List/HeadRow.js +73 -0
- package/dist/components/List/List.js +274 -0
- package/dist/components/List/Row.js +109 -0
- package/dist/components/List/enhanceColumnDefs.js +111 -0
- package/dist/components/List/index.js +59 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +1 -2
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +1 -3
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -3
- package/dist/components/ToastList.js +64 -95
- package/dist/getTheme.js +5 -0
- package/package.json +1 -1
- package/src/components/AppFrame/MenuItem.js +9 -1
- package/src/components/CategoryList.js +140 -0
- package/src/components/CategoryList.test.js +667 -0
- package/src/components/List/DataCell.js +77 -0
- package/src/components/List/DataCell.test.js +357 -0
- package/src/components/List/HeadCell.js +105 -0
- package/src/components/List/HeadCell.test.js +331 -0
- package/src/components/List/HeadRow.js +21 -0
- package/src/components/List/HeadRow.test.js +27 -0
- package/src/components/List/List.js +162 -0
- package/src/components/List/List.test.js +705 -0
- package/src/components/List/Row.js +72 -0
- package/src/components/List/Row.test.js +194 -0
- package/src/components/List/enhanceColumnDefs.js +54 -0
- package/src/components/List/enhanceColumnDefs.test.js +179 -0
- package/src/components/List/index.js +6 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +1 -6
- package/src/components/MaterialUI/DataDisplay/Table.test.js +0 -20
- package/src/components/MaterialUI/DataDisplay/TableProps.js +0 -2
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -20
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +1 -2
- package/src/components/ToastList.js +90 -79
- package/src/components/ToastList.test.js +103 -29
- package/src/getTheme.js +5 -0
- package/dist/utils/toastHelper.js +0 -52
- package/src/utils/toastHelper.js +0 -8
- package/src/utils/toastHelper.test.js +0 -41
|
@@ -1,10 +1,12 @@
|
|
|
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";
|
|
2
5
|
import ReactDOM from "react-dom";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { CSSTransition, TransitionGroup } from "react-transition-group";
|
|
6
|
+
import { shade } from "polished";
|
|
7
|
+
import { getThemeProp } from "../utils";
|
|
8
|
+
import Text from "./Text";
|
|
9
|
+
import Icon from "./Icon";
|
|
8
10
|
|
|
9
11
|
const portal = document.getElementById("toast") || document.createElement("div");
|
|
10
12
|
/* istanbul ignore else */
|
|
@@ -13,91 +15,100 @@ if (!portal.parent) {
|
|
|
13
15
|
document.body.appendChild(portal);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
const
|
|
17
|
-
toastBox: props => {
|
|
18
|
-
const toastColor = getToastColor(theme, props.toastType);
|
|
18
|
+
const toastTransitionTime = 300;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
export const ToastBox = transition.div`
|
|
21
|
+
display: flex;
|
|
22
|
+
width: 390px;
|
|
23
|
+
margin-top: 10px;
|
|
24
|
+
padding: 17px;
|
|
25
|
+
border-radius: 5px;
|
|
26
|
+
font-size: 14px;
|
|
27
|
+
color: white;
|
|
28
|
+
background-color: ${getThemeProp(["colors", "toasts", props => props.type], "#999")};
|
|
29
|
+
z-index: 10000;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
& > * {
|
|
32
|
+
margin-top: auto;
|
|
33
|
+
margin-bottom: auto;
|
|
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
|
+
};
|
|
35
63
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}));
|
|
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
|
+
`;
|
|
76
71
|
|
|
77
|
-
export const
|
|
78
|
-
|
|
72
|
+
export const CloseIcon = styled(Icon).attrs(props => ({
|
|
73
|
+
id: getThemeProp(["icons", "close"], "close")(props),
|
|
74
|
+
}))`
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: 8px;
|
|
77
|
+
right: 8px;
|
|
78
|
+
font-size: 10px;
|
|
79
|
+
padding: 2px;
|
|
80
|
+
border-radius: 2px;
|
|
81
|
+
stroke-width: 2px;
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{closeFunc ? <Icon id="close" className={classes.closeIcon} onClick={closeFunc} /> : null}
|
|
85
|
-
</div>
|
|
86
|
-
</CSSTransition>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
83
|
+
&:hover {
|
|
84
|
+
background-color: ${getThemeProp(["colors", "toasts", props => props.type], "#999999", color => shade(0.3, color))};
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
89
87
|
|
|
90
|
-
export const
|
|
91
|
-
|
|
88
|
+
export const Toast = ({ message = "[No message]", type = "", closeFunc, ...props }) => (
|
|
89
|
+
<ToastBox type={type} in={props.in}>
|
|
90
|
+
<ToastIcon type={type} />
|
|
91
|
+
<Text message={message} />
|
|
92
|
+
{closeFunc ? <CloseIcon onClick={closeFunc} type={type} /> : null}
|
|
93
|
+
</ToastBox>
|
|
94
|
+
);
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
const ListWrapper = styled(TransitionGroup)`
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 40px;
|
|
99
|
+
right: 16px;
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
export const ToastList = ({ toasts }) =>
|
|
105
|
+
ReactDOM.createPortal(
|
|
106
|
+
<ListWrapper>
|
|
95
107
|
{toasts.map((props, idx) => (
|
|
96
108
|
<Toast key={"toast" + idx} {...props} />
|
|
97
109
|
))}
|
|
98
|
-
</
|
|
110
|
+
</ListWrapper>,
|
|
99
111
|
portal,
|
|
100
112
|
);
|
|
101
|
-
};
|
|
102
113
|
|
|
103
114
|
export default ToastList;
|
|
@@ -3,9 +3,10 @@ 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
|
|
6
|
+
import { ThemeProvider } from "styled-components";
|
|
7
|
+
import { shade } from "polished";
|
|
8
|
+
import Icon from "./Icon";
|
|
9
|
+
import FullToastList, { Toast, ToastBox, ToastIcon, CloseIcon } from "./ToastList";
|
|
9
10
|
|
|
10
11
|
class RenderToast extends React.Component {
|
|
11
12
|
render() {
|
|
@@ -46,11 +47,10 @@ describe("ToastList", () => {
|
|
|
46
47
|
return expect(
|
|
47
48
|
toastRoot,
|
|
48
49
|
"to contain",
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</CSSTransition>,
|
|
50
|
+
<ToastBox in>
|
|
51
|
+
<Ignore />
|
|
52
|
+
[No message]
|
|
53
|
+
</ToastBox>,
|
|
54
54
|
);
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -70,11 +70,10 @@ describe("Toast", () => {
|
|
|
70
70
|
</Provider>,
|
|
71
71
|
"when mounted",
|
|
72
72
|
"to satisfy",
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</CSSTransition>,
|
|
73
|
+
<ToastBox in>
|
|
74
|
+
<Ignore />
|
|
75
|
+
this is a toast
|
|
76
|
+
</ToastBox>,
|
|
78
77
|
));
|
|
79
78
|
|
|
80
79
|
it("shows a translated message", () =>
|
|
@@ -92,11 +91,10 @@ describe("Toast", () => {
|
|
|
92
91
|
</Provider>,
|
|
93
92
|
"when mounted",
|
|
94
93
|
"to satisfy",
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</CSSTransition>,
|
|
94
|
+
<ToastBox in>
|
|
95
|
+
<Ignore />
|
|
96
|
+
This is a toast
|
|
97
|
+
</ToastBox>,
|
|
100
98
|
));
|
|
101
99
|
|
|
102
100
|
it("shows an icon", () =>
|
|
@@ -112,11 +110,10 @@ describe("Toast", () => {
|
|
|
112
110
|
</Provider>,
|
|
113
111
|
"when mounted",
|
|
114
112
|
"to satisfy",
|
|
115
|
-
<
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</CSSTransition>,
|
|
113
|
+
<ToastBox in>
|
|
114
|
+
<ToastIcon type="confirm" />
|
|
115
|
+
<Ignore />
|
|
116
|
+
</ToastBox>,
|
|
120
117
|
));
|
|
121
118
|
|
|
122
119
|
it("shows a close icon if a close function is given", () =>
|
|
@@ -132,11 +129,88 @@ describe("Toast", () => {
|
|
|
132
129
|
</Provider>,
|
|
133
130
|
"when mounted",
|
|
134
131
|
"to satisfy",
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
</CSSTransition>,
|
|
132
|
+
<ToastBox in>
|
|
133
|
+
<Ignore />
|
|
134
|
+
<Ignore />
|
|
135
|
+
<CloseIcon onClick={expect.it("to be a function")} />
|
|
136
|
+
</ToastBox>,
|
|
141
137
|
));
|
|
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
|
+
});
|
|
142
216
|
});
|
package/src/getTheme.js
CHANGED
|
@@ -54,6 +54,11 @@ 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
|
+
// },
|
|
57
62
|
prev: "arrow-small-left",
|
|
58
63
|
next: "arrow-small-right",
|
|
59
64
|
menu: "app-list",
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.getToastColor = void 0;
|
|
5
|
-
(function () {
|
|
6
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
7
|
-
enterModule && enterModule(module);
|
|
8
|
-
})();
|
|
9
|
-
(function () {
|
|
10
|
-
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
11
|
-
enterModule && enterModule(module);
|
|
12
|
-
})();
|
|
13
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
14
|
-
return a;
|
|
15
|
-
};
|
|
16
|
-
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var getToastColor = exports.getToastColor = function getToastColor(theme, alertType) {
|
|
20
|
-
var toastBorderColors = {
|
|
21
|
-
error: theme.palette.error.main,
|
|
22
|
-
warn: theme.palette.warning.main,
|
|
23
|
-
confirm: theme.palette.success.main
|
|
24
|
-
};
|
|
25
|
-
return toastBorderColors[alertType] || "red";
|
|
26
|
-
};
|
|
27
|
-
;
|
|
28
|
-
(function () {
|
|
29
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
30
|
-
if (!reactHotLoader) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
reactHotLoader.register(getToastColor, "getToastColor", "/home/vsts/work/1/s/src/utils/toastHelper.js");
|
|
34
|
-
})();
|
|
35
|
-
;
|
|
36
|
-
(function () {
|
|
37
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
38
|
-
leaveModule && leaveModule(module);
|
|
39
|
-
})();
|
|
40
|
-
;
|
|
41
|
-
(function () {
|
|
42
|
-
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
43
|
-
if (!reactHotLoader) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
reactHotLoader.register(getToastColor, "getToastColor", "/home/vsts/work/1/s/src/utils/toastHelper.js");
|
|
47
|
-
})();
|
|
48
|
-
;
|
|
49
|
-
(function () {
|
|
50
|
-
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
51
|
-
leaveModule && leaveModule(module);
|
|
52
|
-
})();
|
package/src/utils/toastHelper.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
});
|