@zohodesk/components 1.0.0-temp-238 → 1.0.0-temp-239

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 CHANGED
@@ -21,7 +21,7 @@ Dot UI is a customizable React component library built to deliver a clean, acces
21
21
  # 1.4.12
22
22
 
23
23
  - `TextBox`
24
- - The event is passed as the 4th argument to both handleBlur and handleFocus
24
+ - The event is passed as the 4th argument to both onBlur and onFocus
25
25
  - `Common Css`
26
26
  - added ltr class for change direction to ltr in rtl mode.
27
27
 
package/es/Popup/Popup.js CHANGED
@@ -159,6 +159,7 @@ const Popup = function (Component) {
159
159
  this.handleScrollAndBlockEvents = this.handleScrollAndBlockEvents.bind(this);
160
160
  this.handleIframeEventListeners = this.handleIframeEventListeners.bind(this);
161
161
  this.handleDropElementStyleUpdate = this.handleDropElementStyleUpdate.bind(this);
162
+ this.waitForDropElement = this.waitForDropElement.bind(this);
162
163
  this.positionRef = /*#__PURE__*/React.createRef();
163
164
  this.rootElement = Registry.getRootElement();
164
165
  this.popupObserver = new ResizeObserver(this.handlePopupResize);
@@ -384,6 +385,25 @@ const Popup = function (Component) {
384
385
  });
385
386
  }
386
387
 
