@zohodesk/components 1.2.48 → 1.2.50

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 (50) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +24 -1
  3. package/es/DateTime/CalendarView.js +8 -5
  4. package/es/DateTime/DateTime.js +18 -4
  5. package/es/DateTime/DateTime.module.css +5 -5
  6. package/es/DateTime/DateWidget.js +5 -1
  7. package/es/DateTime/DaysRow.js +3 -2
  8. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +7 -7
  9. package/es/DateTime/props/defaultProps.js +9 -3
  10. package/es/DateTime/props/propTypes.js +11 -4
  11. package/es/DropBox/DropBoxElement/DropBoxElement.js +3 -1
  12. package/es/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +1 -0
  13. package/es/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +1 -0
  14. package/es/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +1 -0
  15. package/es/Popup/Popup.js +107 -8
  16. package/es/Popup/intersectionObserver.js +39 -0
  17. package/es/Popup/props/propTypes.js +30 -0
  18. package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
  19. package/es/TextBox/TextBox.js +1 -1
  20. package/es/v1/DateTime/CalendarView.js +9 -6
  21. package/es/v1/DateTime/DateTime.js +18 -4
  22. package/es/v1/DateTime/DateWidget.js +5 -1
  23. package/es/v1/DateTime/DaysRow.js +3 -2
  24. package/es/v1/DateTime/props/defaultProps.js +9 -3
  25. package/es/v1/DateTime/props/propTypes.js +11 -4
  26. package/lib/DateTime/CalendarView.js +8 -5
  27. package/lib/DateTime/DateTime.js +27 -4
  28. package/lib/DateTime/DateTime.module.css +5 -5
  29. package/lib/DateTime/DateWidget.js +5 -1
  30. package/lib/DateTime/DaysRow.js +3 -2
  31. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +7 -7
  32. package/lib/DateTime/props/defaultProps.js +9 -3
  33. package/lib/DateTime/props/propTypes.js +11 -4
  34. package/lib/DropBox/DropBoxElement/DropBoxElement.js +3 -1
  35. package/lib/DropBox/DropBoxElement/__tests__/__snapshots__/DropBoxElement.spec.js.snap +1 -0
  36. package/lib/DropBox/__tests__/__snapshots__/DropBox.spec.js.snap +1 -0
  37. package/lib/DropDown/__tests__/__snapshots__/DropDown.spec.js.snap +1 -0
  38. package/lib/Popup/Popup.js +118 -9
  39. package/lib/Popup/intersectionObserver.js +62 -0
  40. package/lib/Popup/props/propTypes.js +51 -0
  41. package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1 -0
  42. package/lib/TextBox/TextBox.js +1 -1
  43. package/lib/v1/DateTime/CalendarView.js +9 -6
  44. package/lib/v1/DateTime/DateTime.js +27 -4
  45. package/lib/v1/DateTime/DateWidget.js +5 -1
  46. package/lib/v1/DateTime/DaysRow.js +3 -2
  47. package/lib/v1/DateTime/props/defaultProps.js +9 -3
  48. package/lib/v1/DateTime/props/propTypes.js +11 -4
  49. package/package.json +4 -4
  50. package/result.json +1 -1
@@ -9,10 +9,10 @@ exports["default"] = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
12
  var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
15
13
 
14
+ var _propTypes = require("./props/propTypes");
15
+
16
16
  var _Common = require("../utils/Common.js");
17
17
 
18
18
  var _viewPort = _interopRequireDefault(require("./viewPort"));
@@ -21,6 +21,8 @@ var _PositionMapping = require("./PositionMapping.js");
21
21
 
22
22
  var _ResizeObserver = _interopRequireDefault(require("@zohodesk/virtualizer/lib/commons/ResizeObserver.js"));
23
23
 
24
+ var _intersectionObserver = require("./intersectionObserver");
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
27
 
26
28
  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); }
