@zohodesk/dot 1.8.1 → 1.8.3
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/README.md +11 -0
- package/es/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
- package/es/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
- package/es/form/fields/Fields.module.css +8 -3
- package/es/form/fields/RadioField/RadioField.js +40 -14
- package/es/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
- package/es/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
- package/es/form/fields/RadioField/props/defaultProps.js +1 -0
- package/es/form/fields/RadioField/props/propTypes.js +6 -0
- package/es/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
- package/es/version2/GlobalNotification/GlobalNotification.js +46 -7
- package/es/version2/GlobalNotification/__tests__/GlobalNotification.spec.js +9 -0
- package/es/version2/GlobalNotification/props/propTypes.js +4 -3
- package/es/version2/GlobalNotification/utils/constants.js +6 -0
- package/lib/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
- package/lib/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
- package/lib/form/fields/Fields.module.css +8 -3
- package/lib/form/fields/RadioField/RadioField.js +39 -15
- package/lib/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
- package/lib/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
- package/lib/form/fields/RadioField/props/defaultProps.js +1 -0
- package/lib/form/fields/RadioField/props/propTypes.js +6 -0
- package/lib/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
- package/lib/version2/GlobalNotification/GlobalNotification.js +68 -18
- package/lib/version2/GlobalNotification/__tests__/GlobalNotification.spec.js +10 -0
- package/lib/version2/GlobalNotification/props/propTypes.js +4 -3
- package/lib/version2/GlobalNotification/utils/constants.js +13 -0
- package/package.json +10 -10
|
@@ -22,6 +22,12 @@ export const propTypes = {
|
|
|
22
22
|
validationRuleMessage: PropTypes.string,
|
|
23
23
|
validationRulePalette: PropTypes.string,
|
|
24
24
|
variant: PropTypes.oneOf(['primary', 'default', 'secondary']),
|
|
25
|
+
customClass: {
|
|
26
|
+
customWrapperClass: PropTypes.string,
|
|
27
|
+
customLabelClass: PropTypes.string,
|
|
28
|
+
customRadioWrapperClass: PropTypes.string,
|
|
29
|
+
customRadioClass: PropTypes.string
|
|
30
|
+
},
|
|
25
31
|
customProps: PropTypes.shape({
|
|
26
32
|
LabelProps: PropTypes.object,
|
|
27
33
|
RadioProps: PropTypes.object,
|
|
@@ -29,7 +29,7 @@ exports[`AvatarFlip rendering the defult props 1`] = `
|
|
|
29
29
|
tabindex="0"
|
|
30
30
|
>
|
|
31
31
|
<div
|
|
32
|
-
class="boxContainer
|
|
32
|
+
class="boxContainer medium filled shrinkOff"
|
|
33
33
|
data-id="boxComponent"
|
|
34
34
|
data-selector-id="box"
|
|
35
35
|
data-test-id="boxComponent"
|
|
@@ -7,6 +7,8 @@ import AlertClose from "../AlertClose/AlertClose";
|
|
|
7
7
|
import style from "./GlobalNotification.module.css";
|
|
8
8
|
import { Container, Box } from '@zohodesk/components/es/Layout';
|
|
9
9
|
import { cancelBubblingEffect } from '@zohodesk/components/es/utils/Common';
|
|
10
|
+
import getCurrentTime from '@zohodesk/utils/es/getCurrentTime';
|
|
11
|
+
import { STATUS } from "./utils/constants";
|
|
10
12
|
export default class GlobalNotification extends React.Component {
|
|
11
13
|
constructor(props) {
|
|
12
14
|
super(props);
|
|
@@ -15,6 +17,8 @@ export default class GlobalNotification extends React.Component {
|
|
|
15
17
|
shadowClose: true
|
|
16
18
|
};
|
|
17
19
|
this.onClose = this.onClose.bind(this);
|
|
20
|
+
this.getNotificationData = this.getNotificationData.bind(this);
|
|
21
|
+
this.handleStatusChange = this.handleStatusChange.bind(this);
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
componentDidMount() {
|
|
@@ -24,18 +28,44 @@ export default class GlobalNotification extends React.Component {
|
|
|
24
28
|
id,
|
|
25
29
|
needAutoClose
|
|
26
30
|
} = this.props;
|
|
31
|
+
this.handleStatusChange(STATUS.MOUNTED);
|
|
27
32
|
|
|
28
33
|
if (needAutoClose) {
|
|
29
34
|
this.hideMessageTimer = setTimeout(() => {
|
|
30
35
|
hideMessage(id);
|
|
36
|
+
this.handleStatusChange(STATUS.DISMISSING);
|
|
31
37
|
}, hideTime);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
componentDidUpdate(prevProps) {
|
|
42
|
+
if (prevProps.id === this.props.id && (prevProps.message !== this.props.message || prevProps.type !== this.props.type)) {
|
|
43
|
+
this.handleStatusChange(STATUS.UPDATED);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
componentWillUnmount() {
|
|
36
48
|
if (this.hideMessageTimer) {
|
|
37
49
|
clearTimeout(this.hideMessageTimer);
|
|
38
50
|
}
|
|
51
|
+
|
|
52
|
+
this.handleStatusChange(STATUS.UNMOUNTED);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
handleStatusChange(status) {
|
|
56
|
+
const {
|
|
57
|
+
onStatusChange
|
|
58
|
+
} = this.props;
|
|
59
|
+
|
|
60
|
+
if (typeof onStatusChange == 'function') {
|
|
61
|
+
const notificationData = this.getNotificationData();
|
|
62
|
+
const currentTime = getCurrentTime();
|
|
63
|
+
onStatusChange({
|
|
64
|
+
status,
|
|
65
|
+
...notificationData,
|
|
66
|
+
time: currentTime
|
|
67
|
+
});
|
|
68
|
+
}
|
|
39
69
|
}
|
|
40
70
|
|
|
41
71
|
onClose(e) {
|
|
@@ -47,20 +77,31 @@ export default class GlobalNotification extends React.Component {
|
|
|
47
77
|
this.setState({
|
|
48
78
|
shadowClose: false
|
|
49
79
|
});
|
|
80
|
+
this.handleStatusChange(STATUS.DISMISSING);
|
|
50
81
|
hideMessage && hideMessage(id);
|
|
51
82
|
onClose && onClose(e);
|
|
52
83
|
}
|
|
53
84
|
|
|
85
|
+
getNotificationData() {
|
|
86
|
+
const {
|
|
87
|
+
id,
|
|
88
|
+
type,
|
|
89
|
+
message
|
|
90
|
+
} = this.props;
|
|
91
|
+
return {
|
|
92
|
+
id,
|
|
93
|
+
type,
|
|
94
|
+
message
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
54
98
|
render() {
|
|
55
99
|
let {
|
|
56
|
-
type,
|
|
57
|
-
message,
|
|
58
100
|
hideMessage,
|
|
59
101
|
onClick,
|
|
60
102
|
i18nKeys = {},
|
|
61
103
|
customProps,
|
|
62
104
|
dataSelectorId,
|
|
63
|
-
id,
|
|
64
105
|
needShadow,
|
|
65
106
|
shadowCount,
|
|
66
107
|
eleRef
|
|
@@ -71,15 +112,13 @@ export default class GlobalNotification extends React.Component {
|
|
|
71
112
|
let {
|
|
72
113
|
closeTitle = 'Close'
|
|
73
114
|
} = i18nKeys;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
message: message,
|
|
115
|
+
const notificationData = this.getNotificationData();
|
|
116
|
+
return /*#__PURE__*/React.createElement(GlobalNotificationUI, { ...notificationData,
|
|
77
117
|
hideMessage: hideMessage,
|
|
78
118
|
onClick: onClick,
|
|
79
119
|
closeTitle: closeTitle,
|
|
80
120
|
customProps: customProps,
|
|
81
121
|
dataSelectorId: dataSelectorId,
|
|
82
|
-
id: id,
|
|
83
122
|
shadowCount: shadowCount,
|
|
84
123
|
onClose: this.onClose,
|
|
85
124
|
needShadow: shadowClose && needShadow,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import GlobalNotification from "../GlobalNotification";
|
|
4
|
+
import { STATUS } from "../utils/constants";
|
|
4
5
|
describe('GlobalNotification', () => {
|
|
5
6
|
test('rendering the defult props', () => {
|
|
6
7
|
const {
|
|
@@ -8,4 +9,12 @@ describe('GlobalNotification', () => {
|
|
|
8
9
|
} = render( /*#__PURE__*/React.createElement(GlobalNotification, null));
|
|
9
10
|
expect(asFragment()).toMatchSnapshot();
|
|
10
11
|
});
|
|
12
|
+
});
|
|
13
|
+
describe('GlobalNotification Constants', () => {
|
|
14
|
+
test('should have correct constant values', () => {
|
|
15
|
+
expect(STATUS.MOUNTED).toBe('mounted');
|
|
16
|
+
expect(STATUS.UPDATED).toBe('updated');
|
|
17
|
+
expect(STATUS.DISMISSING).toBe('dismissing');
|
|
18
|
+
expect(STATUS.UNMOUNTED).toBe('unmounted');
|
|
19
|
+
});
|
|
11
20
|
});
|
|
@@ -10,12 +10,13 @@ export const propTypes = {
|
|
|
10
10
|
customProps: PropTypes.shape({
|
|
11
11
|
ExtraProps: PropTypes.object
|
|
12
12
|
}),
|
|
13
|
-
id: PropTypes.
|
|
13
|
+
id: PropTypes.string,
|
|
14
14
|
hideTime: PropTypes.number,
|
|
15
15
|
needAutoClose: PropTypes.bool,
|
|
16
16
|
isCollapseView: PropTypes.bool,
|
|
17
17
|
shadowCount: PropTypes.number,
|
|
18
|
-
needShadow: PropTypes.bool
|
|
18
|
+
needShadow: PropTypes.bool,
|
|
19
|
+
onStatusChange: PropTypes.func
|
|
19
20
|
};
|
|
20
21
|
export const UI_propTypes = {
|
|
21
22
|
dataSelectorId: PropTypes.string,
|
|
@@ -28,7 +29,7 @@ export const UI_propTypes = {
|
|
|
28
29
|
}),
|
|
29
30
|
needShadow: PropTypes.bool,
|
|
30
31
|
shadowCount: PropTypes.number,
|
|
31
|
-
id: PropTypes.
|
|
32
|
+
id: PropTypes.string,
|
|
32
33
|
onClose: PropTypes.func
|
|
33
34
|
};
|
|
34
35
|
export const new_propTypes = {
|