388
+ waitForDropElement(callback) {
389
+ let maxRetries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
390
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
391
+
392
+ if (this.dropElement) {
393
+ callback();
394
+ return;
395
+ }
396
+
397
+ if (maxRetries <= 0) {
398
+ console.warn('Popup: dropElement not available after maximum retries');
399
+ return;
400
+ }
401
+
402
+ setTimeout(() => {
403
+ this.waitForDropElement(callback, maxRetries - 1, Math.min(delay * 1.5, 1000));
404
+ }, delay);
405
+ }
406
+
387
407
  setContainerDynamicPositioning(betterPosition, needArrow) {
388
408
  const {
389
409
  dropElement
@@ -391,32 +411,39 @@ const Popup = function (Component) {
391
411
  const {
392
412
  isMobile
393
413
  } = this.state;
394
- const {
395
- view,
396
- viewsOffset
397
- } = betterPosition || DUMMY_OBJECT;
398
- const styleToApply = selectn(`${view}`, viewsOffset);
399
-
400
- if (isMobile) {
401
- this.handleDropElementStyleUpdate({
402
- top: '',
403
- left: '',
404
- right: '',
405
- bottom: ''
406
- });
407
- } else {
408
- this.handleDropElementStyleUpdate(styleToApply);
409
414
 
410
- if (this.positionRef.current !== view) {
411
- dropElement.setAttribute('data-position', `${view}`);
412
- dropElement.setAttribute('data-box-direction', selectn(`${view}.direction`, positionMapping));
415
+ if (!dropElement) {
416
+ // Wait for dropElement to be available (in case it's being loaded from a chunk)
417
+ this.waitForDropElement(() => {
418
+ const {
419
+ view,
420
+ viewsOffset
421
+ } = betterPosition || DUMMY_OBJECT;
422
+ const styleToApply = selectn(`${view}`, viewsOffset);
423
+
424
+ if (isMobile) {
425
+ this.handleDropElementStyleUpdate({
426
+ top: '',
427
+ left: '',
428
+ right: '',
429
+ bottom: ''
430
+ });
431
+ } else {
432
+ this.handleDropElementStyleUpdate(styleToApply);
433
+
434
+ if (this.positionRef.current !== view) {
435
+ dropElement.setAttribute('data-position', `${view}`);
436
+ dropElement.setAttribute('data-box-direction', selectn(`${view}.direction`, positionMapping));
413
437
 
414
- if (needArrow) {
415
- dropElement.setAttribute('data-arrow-position', selectn(`${view}.arrowPosition`, positionMapping));
416
- }
438
+ if (needArrow) {
439
+ dropElement.setAttribute('data-arrow-position', selectn(`${view}.arrowPosition`, positionMapping));
440
+ }
417
441
 
418
- this.positionRef.current = view;
419
- }
442
+ this.positionRef.current = view;
443
+ }
444
+ }
445
+ });
446
+ return;
420
447
  }
421
448
  }
422
449
 
@@ -865,10 +892,6 @@ const Popup = function (Component) {
865
892
  this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
866
893
  }
867
894
 
868
- if (!dropElement) {
869
- return;
870
- }
871
-
872
895
  this.setContainerDynamicPositioning(betterPosition, needArrow);
873
896
  } else {
874
897
  if (position !== view || !isPopupReady) {
@@ -234,6 +234,7 @@ var Popup = function Popup(Component) {
234
234
  _this.handleScrollAndBlockEvents = _this.handleScrollAndBlockEvents.bind(_assertThisInitialized(_this));
235
235
  _this.handleIframeEventListeners = _this.handleIframeEventListeners.bind(_assertThisInitialized(_this));
236
236
  _this.handleDropElementStyleUpdate = _this.handleDropElementStyleUpdate.bind(_assertThisInitialized(_this));
237
+ _this.waitForDropElement = _this.waitForDropElement.bind(_assertThisInitialized(_this));
237
238
  _this.positionRef = /*#__PURE__*/_react["default"].createRef();
238
239
  _this.rootElement = _Registry["default"].getRootElement();
239
240
  _this.popupObserver = new _ResizeObserver["default"](_this.handlePopupResize);
@@ -482,38 +483,68 @@ var Popup = function Popup(Component) {
482
483
  bottom: bottom ? "".concat(bottom, "px") : ''
483
484
  });
484
485
  }
486
+ }, {
487
+ key: "waitForDropElement",
488
+ value: function waitForDropElement(callback) {
489
+ var _this4 = this;
490
+
491
+ var maxRetries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
492
+ var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
493
+
494
+ if (this.dropElement) {
495
+ callback();
496
+ return;
497
+ }
498
+
499
+ if (maxRetries <= 0) {
500
+ console.warn('Popup: dropElement not available after maximum retries');
501
+ return;
502
+ }
503
+
504
+ setTimeout(function () {
505
+ _this4.waitForDropElement(callback, maxRetries - 1, Math.min(delay * 1.5, 1000));
506
+ }, delay);
507
+ }
485
508
  }, {
486
509
  key: "setContainerDynamicPositioning",
487
510
  value: function setContainerDynamicPositioning(betterPosition, needArrow) {
511
+ var _this5 = this;
512
+
488
513
  var dropElement = this.dropElement;
489
514
  var isMobile = this.state.isMobile;
490
515
 
491
- var _ref4 = betterPosition || _Common.DUMMY_OBJECT,
492
- view = _ref4.view,
493
- viewsOffset = _ref4.viewsOffset;
516
+ if (!dropElement) {
517
+ // Wait for dropElement to be available (in case it's being loaded from a chunk)
518
+ this.waitForDropElement(function () {
519
+ var _ref4 = betterPosition || _Common.DUMMY_OBJECT,
520
+ view = _ref4.view,
521
+ viewsOffset = _ref4.viewsOffset;
522
+
523
+ var styleToApply = (0, _selectn["default"])("".concat(view), viewsOffset);
524
+
525
+ if (isMobile) {
526
+ _this5.handleDropElementStyleUpdate({
527
+ top: '',
528
+ left: '',
529
+ right: '',
530
+ bottom: ''
531
+ });
532
+ } else {
533
+ _this5.handleDropElementStyleUpdate(styleToApply);
494
534
 
495
- var styleToApply = (0, _selectn["default"])("".concat(view), viewsOffset);
535
+ if (_this5.positionRef.current !== view) {
536
+ dropElement.setAttribute('data-position', "".concat(view));
537
+ dropElement.setAttribute('data-box-direction', (0, _selectn["default"])("".concat(view, ".direction"), _DropBoxPositionMapping.positionMapping));
496
538
 
497
- if (isMobile) {
498
- this.handleDropElementStyleUpdate({
499
- top: '',
500
- left: '',
501
- right: '',
502
- bottom: ''
503
- });
504
- } else {
505
- this.handleDropElementStyleUpdate(styleToApply);
506
-
507
- if (this.positionRef.current !== view) {
508
- dropElement.setAttribute('data-position', "".concat(view));
509
- dropElement.setAttribute('data-box-direction', (0, _selectn["default"])("".concat(view, ".direction"), _DropBoxPositionMapping.positionMapping));
539
+ if (needArrow) {
540
+ dropElement.setAttribute('data-arrow-position', (0, _selectn["default"])("".concat(view, ".arrowPosition"), _DropBoxPositionMapping.positionMapping));
541
+ }
510
542
 
511
- if (needArrow) {
512
- dropElement.setAttribute('data-arrow-position', (0, _selectn["default"])("".concat(view, ".arrowPosition"), _DropBoxPositionMapping.positionMapping));
543
+ _this5.positionRef.current = view;
544
+ }
513
545
  }
514
-
515
- this.positionRef.current = view;
516
- }
546
+ });
547
+ return;
517
548
  }
518
549
  }
519
550
  }, {
@@ -536,7 +567,7 @@ var Popup = function Popup(Component) {
536
567
  }, {
537
568
  key: "updateListeners",
538
569
  value: function updateListeners() {
539
- var _this4 = this;
570
+ var _this6 = this;
540
571
 
541
572
  var add = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
542
573
  var eventList = arguments.length > 1 ? arguments[1] : undefined;
@@ -546,7 +577,7 @@ var Popup = function Popup(Component) {
546
577
  var name = _ref6.name,
547
578
  handlerName = _ref6.handlerName,
548
579
  options = _ref6.options;
549
- var handler = _this4[handlerName];
580
+ var handler = _this6[handlerName];
550
581
 
551
582
  if (handler) {
552
583
  element[method](name, handler, options);
@@ -719,7 +750,7 @@ var Popup = function Popup(Component) {
719
750
  }, {
720
751
  key: "togglePopup",
721
752
  value: function togglePopup(e, defaultPosition) {
722
- var _this5 = this;
753
+ var _this7 = this;
723
754
 
724
755
  var group = this.getGroup();
725
756
  this.removeClose(e);
@@ -728,7 +759,7 @@ var Popup = function Popup(Component) {
728
759
  _Registry["default"].lastOpenedGroup = !isPopupOpen && _Registry["default"].lastOpenedGroup.indexOf(group) === -1 ? [group].concat(_toConsumableArray(_Registry["default"].lastOpenedGroup)) : _Registry["default"].lastOpenedGroup;
729
760
  isPopupOpen && _Registry["default"].lastOpenedGroup.splice(0, 1);
730
761
  groupPopups.forEach(function (popup) {
731
- if (popup !== _this5 && popup.state.isPopupOpen) {
762
+ if (popup !== _this7 && popup.state.isPopupOpen) {
732
763
  popup.setState({
733
764
  isPopupOpen: false,
734
765
  isPopupReady: false
@@ -901,7 +932,7 @@ var Popup = function Popup(Component) {
901
932
  }, {
902
933
  key: "handlePopupPosition",
903
934
  value: function handlePopupPosition() {
904
- var _this6 = this;
935
+ var _this8 = this;
905
936
 
906
937
  var defaultPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottomCenter';
907
938
  var isUpdatePosition = arguments.length > 1 ? arguments[1] : undefined;
@@ -933,14 +964,14 @@ var Popup = function Popup(Component) {
933
964
  }
934
965
 
935
966
  var setPosition = function setPosition() {
936
- _this6.cancelRaf('setPositionRafId');
937
-
938
- _this6.setPositionRafId = requestAnimationFrame(function () {
939
- var placeHolderElement = _this6.placeHolderElement,
940
- dropElement = _this6.dropElement;
941
- var _this6$state = _this6.state,
942
- position = _this6$state.position,
943
- isPopupReady = _this6$state.isPopupReady;
967
+ _this8.cancelRaf('setPositionRafId');
968
+
969
+ _this8.setPositionRafId = requestAnimationFrame(function () {
970
+ var placeHolderElement = _this8.placeHolderElement,
971
+ dropElement = _this8.dropElement;
972
+ var _this8$state = _this8.state,
973
+ position = _this8$state.position,
974
+ isPopupReady = _this8$state.isPopupReady;
944
975
  var scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
945
976
 
946
977
  var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
@@ -958,21 +989,17 @@ var Popup = function Popup(Component) {
958
989
 
959
990
  if (!isAbsolute) {
960
991
  if (!isPopupReady) {
961
- _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
992
+ _this8.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
962
993
  }
963
994
 
964
- if (!dropElement) {
965
- return;
966
- }
967
-
968
- _this6.setContainerDynamicPositioning(betterPosition, needArrow);
995
+ _this8.setContainerDynamicPositioning(betterPosition, needArrow);
969
996
  } else {
970
997
  if (position !== view || !isPopupReady) {
971
- _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
998
+ _this8.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
972
999
  }
973
1000
  }
974
1001
 
975
- _this6.setPositionRafId = null;
1002
+ _this8.setPositionRafId = null;
976
1003
  });
977
1004
  };
978
1005
 
@@ -989,7 +1016,7 @@ var Popup = function Popup(Component) {
989
1016
  }, {
990
1017
  key: "handleOpenPopupPositionChange",
991
1018
  value: function handleOpenPopupPositionChange() {
992
- var _this7 = this;
1019
+ var _this9 = this;
993
1020
 
994
1021
  Object.keys(_Registry["default"].popups).forEach(function (groupName) {
995
1022
  var groupPopups = _Registry["default"].popups[groupName] || [];
@@ -1006,14 +1033,14 @@ var Popup = function Popup(Component) {
1006
1033
  if (placeHolderElement && dropElement) {
1007
1034
  var scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
1008
1035
 
1009
- _this7.cancelRaf('resizePositionRafId');
1036
+ _this9.cancelRaf('resizePositionRafId');
1010
1037
 
1011
- _this7.resizePositionRafId = requestAnimationFrame(function () {
1012
- var needArrow = _this7.getNeedArrow(popup);
1038
+ _this9.resizePositionRafId = requestAnimationFrame(function () {
1039
+ var needArrow = _this9.getNeedArrow(popup);
1013
1040
 
1014
- var isAbsolute = _this7.getIsAbsolutePopup(popup);
1041
+ var isAbsolute = _this9.getIsAbsolutePopup(popup);
1015
1042
 
1016
- var customOrder = _this7.getCustomPositionOrder(popup);
1043
+ var customOrder = _this9.getCustomPositionOrder(popup);
1017
1044
 
1018
1045
  var isMobile = (0, _isMobilePopover["default"])(true);
1019
1046
 
@@ -1080,7 +1107,7 @@ var Popup = function Popup(Component) {
1080
1107
  // }
1081
1108
 
1082
1109
 
1083
- _this7.resizePositionRafId = null;
1110
+ _this9.resizePositionRafId = null;
1084
1111
  });
1085
1112
  }
1086
1113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.0.0-temp-238",
3
+ "version": "1.0.0-temp-239",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -39,7 +39,7 @@
39
39
  "build:css:umd": "npm run clean && npm run init && react-cli build:css:umd",
40
40
  "coverage": "react-cli coverage",
41
41
  "prepare": "npm run init && npm run css:build ",
42
- "prepublishOnly": "node prePublish.js && npm run download_only",
42
+ "prepublishOnly": "node prePublish.js && npm run css:review",
43
43
  "postpublish": "node postPublish.js",
44
44
  "report": "react-cli publish:report",
45
45
  "test": "react-cli test",