@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.
Files changed (28) hide show
  1. package/README.md +11 -0
  2. package/es/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
  3. package/es/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
  4. package/es/form/fields/Fields.module.css +8 -3
  5. package/es/form/fields/RadioField/RadioField.js +40 -14
  6. package/es/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
  7. package/es/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
  8. package/es/form/fields/RadioField/props/defaultProps.js +1 -0
  9. package/es/form/fields/RadioField/props/propTypes.js +6 -0
  10. package/es/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
  11. package/es/version2/GlobalNotification/GlobalNotification.js +46 -7
  12. package/es/version2/GlobalNotification/__tests__/GlobalNotification.spec.js +9 -0
  13. package/es/version2/GlobalNotification/props/propTypes.js +4 -3
  14. package/es/version2/GlobalNotification/utils/constants.js +6 -0
  15. package/lib/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
  16. package/lib/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
  17. package/lib/form/fields/Fields.module.css +8 -3
  18. package/lib/form/fields/RadioField/RadioField.js +39 -15
  19. package/lib/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
  20. package/lib/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
  21. package/lib/form/fields/RadioField/props/defaultProps.js +1 -0
  22. package/lib/form/fields/RadioField/props/propTypes.js +6 -0
  23. package/lib/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
  24. package/lib/version2/GlobalNotification/GlobalNotification.js +68 -18
  25. package/lib/version2/GlobalNotification/__tests__/GlobalNotification.spec.js +10 -0
  26. package/lib/version2/GlobalNotification/props/propTypes.js +4 -3
  27. package/lib/version2/GlobalNotification/utils/constants.js +13 -0
  28. package/package.json +10 -10
@@ -14,6 +14,7 @@ var defaultProps = {
14
14
  labelSize: 'medium',
15
15
  labelPalette: 'default',
16
16
  isActive: false,
17
+ customClass: {},
17
18
  customProps: {},
18
19
  dataSelectorId: 'radioField'
19
20
  };