@@ -151,6 +153,12 @@ var Popup = function Popup(Component) {
151
153
  _this.handleDocumentMouseDown = _this.handleDocumentMouseDown.bind(_assertThisInitialized(_this));
152
154
  _this.handleDocumentFocus = _this.handleDocumentFocus.bind(_assertThisInitialized(_this));
153
155
  _this.handleGetNeedPrevent = _this.handleGetNeedPrevent.bind(_assertThisInitialized(_this));
156
+ _this.handleBlockScroll = _this.handleBlockScroll.bind(_assertThisInitialized(_this));
157
+ _this.handlePositionChange = _this.handlePositionChange.bind(_assertThisInitialized(_this));
158
+ _this.preventKeyboardScroll = _this.preventKeyboardScroll.bind(_assertThisInitialized(_this));
159
+ _this.addScrollBlockListeners = _this.addScrollBlockListeners.bind(_assertThisInitialized(_this));
160
+ _this.removeScrollBlockListeners = _this.removeScrollBlockListeners.bind(_assertThisInitialized(_this));
161
+ _this.handleIntersectionObserver = _this.handleIntersectionObserver.bind(_assertThisInitialized(_this));
154
162
  _this.popupObserver = new _ResizeObserver["default"](_this.handlePopupResize); //dropBoxSize
155
163
 
156
164
  _this.size = null;
@@ -164,6 +172,7 @@ var Popup = function Popup(Component) {
164
172
  scrollDebounceTime = _this$getScrollDeboun.scrollDebounceTime;
165
173
 
166
174
  _this.handleScroll = (0, _Common.debounce)(_this.handleScroll.bind(_assertThisInitialized(_this)), scrollDebounceTime);
175
+ _this.handleDebouncedPositionChange = (0, _Common.debounce)(_this.handlePositionChange.bind(_assertThisInitialized(_this)), 100);
167
176
  return _this;
168
177
  }
169
178
 
@@ -207,7 +216,10 @@ var Popup = function Popup(Component) {
207
216
  oldStateOpen = _ref2$isPopupReady === void 0 ? false : _ref2$isPopupReady;
208
217
 
209
218
  var dropElement = this.dropElement;
210
- var propResizeHandling = this.props.needResizeHandling;
219
+ var _this$props = this.props,
220
+ propResizeHandling = _this$props.needResizeHandling,
221
+ isAbsolutePositioningNeeded = _this$props.isAbsolutePositioningNeeded,
222
+ isOutsideScrollBlocked = _this$props.isOutsideScrollBlocked;
211
223
 
212
224
  if (oldStateOpen !== isPopupReady) {
213
225
  if (isPopupReady && dropElement && (propResizeHandling !== undefined ? propResizeHandling : needResizeHandling)) {
@@ -216,6 +228,16 @@ var Popup = function Popup(Component) {
216
228
  this.size = null;
217
229
  this.popupObserver.disconnect();
218
230
  }
231
+
232
+ if (isOutsideScrollBlocked && !isAbsolutePositioningNeeded) {
233
+ if (isPopupReady) {
234
+ (0, _intersectionObserver.addIntersectionObserver)(this.placeHolderElement, this.handleIntersectionObserver);
235
+ this.addScrollBlockListeners();
236
+ } else {
237
+ (0, _intersectionObserver.removeIntersectionObserver)(this.placeHolderElement, this.handleIntersectionObserver);
238
+ this.removeScrollBlockListeners();
239
+ }
240
+ }
219
241
  }
220
242
  }
221
243
  }, {
@@ -236,6 +258,8 @@ var Popup = function Popup(Component) {
236
258
 
237
259
  return res;
238
260
  }, popups);
261
+ (0, _intersectionObserver.removeIntersectionObserver)(this.placeHolderElement, this.handleIntersectionObserver);
262
+ this.removeScrollBlockListeners();
239
263
  var noPopups = true;
240
264
 
241
265
  for (var i in popups) {
@@ -259,6 +283,88 @@ var Popup = function Popup(Component) {
259
283
  document.removeEventListener('focus', this.handleDocumentFocus, true);
260
284
  }
261
285
  }
286
+ }, {
287
+ key: "addScrollBlockListeners",
288
+ value: function addScrollBlockListeners() {
289
+ document.addEventListener('wheel', this.handleBlockScroll, {
290
+ capture: true,
291
+ passive: false
292
+ });
293
+ document.addEventListener('touchmove', this.handleBlockScroll, {
294
+ capture: true,
295
+ passive: false
296
+ });
297
+ document.addEventListener('scroll', this.handleDebouncedPositionChange, {
298
+ capture: true,
299
+ passive: false
300
+ });
301
+ document.addEventListener('keydown', this.preventKeyboardScroll, {
302
+ capture: true,
303
+ passive: false
304
+ });
305
+ }
306
+ }, {
307
+ key: "removeScrollBlockListeners",
308
+ value: function removeScrollBlockListeners() {
309
+ document.removeEventListener('wheel', this.handleBlockScroll, {
310
+ capture: true,
311
+ passive: false
312
+ });
313
+ document.removeEventListener('touchmove', this.handleBlockScroll, {
314
+ capture: true,
315
+ passive: false
316
+ });
317
+ document.removeEventListener('scroll', this.handleDebouncedPositionChange, {
318
+ capture: true,
319
+ passive: false
320
+ });
321
+ document.removeEventListener('keydown', this.preventKeyboardScroll, {
322
+ capture: true,
323
+ passive: false
324
+ });
325
+ }
326
+ }, {
327
+ key: "handleBlockScroll",
328
+ value: function handleBlockScroll(event) {
329
+ // const targetElement = this.placeHolderElement;
330
+ var containerElement = this.dropElement;
331
+
332
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target)) {
333
+ // --- Scroll exclude Target & Container elements --- For reference. Will adopt in future
334
+ // if(
335
+ // (containerElement && (containerElement !== event.target && !containerElement.contains(event.target)))
336
+ // && (targetElement && (targetElement !== event.target && !targetElement.contains(event.target)))
337
+ // ) {
338
+ event.preventDefault();
339
+ }
340
+ }
341
+ }, {
342
+ key: "handlePositionChange",
343
+ value: function handlePositionChange(event) {
344
+ var targetElement = this.placeHolderElement;
345
+ var containerElement = this.dropElement;
346
+
347
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && targetElement && targetElement !== event.target && !targetElement.contains(event.target) && event.target.contains(targetElement)) {
348
+ this.handlePopupPosition(this.state.position); // this.closePopupOnly(event);
349
+ }
350
+ }
351
+ }, {
352
+ key: "preventKeyboardScroll",
353
+ value: function preventKeyboardScroll(event) {
354
+ var containerElement = this.dropElement;
355
+ var keys = [32, 37, 38, 39, 40]; // Space, Arrow keys
356
+
357
+ if (containerElement && containerElement !== event.target && !containerElement.contains(event.target) && keys.includes(event.keyCode)) {
358
+ event.preventDefault();
359
+ }
360
+ }
361
+ }, {
362
+ key: "handleIntersectionObserver",
363
+ value: function handleIntersectionObserver(entry) {
364
+ if (entry.intersectionRatio === 0) {
365
+ this.closePopupOnly();
366
+ }
367
+ }
262
368
  }, {
263
369
  key: "getGroup",
264
370
  value: function getGroup() {
@@ -587,15 +693,19 @@ var Popup = function Popup(Component) {
587
693
  _ref6$left = _ref6.left,
588
694
  oldLeft = _ref6$left === void 0 ? '' : _ref6$left,
589
695
  _ref6$top = _ref6.top,
590
- oldTop = _ref6$top === void 0 ? '' : _ref6$top;
696
+ oldTop = _ref6$top === void 0 ? '' : _ref6$top,
697
+ _ref6$bottom = _ref6.bottom,
698
+ oldBottom = _ref6$bottom === void 0 ? '' : _ref6$bottom;
591
699
 
592
700
  var _ref7 = viewsOffset[view] || {},
593
701
  _ref7$left = _ref7.left,
594
702
  left = _ref7$left === void 0 ? '' : _ref7$left,
595
703
  _ref7$top = _ref7.top,
596
- top = _ref7$top === void 0 ? '' : _ref7$top;
704
+ top = _ref7$top === void 0 ? '' : _ref7$top,
705
+ _ref7$bottom = _ref7.bottom,
706
+ bottom = _ref7$bottom === void 0 ? '' : _ref7$bottom;
597
707
 
598
- var changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top; // let isInViewPort = viewPort.isInViewPort(
708
+ var changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top || oldBottom !== bottom; // let isInViewPort = viewPort.isInViewPort(
599
709
  // placeHolderElement,
600
710
  // scrollContainer
601
711
  // );
@@ -705,9 +815,8 @@ var Popup = function Popup(Component) {
705
815
  }(_react["default"].Component);
706
816
 
707
817
  Popup.displayName = Component.displayName || Component.name || Popup.name;
708
- Popup.contextTypes = {
709
- direction: _propTypes["default"].string
710
- };
818
+ Popup.contextTypes = _propTypes.ContextTypes;
819
+ Popup.propTypes = _propTypes.PopupPropTypes;
711
820
  return (0, _hoistNonReactStatics["default"])(Popup, Component);
712
821
  };
713
822
 
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addIntersectionObserver = addIntersectionObserver;
7
+ exports.removeIntersectionObserver = removeIntersectionObserver;
8
+
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+
11
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
+
17
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+
21
+ var observerCallbacks = null;
22
+ var intersectionObserver = null;
23
+
24
+ function handleObserverCallbacks(entries) {
25
+ entries.map(function (entry, i) {
26
+ var oldCallbacks = observerCallbacks.get(entry.target);
27
+ oldCallbacks.length && oldCallbacks.forEach(function (callback) {
28
+ callback && callback(entry);
29
+ });
30
+ });
31
+ }
32
+
33
+ function addIntersectionObserver(element, callback, options) {
34
+ if (intersectionObserver === null && observerCallbacks === null) {
35
+ intersectionObserver = new IntersectionObserver(function (entries) {
36
+ handleObserverCallbacks(entries);
37
+ }, options);
38
+ observerCallbacks = new Map();
39
+ }
40
+
41
+ intersectionObserver.observe(element);
42
+ var oldCallbacks = observerCallbacks.get(element) || [];
43
+ observerCallbacks.set(element, [].concat(_toConsumableArray(oldCallbacks), [callback]));
44
+ }
45
+
46
+ function removeIntersectionObserver(element, callback) {
47
+ var oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : [];
48
+ oldCallbacks = oldCallbacks.filter(function (handler) {
49
+ return handler !== callback;
50
+ });
51
+
52
+ if (intersectionObserver && oldCallbacks.length === 0) {
53
+ observerCallbacks["delete"](element);
54
+ intersectionObserver.unobserve(element);
55
+ }
56
+
57
+ if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
58
+ intersectionObserver.disconnect();
59
+ intersectionObserver = null;
60
+ observerCallbacks = null;
61
+ }
62
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PopupWrappersPropTypes = exports.PopupPropTypes = exports.ContextTypes = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ 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; }
13
+
14
+ 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; }
15
+
16
+ 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; }
17
+
18
+ var ContextTypes = {
19
+ direction: _propTypes["default"].string
20
+ };
21
+ exports.ContextTypes = ContextTypes;
22
+ var PopupPropTypes = {
23
+ popupGroup: _propTypes["default"].string,
24
+ isArrow: _propTypes["default"].bool,
25
+ isPopupOpen: _propTypes["default"].bool,
26
+ closeOnScroll: _propTypes["default"].bool,
27
+ isOutsideScrollBlocked: _propTypes["default"].bool,
28
+ needResizeHandling: _propTypes["default"].bool,
29
+ isAbsolutePositioningNeeded: _propTypes["default"].bool,
30
+ scrollDebounceTime: _propTypes["default"].number,
31
+ customOrder: _propTypes["default"].arrayOf(_propTypes["default"].string),
32
+ checkBeforeClose: _propTypes["default"].func
33
+ };
34
+ exports.PopupPropTypes = PopupPropTypes;
35
+
36
+ var PopupWrappersPropTypes = _objectSpread(_objectSpread({
37
+ openPopupOnly: _propTypes["default"].func,
38
+ closePopupOnly: _propTypes["default"].func,
39
+ togglePopup: _propTypes["default"].func,
40
+ removeClose: _propTypes["default"].func,
41
+ isPopupReady: _propTypes["default"].bool,
42
+ position: _propTypes["default"].oneOf(['bottomRight', 'bottomLeft', 'bottomCenter', 'topRight', 'topLeft', 'topCenter', 'rightTop', 'rightBottom', 'rightCenter', 'leftTop', 'leftBottom', 'leftCenter']),
43
+ getTargetRef: _propTypes["default"].func,
44
+ getContainerRef: _propTypes["default"].func
45
+ }, PopupPropTypes), {}, {
46
+ isRestrictScroll: _propTypes["default"].bool,
47
+ positionsOffset: _propTypes["default"].object,
48
+ targetOffset: _propTypes["default"].object
49
+ });
50
+
51
+ exports.PopupWrappersPropTypes = PopupWrappersPropTypes;
@@ -9,6 +9,7 @@ exports[`ResponsiveDropBox rendering the defult props 1`] = `
9
9
  data-position="bottomStart"
10
10
  data-selector-id="dropBox"
11
11
  data-test-id="dropBox"
12
+ dot-ui-element="dropbox"
12
13
  >
13
14
  <div
14
15
  class="subContainer bottom_shadow radius defaultPalette"
@@ -211,7 +211,7 @@ var TextBox = /*#__PURE__*/function (_React$PureComponent) {
211
211
  ref: this.inputRef,
212
212
  type: type,
213
213
  value: value,
214
- onScroll: isScrollPrevent ? this.handlePreventTextBoxScroll : '',
214
+ onScroll: isScrollPrevent ? this.handlePreventTextBoxScroll : null,
215
215
  onKeyPress: onKeyPress,
216
216
  onMouseDown: onMouseDown
217
217
  }, options, customProps));
@@ -84,9 +84,11 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
84
84
  todayDate = _this$props.todayDate,
85
85
  todayYear = _this$props.todayYear,
86
86
  startDate = _this$props.startDate,
87
- endDate = _this$props.endDate;
87
+ endDate = _this$props.endDate,
88
+ weekStartDay = _this$props.weekStartDay,
89
+ holidays = _this$props.holidays;
88
90
  var userSeeDate = new Date(year, month, 1);
89
- var userSeeDay = userSeeDate.getDay() + 1;
91
+ var userSeeDay = (userSeeDate.getDay() - weekStartDay + dayNames.length) % dayNames.length + 1;
90
92
  var userSeeYear = userSeeDate.getFullYear();
91
93
  var userSeeMonth = userSeeDate.getMonth();
92
94
  var monthEnd = (0, _common.getMonthEnd)(month, year);
@@ -114,10 +116,10 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
114
116
  var output = null;
115
117
 
116
118
  for (var i = 1; i <= 7; i++) {
117
- var tdclass = "".concat(_DateTimeModule["default"].datesStr, " ").concat(_DateTimeModule["default"].grid);
119
+ var tdclass = "".concat(_DateTimeModule["default"].datesStr, " ").concat(_DateTimeModule["default"].grid); // if (i === 1) {
118
120
 
119
- if (i === 1) {
120
- tdclass += " ".concat(_DateTimeModule["default"].sunday);
121
+ if (holidays.includes(i - 1)) {
122
+ tdclass += " ".concat(_DateTimeModule["default"].holiday);
121
123
  }
122
124
 
123
125
  if (incremleti >= userSeeDay && incremday <= monthEnd) {
@@ -226,7 +228,8 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
226
228
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_DaysRow["default"], {
227
229
  dayNames: dayNames,
228
230
  dayNamesShort: dayNamesShort,
229
- ariaLabel: dayNamesShort
231
+ ariaLabel: dayNamesShort,
232
+ holidays: holidays
230
233
  }), /*#__PURE__*/_react["default"].createElement("div", {
231
234
  "data-id": "".concat(dataId, "_dateContainer"),
232
235
  "data-test-id": "".concat(dataId, "_dateContainer"),
@@ -43,6 +43,14 @@ var _dateFormat = require("./../../DateTime/dateFormatUtils/dateFormat");
43
43
 
44
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
45
45
 
46
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
47
+
48
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
+
50
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
51
+
52
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
53
+
46
54
  function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
47
55
 
48
56
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -728,7 +736,9 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
728
736
  startDate = _this$props7.startDate,
729
737
  endDate = _this$props7.endDate,
730
738
  _this$props7$customPr = _this$props7.customProps,
731
- customProps = _this$props7$customPr === void 0 ? {} : _this$props7$customPr;
739
+ customProps = _this$props7$customPr === void 0 ? {} : _this$props7$customPr,
740
+ holidays = _this$props7.holidays,
741
+ weekStartDay = _this$props7.weekStartDay;
732
742
  var _customProps$TimeProp = customProps.TimeProps,
733
743
  TimeProps = _customProps$TimeProp === void 0 ? {} : _customProps$TimeProp;
734
744
  var _i18nKeys$timeText = i18nKeys.timeText,
@@ -754,6 +764,17 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
754
764
  _i18nKeys$dayNamesSho = i18nKeys.dayNamesShort,
755
765
  dayNamesShort = _i18nKeys$dayNamesSho === void 0 ? _constants.dayNamesShortDefault : _i18nKeys$dayNamesSho;
756
766
  var showmonthtxt = title(date, year, month, monthNames);
767
+ var customDayNames = dayNames,
768
+ customDayNamesShort = dayNamesShort,
769
+ customizedHolidays = holidays;
770
+
771
+ if (weekStartDay !== 0) {
772
+ customDayNames = [].concat(_toConsumableArray(dayNames.slice(weekStartDay)), _toConsumableArray(dayNames.slice(0, weekStartDay)));
773
+ customDayNamesShort = [].concat(_toConsumableArray(dayNamesShort.slice(weekStartDay)), _toConsumableArray(dayNamesShort.slice(0, weekStartDay)));
774
+ customizedHolidays = holidays.map(function (dayIndex) {
775
+ return customDayNames.indexOf(dayNames[dayIndex]);
776
+ });
777
+ }
757
778
 
758
779
  var childEle = /*#__PURE__*/_react["default"].createElement("div", {
759
780
  className: "".concat(_DateTimeModule["default"].container, " ").concat(innerClass),
@@ -776,13 +797,15 @@ var DateTime = /*#__PURE__*/function (_React$PureComponent) {
776
797
  year: year,
777
798
  month: month,
778
799
  onSelect: this.dateSelect,
779
- dayNames: dayNames,
780
- dayNamesShort: dayNamesShort,
800
+ dayNames: customDayNames,
801
+ dayNamesShort: customDayNamesShort,
781
802
  todayDate: todayDate,
782
803
  todayMonth: todayMonth,
783
804
  todayYear: todayYear,
784
805
  startDate: startDate,
785
- endDate: endDate
806
+ endDate: endDate,
807
+ weekStartDay: weekStartDay,
808
+ holidays: customizedHolidays
786
809
  }), isDateTimeField ? /*#__PURE__*/_react["default"].createElement(_Time["default"], {
787
810
  timeText: timeText,
788
811
  dataId: dataId,
@@ -1032,6 +1032,8 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
1032
1032
  onError = _this$props12.onError,
1033
1033
  startDate = _this$props12.startDate,
1034
1034
  endDate = _this$props12.endDate,
1035
+ weekStartDay = _this$props12.weekStartDay,
1036
+ holidays = _this$props12.holidays,
1035
1037
  _this$props12$customP = _this$props12.customProps,
1036
1038
  customProps = _this$props12$customP === void 0 ? {} : _this$props12$customP;
1037
1039
  var _customProps$DateTime = customProps.DateTimeProps,
@@ -1131,7 +1133,9 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
1131
1133
  onError: onError,
1132
1134
  startDate: startDate,
1133
1135
  endDate: endDate,
1134
- customProps: DateTimeProps
1136
+ customProps: DateTimeProps,
1137
+ weekStartDay: weekStartDay,
1138
+ holidays: holidays
1135
1139
  }));
1136
1140
  }
1137
1141
  }]);
@@ -57,7 +57,8 @@ var DaysRow = /*#__PURE__*/function (_PureComponent) {
57
57
  value: function render() {
58
58
  var _this$props = this.props,
59
59
  dayNames = _this$props.dayNames,
60
- dayNamesShort = _this$props.dayNamesShort;
60
+ dayNamesShort = _this$props.dayNamesShort,
61
+ holidays = _this$props.holidays;
61
62
  return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
62
63
  alignBox: "row",
63
64
  align: "center",
@@ -65,7 +66,7 @@ var DaysRow = /*#__PURE__*/function (_PureComponent) {
65
66
  }, dayNames.map(function (dayName, index) {
66
67
  return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
67
68
  key: dayName,
68
- className: "".concat(_DateTimeModule["default"].daysStr, " ").concat(_DateTimeModule["default"].grid, " ").concat(index === 0 ? _DateTimeModule["default"].sunday : ''),
69
+ className: "".concat(_DateTimeModule["default"].daysStr, " ").concat(_DateTimeModule["default"].grid, " ").concat(holidays.includes(index) ? _DateTimeModule["default"].holiday : ''),
69
70
  "data-title": dayName,
70
71
  "aria-label": dayName
71
72
  }, dayNamesShort[index]);
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.YearView_defaultProps = exports.Time_defaultProps = exports.Span_defaultProps = exports.DateWidget_defaultProps = exports.DateTime_defaultProps = exports.DateTimePopupFooter_defaultProps = exports.CalendarView_defaultProps = void 0;
7
7
  var CalendarView_defaultProps = {
8
8
  dataId: 'dateContainer',
9
- needBorder: true
9
+ needBorder: true,
10
+ weekStartDay: 0,
11
+ holidays: [0]
10
12
  };
11
13
  exports.CalendarView_defaultProps = CalendarView_defaultProps;
12
14
  var Span_defaultProps = {
@@ -28,7 +30,9 @@ var DateTime_defaultProps = {
28
30
  i18nKeys: {},
29
31
  is24Hour: false,
30
32
  isDefaultPosition: false,
31
- customDateFormat: null
33
+ customDateFormat: null,
34
+ weekStartDay: 0,
35
+ holidays: [0]
32
36
  };
33
37
  exports.DateTime_defaultProps = DateTime_defaultProps;
34
38
  var DateWidget_defaultProps = {
@@ -52,7 +56,9 @@ var DateWidget_defaultProps = {
52
56
  needErrorOnBlur: false,
53
57
  isEditable: false,
54
58
  iconOnHover: false,
55
- is24Hour: false
59
+ is24Hour: false,
60
+ weekStartDay: 0,
61
+ holidays: [0]
56
62
  };
57
63
  exports.DateWidget_defaultProps = DateWidget_defaultProps;
58
64
  var YearView_defaultProps = {
@@ -36,7 +36,9 @@ var CalendarView_propTypes = {
36
36
  todayDate: _propTypes["default"].string,
37
37
  todayYear: _propTypes["default"].string,
38
38
  startDate: _propTypes["default"].string,
39
- endDate: _propTypes["default"].string
39
+ endDate: _propTypes["default"].string,
40
+ weekStartDay: _propTypes["default"].oneOf([0, 1, 2, 3, 4, 5, 6]),
41
+ holidays: _propTypes["default"].arrayOf(_propTypes["default"].number)
40
42
  };
41
43
  exports.CalendarView_propTypes = CalendarView_propTypes;
42
44
  var Span_propTypes = {
@@ -104,7 +106,9 @@ var DateTime_propTypes = {
104
106
  dropBoxPortalId: _propTypes["default"].string,
105
107
  startDate: _propTypes["default"].string,
106
108
  endDate: _propTypes["default"].string,
107
- customProps: _propTypes["default"].object
109
+ customProps: _propTypes["default"].object,
110
+ weekStartDay: _propTypes["default"].oneOf([0, 1, 2, 3, 4, 5, 6]),
111
+ holidays: _propTypes["default"].arrayOf(_propTypes["default"].number)
108
112
  };
109
113
  exports.DateTime_propTypes = DateTime_propTypes;
110
114
  var DateWidget_propTypes = {
@@ -176,7 +180,9 @@ var DateWidget_propTypes = {
176
180
  startDate: _propTypes["default"].string,
177
181
  endDate: _propTypes["default"].string,
178
182
  getPopupProps: _propTypes["default"].func,
179
- customProps: _propTypes["default"].object
183
+ customProps: _propTypes["default"].object,
184
+ weekStartDay: _propTypes["default"].oneOf([0, 1, 2, 3, 4, 5, 6]),
185
+ holidays: _propTypes["default"].arrayOf(_propTypes["default"].number)
180
186
  };
181
187
  exports.DateWidget_propTypes = DateWidget_propTypes;
182
188
  var YearView_propTypes = {
@@ -207,7 +213,8 @@ var DateTimePopupHeader_propTypes = {
207
213
  exports.DateTimePopupHeader_propTypes = DateTimePopupHeader_propTypes;
208
214
  var DaysRow_propTypes = {
209
215
  dayNames: _propTypes["default"].array,
210
- dayNamesShort: _propTypes["default"].object
216
+ dayNamesShort: _propTypes["default"].object,
217
+ holidays: _propTypes["default"].arrayOf(_propTypes["default"].number)
211
218
  };
212
219
  exports.DaysRow_propTypes = DaysRow_propTypes;
213
220
  var Time_propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.2.48",
3
+ "version": "1.2.50",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -42,7 +42,7 @@
42
42
  "postpublish": "node postPublish.js",
43
43
  "report": "react-cli publish:report",
44
44
  "test": "react-cli test",
45
- "test-clean": "react-cli clean coverage",
45
+ "test-clean": "react-cli clean ./coverage",
46
46
  "snap-update": "npm run test-clean && npm run test -- -u",
47
47
  "sstest": "npm run init && react-cli sstest",
48
48
  "build:external": "npm run clean && npm run init && npm run docsjs:build && npm run build:externalDocCopy && react-cli build:component:umd && npm run externalDocHTMLChange",
@@ -71,7 +71,7 @@
71
71
  "@zohodesk/a11y": "2.2.6",
72
72
  "@zohodesk/docstool": "1.0.0-alpha-2",
73
73
  "@zohodesk/hooks": "2.0.5",
74
- "@zohodesk/icons": "1.0.63",
74
+ "@zohodesk/icons": "1.0.66",
75
75
  "@zohodesk/svg": "1.1.22",
76
76
  "@zohodesk/utils": "1.3.14",
77
77
  "@zohodesk/variables": "1.0.0",
@@ -86,7 +86,7 @@
86
86
  "selectn": "1.1.2"
87
87
  },
88
88
  "peerDependencies": {
89
- "@zohodesk/icons": "1.0.63",
89
+ "@zohodesk/icons": "1.0.66",
90
90
  "@zohodesk/variables": "1.0.0",
91
91
  "@zohodesk/svg": "1.1.22",
92
92
  "@zohodesk/virtualizer": "1.0.3",