@zohodesk/dot 1.0.0-temp-222.1 → 1.0.0-temp-220.4

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.
@@ -8,7 +8,6 @@ export const defaultProps = {
8
8
  labelSize: 'medium',
9
9
  labelPalette: 'default',
10
10
  isActive: false,
11
- customClass: {},
12
11
  customProps: {},
13
12
  dataSelectorId: 'radioField'
14
13
  };
@@ -22,12 +22,6 @@ 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
- },
31
25
  customProps: PropTypes.shape({
32
26
  LabelProps: PropTypes.object,
33
27
  RadioProps: PropTypes.object,
@@ -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
- return /*#__PURE__*/React.createElement(GlobalNotificationUI, {
75
- type: type,
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.number,
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.number,
32
+ id: PropTypes.string,
32
33
  onClose: PropTypes.func
33
34
  };
34
35
  export const new_propTypes = {
@@ -0,0 +1,6 @@
1
+ export const STATUS = {
2
+ MOUNTED: 'mounted',
3
+ UNMOUNTED: 'unmounted',
4
+ UPDATED: 'updated',
5
+ DISMISSING: 'dismissing'
6
+ };
@@ -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
- .radioBox.withSecondaryText {
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");
@@ -161,7 +159,6 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
161
159
  isReadOnly = _this$props6.isReadOnly,
162
160
  isBoxStyle = _this$props6.isBoxStyle,
163
161
  variant = _this$props6.variant,
164
- customClass = _this$props6.customClass,
165
162
  customProps = _this$props6.customProps;
166
163
  var _customProps$LabelPro = customProps.LabelProps,
167
164
  LabelProps = _customProps$LabelPro === void 0 ? {} : _customProps$LabelPro,
@@ -173,16 +170,8 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
173
170
  ValidationMessageProps1 = _customProps$Validati === void 0 ? {} : _customProps$Validati,
174
171
  _customProps$Validati2 = customProps.ValidationMessageProps2,
175
172
  ValidationMessageProps2 = _customProps$Validati2 === void 0 ? {} : _customProps$Validati2;
176
- var _customClass$customWr = customClass.customWrapperClass,
177
- customWrapperClass = _customClass$customWr === void 0 ? '' : _customClass$customWr,
178
- _customClass$customLa = customClass.customLabelClass,
179
- customLabelClass = _customClass$customLa === void 0 ? '' : _customClass$customLa,
180
- _customClass$customRa = customClass.customRadioWrapperClass,
181
- customRadioWrapperClass = _customClass$customRa === void 0 ? '' : _customClass$customRa,
182
- _customClass$customRa2 = customClass.customRadioClass,
183
- customRadioClass = _customClass$customRa2 === void 0 ? '' : _customClass$customRa2;
184
173
  return /*#__PURE__*/_react["default"].createElement("div", {
185
- className: "".concat(_FieldsModule["default"].container, " ").concat(isDisabled ? _FieldsModule["default"].disabled : isReadOnly ? _FieldsModule["default"].readonly : '', " ").concat(customWrapperClass),
174
+ className: "".concat(_FieldsModule["default"].container, " ").concat(isDisabled ? _FieldsModule["default"].disabled : isReadOnly ? _FieldsModule["default"].readonly : ''),
186
175
  "data-title": isDisabled ? title : null,
187
176
  "data-selector-id": dataSelectorId
188
177
  }, labelName && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
@@ -190,35 +179,23 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
190
179
  size: "medium",
191
180
  id: id,
192
181
  palette: isMandatory ? 'mandatory' : isDisabled ? 'primary' : 'default',
193
- customClass: "".concat(_FieldsModule["default"].fieldLabel, " ").concat(isMandatory ? _FieldsModule["default"].labelMandatory : '', " ").concat(customLabelClass),
182
+ customClass: "".concat(_FieldsModule["default"].fieldLabel, " ").concat(isMandatory ? _FieldsModule["default"].labelMandatory : ''),
194
183
  dataId: isDisabled ? "".concat(dataId, "_label_disabled") : isMandatory ? "".concat(dataId, "_label_mandatory") : "".concat(dataId, "_label")
195
184
  }, LabelProps)), /*#__PURE__*/_react["default"].createElement("div", {
196
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)
197
186
  }, options.map(function (option, index) {
198
- var _compileClassNames;
199
-
200
187
  var text = option.text,
201
188
  value = option.value,
202
189
  _option$disabled = option.disabled,
203
190
  disabled = _option$disabled === void 0 ? false : _option$disabled,
204
191
  tooltip = option.tooltip,
205
- infoTooltip = option.infoTooltip,
206
- secondaryText = option.secondaryText,
207
- renderRightPlaceholderNode = option.renderRightPlaceholderNode,
208
- customProps = option.customProps;
192
+ infoTooltip = option.infoTooltip;
209
193
  var isDisabledState = disabled || isDisabled;
210
194
  var isChecked = selectedValue == value;
211
- var rightPlaceholderNode = !!infoTooltip ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Icon["default"], _extends({
212
- name: "ZD-GN-info",
213
- size: "16",
214
- title: infoTooltip,
215
- iconClass: _FieldsModule["default"].infoIcon
216
- }, InfoIconProps)), renderRightPlaceholderNode) : renderRightPlaceholderNode;
217
- var radioBoxClasses = isBoxStyle ? (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, customRadioClass, !!customRadioClass), _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)) : '';
218
195
  return /*#__PURE__*/_react["default"].createElement("span", {
219
- key: text,
220
- className: "".concat(!isBoxStyle ? _FieldsModule["default"].radio : '', " ").concat(_FieldsModule["default"].radioWrap, " ").concat(customRadioWrapperClass)
221
- }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], _extends({}, customProps, {
196
+ key: index,
197
+ className: "".concat(!isBoxStyle ? _FieldsModule["default"].radio : '', " ").concat(_FieldsModule["default"].radioWrap)
198
+ }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], _extends({
222
199
  id: index,
223
200
  value: value,
224
201
  name: id,
@@ -235,21 +212,20 @@ var RadioField = /*#__PURE__*/function (_PureComponent) {
235
212
  checked: isChecked,
236
213
  dataId: dataId,
237
214
  isReadOnly: isReadOnly,
238
- variant: variant,
239
- secondaryText: secondaryText
215
+ variant: variant
240
216
  }, RadioProps, {
241
217
  a11y: _objectSpread({
242
218
  tabIndex: !!selectedValue ? isChecked ? '0' : '-1' : index === 0 ? '0' : '-1'
243
219
  }, RadioProps.a11y),
244
220
  customClass: _objectSpread({
245
- customRadioWrap: radioBoxClasses
246
- }, RadioProps.customClass),
247
- customProps: _objectSpread(_objectSpread({}, RadioProps.customProps), {}, {
248
- LabelProps: _objectSpread(_objectSpread({}, RadioProps.customProps ? RadioProps.customProps.LabelProps : undefined), {}, {
249
- renderRightPlaceholderNode: rightPlaceholderNode
250
- })
251
- })
252
- })));
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));
253
229
  })), validationMessage && /*#__PURE__*/_react["default"].createElement(_ValidationMessage["default"], _extends({
254
230
  text: validationMessage,
255
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
  });