@@ -32,6 +32,12 @@ var propTypes = {
32
32
  validationRuleMessage: _propTypes["default"].string,
33
33
  validationRulePalette: _propTypes["default"].string,
34
34
  variant: _propTypes["default"].oneOf(['primary', 'default', 'secondary']),
35
+ customClass: {
36
+ customWrapperClass: _propTypes["default"].string,
37
+ customLabelClass: _propTypes["default"].string,
38
+ customRadioWrapperClass: _propTypes["default"].string,
39
+ customRadioClass: _propTypes["default"].string
40
+ },
35
41
  customProps: _propTypes["default"].shape({
36
42
  LabelProps: _propTypes["default"].object,
37
43
  RadioProps: _propTypes["default"].object,
@@ -29,7 +29,7 @@ exports[`AvatarFlip rendering the defult props 1`] = `
29
29
  tabindex="0"
30
30
  >
31
31
  <div
32
- class="boxContainer medium filled shrinkOff"
32
+ class="boxContainer medium filled shrinkOff"
33
33
  data-id="boxComponent"
34
34
  data-selector-id="box"
35
35
  data-test-id="boxComponent"
@@ -27,10 +27,20 @@ var _Layout = require("@zohodesk/components/es/Layout");
27
27
 
28
28
  var _Common = require("@zohodesk/components/es/utils/Common");
29
29
 
30
+ var _getCurrentTime = _interopRequireDefault(require("@zohodesk/utils/es/getCurrentTime"));
31
+
32
+ var _constants = require("./utils/constants");
33
+
30
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
35
 
32
36
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
33
37
 
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
+
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
41
+
42
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
+
34
44
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
35
45
 
36
46
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -67,30 +77,61 @@ var GlobalNotification = /*#__PURE__*/function (_React$Component) {
67
77
  shadowClose: true
68
78
  };
69
79
  _this.onClose = _this.onClose.bind(_assertThisInitialized(_this));
80
+ _this.getNotificationData = _this.getNotificationData.bind(_assertThisInitialized(_this));
81
+ _this.handleStatusChange = _this.handleStatusChange.bind(_assertThisInitialized(_this));
70
82
  return _this;
71
83
  }
72
84
 
73
85
  _createClass(GlobalNotification, [{
74
86
  key: "componentDidMount",
75
87
  value: function componentDidMount() {
88
+ var _this2 = this;
89
+
76
90
  var _this$props = this.props,
77
91
  hideMessage = _this$props.hideMessage,
78
92
  hideTime = _this$props.hideTime,
79
93
  id = _this$props.id,
80
94
  needAutoClose = _this$props.needAutoClose;
95
+ this.handleStatusChange(_constants.STATUS.MOUNTED);
81
96
 
82
97
  if (needAutoClose) {
83
98
  this.hideMessageTimer = setTimeout(function () {
84
99
  hideMessage(id);
100
+
101
+ _this2.handleStatusChange(_constants.STATUS.DISMISSING);
85
102
  }, hideTime);
86
103
  }
87
104
  }
105
+ }, {
106
+ key: "componentDidUpdate",
107
+ value: function componentDidUpdate(prevProps) {
108
+ if (prevProps.id === this.props.id && (prevProps.message !== this.props.message || prevProps.type !== this.props.type)) {
109
+ this.handleStatusChange(_constants.STATUS.UPDATED);
110
+ }
111
+ }
88
112
  }, {
89
113
  key: "componentWillUnmount",
90
114
  value: function componentWillUnmount() {
91
115
  if (this.hideMessageTimer) {
92
116
  clearTimeout(this.hideMessageTimer);
93
117
  }
118
+
119
+ this.handleStatusChange(_constants.STATUS.UNMOUNTED);
120
+ }
121
+ }, {
122
+ key: "handleStatusChange",
123
+ value: function handleStatusChange(status) {
124
+ var onStatusChange = this.props.onStatusChange;
125
+
126
+ if (typeof onStatusChange == 'function') {
127
+ var notificationData = this.getNotificationData();
128
+ var currentTime = (0, _getCurrentTime["default"])();
129
+ onStatusChange(_objectSpread(_objectSpread({
130
+ status: status
131
+ }, notificationData), {}, {
132
+ time: currentTime
133
+ }));
134
+ }
94
135
  }
95
136
  }, {
96
137
  key: "onClose",
@@ -102,42 +143,51 @@ var GlobalNotification = /*#__PURE__*/function (_React$Component) {
102
143
  this.setState({
103
144
  shadowClose: false
104
145
  });
146
+ this.handleStatusChange(_constants.STATUS.DISMISSING);
105
147
  hideMessage && hideMessage(id);
106
148
  onClose && onClose(e);
107
149
  }
108
150
  }, {
109
- key: "render",
110
- value: function render() {
151
+ key: "getNotificationData",
152
+ value: function getNotificationData() {
111
153
  var _this$props3 = this.props,
112
- type = _this$props3.type,
113
- message = _this$props3.message,
114
- hideMessage = _this$props3.hideMessage,
115
- onClick = _this$props3.onClick,
116
- _this$props3$i18nKeys = _this$props3.i18nKeys,
117
- i18nKeys = _this$props3$i18nKeys === void 0 ? {} : _this$props3$i18nKeys,
118
- customProps = _this$props3.customProps,
119
- dataSelectorId = _this$props3.dataSelectorId,
120
154
  id = _this$props3.id,
121
- needShadow = _this$props3.needShadow,
122
- shadowCount = _this$props3.shadowCount,
123
- eleRef = _this$props3.eleRef;
155
+ type = _this$props3.type,
156
+ message = _this$props3.message;
157
+ return {
158
+ id: id,
159
+ type: type,
160
+ message: message
161
+ };
162
+ }
163
+ }, {
164
+ key: "render",
165
+ value: function render() {
166
+ var _this$props4 = this.props,
167
+ hideMessage = _this$props4.hideMessage,
168
+ onClick = _this$props4.onClick,
169
+ _this$props4$i18nKeys = _this$props4.i18nKeys,
170
+ i18nKeys = _this$props4$i18nKeys === void 0 ? {} : _this$props4$i18nKeys,
171
+ customProps = _this$props4.customProps,
172
+ dataSelectorId = _this$props4.dataSelectorId,
173
+ needShadow = _this$props4.needShadow,
174
+ shadowCount = _this$props4.shadowCount,
175
+ eleRef = _this$props4.eleRef;
124
176
  var shadowClose = this.state.shadowClose;
125
177
  var _i18nKeys$closeTitle = i18nKeys.closeTitle,
126
178
  closeTitle = _i18nKeys$closeTitle === void 0 ? 'Close' : _i18nKeys$closeTitle;
127
- return /*#__PURE__*/_react["default"].createElement(GlobalNotificationUI, {
128
- type: type,
129
- message: message,
179
+ var notificationData = this.getNotificationData();
180
+ return /*#__PURE__*/_react["default"].createElement(GlobalNotificationUI, _extends({}, notificationData, {
130
181
  hideMessage: hideMessage,
131
182
  onClick: onClick,
132
183
  closeTitle: closeTitle,
133
184
  customProps: customProps,
134
185
  dataSelectorId: dataSelectorId,
135
- id: id,
136
186
  shadowCount: shadowCount,
137
187
  onClose: this.onClose,
138
188
  needShadow: shadowClose && needShadow,
139
189
  eleRef: eleRef
140
- });
190
+ }));
141
191
  }
142
192
  }]);
143
193
 
@@ -6,6 +6,8 @@ var _react2 = require("@testing-library/react");
6
6
 
7
7
  var _GlobalNotification = _interopRequireDefault(require("../GlobalNotification"));
8
8
 
9
+ var _constants = require("../utils/constants");
10
+
9
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
12
 
11
13
  describe('GlobalNotification', function () {
@@ -15,4 +17,12 @@ describe('GlobalNotification', function () {
15
17
 
16
18
  expect(asFragment()).toMatchSnapshot();
17
19
  });
20
+ });
21
+ describe('GlobalNotification Constants', function () {
22
+ test('should have correct constant values', function () {
23
+ expect(_constants.STATUS.MOUNTED).toBe('mounted');
24
+ expect(_constants.STATUS.UPDATED).toBe('updated');
25
+ expect(_constants.STATUS.DISMISSING).toBe('dismissing');
26
+ expect(_constants.STATUS.UNMOUNTED).toBe('unmounted');
27
+ });
18
28
  });
@@ -20,12 +20,13 @@ var propTypes = {
20
20
  customProps: _propTypes["default"].shape({
21
21
  ExtraProps: _propTypes["default"].object
22
22
  }),
23
- id: _propTypes["default"].number,
23
+ id: _propTypes["default"].string,
24
24
  hideTime: _propTypes["default"].number,
25
25
  needAutoClose: _propTypes["default"].bool,
26
26
  isCollapseView: _propTypes["default"].bool,
27
27
  shadowCount: _propTypes["default"].number,
28
- needShadow: _propTypes["default"].bool
28
+ needShadow: _propTypes["default"].bool,
29
+ onStatusChange: _propTypes["default"].func
29
30
  };
30
31
  exports.propTypes = propTypes;
31
32
  var UI_propTypes = {
@@ -39,7 +40,7 @@ var UI_propTypes = {
39
40
  }),
40
41
  needShadow: _propTypes["default"].bool,
41
42
  shadowCount: _propTypes["default"].number,
42
- id: _propTypes["default"].number,
43
+ id: _propTypes["default"].string,
43
44
  onClose: _propTypes["default"].func
44
45
  };
45
46
  exports.UI_propTypes = UI_propTypes;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.STATUS = void 0;
7
+ var STATUS = {
8
+ MOUNTED: 'mounted',
9
+ UNMOUNTED: 'unmounted',
10
+ UPDATED: 'updated',
11
+ DISMISSING: 'dismissing'
12
+ };
13
+ exports.STATUS = STATUS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/dot",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "main": "lib/index",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -73,29 +73,29 @@
73
73
  "@zohodesk-private/node-plugins": "1.1.13",
74
74
  "@zohodesk-private/react-prop-validator": "1.2.3",
75
75
  "@zohodesk/a11y": "2.3.8",
76
- "@zohodesk/components": "1.5.1",
76
+ "@zohodesk/components": "1.5.3",
77
77
  "@zohodesk/hooks": "2.0.6",
78
- "@zohodesk/icons": "1.1.3",
78
+ "@zohodesk/icons": "1.1.4",
79
79
  "@zohodesk/layout": "^3.1.0",
80
- "@zohodesk/svg": "1.2.3",
81
- "@zohodesk/utils": "1.3.15",
80
+ "@zohodesk/svg": "1.2.5",
81
+ "@zohodesk/utils": "1.3.16",
82
82
  "@zohodesk/variables": "1.2.0",
83
83
  "@zohodesk/virtualizer": "1.0.13",
84
84
  "react-sortable-hoc": "^0.8.3",
85
85
  "velocity-react": "1.4.3",
86
- "@zohodesk/dotkit": "1.0.3",
86
+ "@zohodesk/dotkit": "1.0.4",
87
87
  "@zohodesk/react-cli": "1.1.27"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "velocity-react": "1.4.3",
91
91
  "@zohodesk/variables": "1.2.0",
92
- "@zohodesk/components": "1.5.1",
93
- "@zohodesk/icons": "1.1.3",
94
- "@zohodesk/svg": "1.2.3",
92
+ "@zohodesk/components": "1.5.3",
93
+ "@zohodesk/icons": "1.1.4",
94
+ "@zohodesk/svg": "1.2.5",
95
95
  "@zohodesk/virtualizer": "1.0.13",
96
96
  "react-sortable-hoc": "^0.8.3",
97
97
  "@zohodesk/hooks": "2.0.6",
98
- "@zohodesk/utils": "1.3.15",
98
+ "@zohodesk/utils": "1.3.16",
99
99
  "@zohodesk/a11y": "2.3.8",
100
100
  "@zohodesk/layout": "3.1.0"
101
101
  }