@zohodesk/dot 1.0.0-temp-222 → 1.0.0-temp-220.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/README.md +3 -2
- package/es/form/fields/Fields.module.css +3 -8
- package/es/form/fields/RadioField/RadioField.js +10 -29
- package/es/form/fields/RadioField/__tests__/RadioField.spec.js +0 -33
- package/es/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +66 -562
- 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/form/fields/Fields.module.css +3 -8
- package/lib/form/fields/RadioField/RadioField.js +11 -26
- package/lib/form/fields/RadioField/__tests__/RadioField.spec.js +0 -33
- package/lib/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +66 -562
- 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 +7 -7
|
@@ -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.getNotiifcationData = this.getNotiifcationData.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.getNotiifcationData();
|
|
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
|
+
getNotiifcationData() {
|
|
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.getNotiifcationData();
|
|
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 = {
|
|
@@ -71,16 +71,11 @@
|
|
|
71
71
|
}
|
|
72
72
|
.radioBox {
|
|
73
73
|
max-width: 100% ;
|
|
74
|
-
transition: border var(--zd_transition3);
|
|
75
|
-
border: 1px solid var(--zdt_radiofield_box_border);
|
|
76
|
-
border-radius: 6px;
|
|
77
|
-
}
|
|
78
|
-
.radioBox.primaryTextOnly {
|
|
79
74
|
height: var(--zd_size36) ;
|
|
75
|
+
transition: border var(--zd_transition3);
|
|
80
76
|
padding: 0 var(--zd_size10) ;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
padding: var(--zd_size18) var(--zd_size16) ;
|
|
77
|
+
border: 1px solid var(--zdt_radiofield_box_border);
|
|
78
|
+
border-radius: 6px
|
|
84
79
|
}
|
|
85
80
|
.hoverableRadioBox:hover, .radioBoxActive {
|
|
86
81
|
border-color: var(--zdt_radiofield_box_active_border)
|
|
@@ -9,8 +9,6 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _utils = require("@zohodesk/utils");
|
|
13
|
-
|
|
14
12
|
var _defaultProps = require("./props/defaultProps");
|
|
15
13
|
|
|
16
14
|
var _propTypes = require("./props/propTypes");
|
|
@@ -186,30 +184,18 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
|
|
|
186
184
|
}, LabelProps)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
187
185
|
className: "".concat(_FieldsModule["default"].fieldContainer, " ").concat(isBoxStyle ? _FieldsModule["default"].radiosWrapper : '', " ").concat(labelName ? isBoxStyle ? _FieldsModule["default"].fieldMargin_large : _FieldsModule["default"].fieldMargin_medium : '', " ").concat(_FieldsModule["default"].radioContainer)
|
|
188
186
|
}, options.map(function (option, index) {
|
|
189
|
-
var _compileClassNames;
|
|
190
|
-
|
|
191
187
|
var text = option.text,
|
|
192
188
|
value = option.value,
|
|
193
189
|
_option$disabled = option.disabled,
|
|
194
190
|
disabled = _option$disabled === void 0 ? false : _option$disabled,
|
|
195
191
|
tooltip = option.tooltip,
|
|
196
|
-
infoTooltip = option.infoTooltip
|
|
197
|
-
secondaryText = option.secondaryText,
|
|
198
|
-
renderRightPlaceholderNode = option.renderRightPlaceholderNode,
|
|
199
|
-
customProps = option.customProps;
|
|
192
|
+
infoTooltip = option.infoTooltip;
|
|
200
193
|
var isDisabledState = disabled || isDisabled;
|
|
201
194
|
var isChecked = selectedValue == value;
|
|
202
|
-
var rightPlaceholderNode = !!infoTooltip ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Icon["default"], _extends({
|
|
203
|
-
name: "ZD-GN-info",
|
|
204
|
-
size: "16",
|
|
205
|
-
title: infoTooltip,
|
|
206
|
-
iconClass: _FieldsModule["default"].infoIcon
|
|
207
|
-
}, InfoIconProps)), renderRightPlaceholderNode) : renderRightPlaceholderNode;
|
|
208
|
-
var radioBoxClasses = isBoxStyle ? (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, _FieldsModule["default"].radioBox, true), _defineProperty(_compileClassNames, _FieldsModule["default"].withSecondaryText, !!secondaryText), _defineProperty(_compileClassNames, _FieldsModule["default"].primaryTextOnly, !secondaryText), _defineProperty(_compileClassNames, _FieldsModule["default"].hoverableRadioBox, !isDisabledState), _defineProperty(_compileClassNames, _FieldsModule["default"].radioBoxActive, isChecked), _compileClassNames)) : '';
|
|
209
195
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
210
196
|
key: index,
|
|
211
197
|
className: "".concat(!isBoxStyle ? _FieldsModule["default"].radio : '', " ").concat(_FieldsModule["default"].radioWrap)
|
|
212
|
-
}, /*#__PURE__*/_react["default"].createElement(_Radio["default"], _extends({
|
|
198
|
+
}, /*#__PURE__*/_react["default"].createElement(_Radio["default"], _extends({
|
|
213
199
|
id: index,
|
|
214
200
|
value: value,
|
|
215
201
|
name: id,
|
|
@@ -226,21 +212,20 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
|
|
|
226
212
|
checked: isChecked,
|
|
227
213
|
dataId: dataId,
|
|
228
214
|
isReadOnly: isReadOnly,
|
|
229
|
-
variant: variant
|
|
230
|
-
secondaryText: secondaryText
|
|
215
|
+
variant: variant
|
|
231
216
|
}, RadioProps, {
|
|
232
217
|
a11y: _objectSpread({
|
|
233
218
|
tabIndex: !!selectedValue ? isChecked ? '0' : '-1' : index === 0 ? '0' : '-1'
|
|
234
219
|
}, RadioProps.a11y),
|
|
235
220
|
customClass: _objectSpread({
|
|
236
|
-
customRadioWrap:
|
|
237
|
-
}, RadioProps.customClass)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
})));
|
|
221
|
+
customRadioWrap: isBoxStyle ? "".concat(_FieldsModule["default"].radioBox, " ").concat(!isDisabledState ? _FieldsModule["default"].hoverableRadioBox : '', " ").concat(isChecked ? _FieldsModule["default"].radioBoxActive : '') : ''
|
|
222
|
+
}, RadioProps.customClass)
|
|
223
|
+
}), !!infoTooltip ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], _extends({
|
|
224
|
+
name: "ZD-GN-info",
|
|
225
|
+
size: "16",
|
|
226
|
+
title: infoTooltip,
|
|
227
|
+
iconClass: _FieldsModule["default"].infoIcon
|
|
228
|
+
}, InfoIconProps)) : null));
|
|
244
229
|
})), validationMessage && /*#__PURE__*/_react["default"].createElement(_ValidationMessage["default"], _extends({
|
|
245
230
|
text: validationMessage,
|
|
246
231
|
palette: validationPalette,
|
|
@@ -24,22 +24,6 @@ var options = [{
|
|
|
24
24
|
text: 'Kolkata',
|
|
25
25
|
value: '4'
|
|
26
26
|
}];
|
|
27
|
-
var optionsWithsecondaryText = [{
|
|
28
|
-
text: 'Chennai',
|
|
29
|
-
value: '1',
|
|
30
|
-
secondaryText: 'Tamil Nadu Capital'
|
|
31
|
-
}, {
|
|
32
|
-
text: 'Mumbai',
|
|
33
|
-
value: '2',
|
|
34
|
-
secondaryText: 'Maharashtra Capital',
|
|
35
|
-
tooltip: 'Disabled Option',
|
|
36
|
-
disabled: true
|
|
37
|
-
}, {
|
|
38
|
-
text: 'Delhi',
|
|
39
|
-
value: '3',
|
|
40
|
-
secondaryText: 'Capital of India',
|
|
41
|
-
infoTooltip: 'Capital of India'
|
|
42
|
-
}];
|
|
43
27
|
describe('RadioField', function () {
|
|
44
28
|
test('rendering the defult props', function () {
|
|
45
29
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioField["default"], {
|
|
@@ -66,21 +50,4 @@ describe('RadioField', function () {
|
|
|
66
50
|
|
|
67
51
|
expect(asFragment()).toMatchSnapshot();
|
|
68
52
|
});
|
|
69
|
-
test('rendering with secondaryTextOptions', function () {
|
|
70
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioField["default"], {
|
|
71
|
-
options: optionsWithsecondaryText
|
|
72
|
-
})),
|
|
73
|
-
asFragment = _render4.asFragment;
|
|
74
|
-
|
|
75
|
-
expect(asFragment()).toMatchSnapshot();
|
|
76
|
-
});
|
|
77
|
-
test('rendering with secondaryTextOptions & isBoxStyle', function () {
|
|
78
|
-
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioField["default"], {
|
|
79
|
-
options: optionsWithsecondaryText,
|
|
80
|
-
isBoxStyle: true
|
|
81
|
-
})),
|
|
82
|
-
asFragment = _render5.asFragment;
|
|
83
|
-
|
|
84
|
-
expect(asFragment()).toMatchSnapshot();
|
|
85
|
-
});
|
|
86
53
|
});
|