@zohodesk/components 1.4.19 → 1.4.20

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
@@ -2,6 +2,11 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.4.20
6
+
7
+ - **Popup**
8
+ - Exposed the `recomputePosition` method to handle repositioning and dropdown alignment after chunk download.
9
+
5
10
  # 1.4.19
6
11
 
7
12
  - Added rtl:as:property comment for linear-gradient usages to ensure support in PostCSS
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.setPosition = this.setPosition.bind(this);
162
163
  this.positionRef = /*#__PURE__*/React.createRef();
163
164
  this.rootElement = Registry.getRootElement();
164
165
  this.popupObserver = new ResizeObserver(this.handlePopupResize);
@@ -391,31 +392,34 @@ const Popup = function (Component) {
391
392
  const {
392
393
  isMobile
393
394
  } = 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
395
 
410
- if (this.positionRef.current !== view) {
411
- dropElement.setAttribute('data-position', `${view}`);
412
- dropElement.setAttribute('data-box-direction', selectn(`${view}.direction`, positionMapping));
396
+ if (dropElement) {
397
+ const {
398
+ view,
399
+ viewsOffset
400
+ } = betterPosition || DUMMY_OBJECT;
401
+ const styleToApply = selectn(`${view}`, viewsOffset);
402
+
403
+ if (isMobile) {
404
+ this.handleDropElementStyleUpdate({
405
+ top: '',
406
+ left: '',
407
+ right: '',
408
+ bottom: ''
409
+ });
410
+ } else {
411
+ this.handleDropElementStyleUpdate(styleToApply);
413
412
 
414
- if (needArrow) {
415
- dropElement.setAttribute('data-arrow-position', selectn(`${view}.arrowPosition`, positionMapping));
416
- }
413
+ if (this.positionRef.current !== view) {
414
+ dropElement.setAttribute('data-position', `${view}`);
415
+ dropElement.setAttribute('data-box-direction', selectn(`${view}.direction`, positionMapping));
417
416
 
418
- this.positionRef.current = view;
417
+ if (needArrow) {
418
+ dropElement.setAttribute('data-arrow-position', selectn(`${view}.arrowPosition`, positionMapping));
419
+ }
420
+
421
+ this.positionRef.current = view;
422
+ }
419
423
  }
420
424
  }
421
425
  }
@@ -804,6 +808,51 @@ const Popup = function (Component) {
804
808
  });
805
809
  }
806
810
 
811
+ setPosition() {
812
+ this.cancelRaf('setPositionRafId');
813
+ const needArrow = this.getNeedArrow(this);
814
+ const isAbsolute = this.getIsAbsolutePopup(this);
815
+ const customOrder = this.getCustomPositionOrder(this);
816
+ this.setPositionRafId = requestAnimationFrame(() => {
817
+ const {
818
+ placeHolderElement,
819
+ dropElement,
820
+ defaultPosition
821
+ } = this;
822
+ const {
823
+ position,
824
+ isPopupReady
825
+ } = this.state;
826
+ const scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
827
+ const betterPosition = viewPort.betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
828
+ needArrow,
829
+ isAbsolute,
830
+ customOrder
831
+ });
832
+ const {
833
+ view,
834
+ views,
835
+ viewsOffset,
836
+ targetOffset,
837
+ popupOffset
838
+ } = betterPosition || DUMMY_OBJECT;
839
+
840
+ if (!isAbsolute) {
841
+ if (!isPopupReady) {
842
+ this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
843
+ }
844
+
845
+ this.setContainerDynamicPositioning(betterPosition, needArrow);
846
+ } else {
847
+ if (position !== view || !isPopupReady) {
848
+ this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
849
+ }
850
+ }
851
+
852
+ this.setPositionRafId = null;
853
+ });
854
+ }
855
+
807
856
  handlePopupPosition() {
808
857
  let defaultPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottomCenter';
809
858
  let isUpdatePosition = arguments.length > 1 ? arguments[1] : undefined;
@@ -815,9 +864,7 @@ const Popup = function (Component) {
815
864
  placeHolderElement,
816
865
  dropElement
817
866
  } = this;
818
- const needArrow = this.getNeedArrow(this);
819
867
  const isAbsolute = this.getIsAbsolutePopup(this);
820
- const customOrder = this.getCustomPositionOrder(this);
821
868
 
822
869
  if (direction === 'rtl') {
823
870
  defaultPosition = isAbsolute ? rtlAbsolutePositionMapping[defaultPosition] : rtlFixedPositionMapping[defaultPosition];
@@ -825,6 +872,8 @@ const Popup = function (Component) {
825
872
  defaultPosition = isAbsolute ? absolutePositionMapping[defaultPosition] : defaultPosition;
826
873
  }
827
874
 
875
+ this.defaultPosition = defaultPosition;
876
+
828
877
  if (!placeHolderElement && !dropElement) {
829
878
  const isMobile = isMobilePopover(true);
830
879
  this.setState({
@@ -835,59 +884,13 @@ const Popup = function (Component) {
835
884
  return;
836
885
  }
837
886
 
838
- const setPosition = () => {
839
- this.cancelRaf('setPositionRafId');
840
- this.setPositionRafId = requestAnimationFrame(() => {
841
- const {
842
- placeHolderElement,
843
- dropElement
844
- } = this;
845
- const {
846
- position,
847
- isPopupReady
848
- } = this.state;
849
- const scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
850
- const betterPosition = viewPort.betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
851
- needArrow,
852
- isAbsolute,
853
- customOrder
854
- });
855
- const {
856
- view,
857
- views,
858
- viewsOffset,
859
- targetOffset,
860
- popupOffset
861
- } = betterPosition || DUMMY_OBJECT;
862
-
863
- if (!isAbsolute) {
864
- if (!isPopupReady) {
865
- this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
866
- }
867
-
868
- if (!dropElement) {
869
- return;
870
- }
871
-
872
- this.setContainerDynamicPositioning(betterPosition, needArrow);
873
- } else {
874
- if (position !== view || !isPopupReady) {
875
- this.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
876
- }
877
- }
878
-
879
- this.setPositionRafId = null;
880
- });
881
- };
882
-
883
887
  if (isUpdatePosition) {
884
- setPosition();
888
+ this.setPosition();
885
889
  } else {
886
- this.defaultPosition = defaultPosition;
887
890
  this.setState({
888
891
  isPopupOpen: true,
889
892
  isPopupReady: false
890
- }, setPosition);
893
+ }, this.setPosition);
891
894
  }
892
895
  }
893
896
 
@@ -1032,6 +1035,7 @@ const Popup = function (Component) {
1032
1035
  openPopupOnly: this.openPopupOnly,
1033
1036
  closePopupOnly: this.closePopupOnly,
1034
1037
  togglePopup: this.togglePopup,
1038
+ recomputePosition: this.setPosition,
1035
1039
  removeClose: this.removeClose,
1036
1040
  getTargetRef: this.getTargetRef,
1037
1041
  getContainerRef: this.getContainerRef
@@ -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.setPosition = _this.setPosition.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);
@@ -488,31 +489,33 @@ var Popup = function Popup(Component) {
488
489
  var dropElement = this.dropElement;
489
490
  var isMobile = this.state.isMobile;
490
491
 
491
- var _ref4 = betterPosition || _Common.DUMMY_OBJECT,
492
- view = _ref4.view,
493
- viewsOffset = _ref4.viewsOffset;
492
+ if (dropElement) {
493
+ var _ref4 = betterPosition || _Common.DUMMY_OBJECT,
494
+ view = _ref4.view,
495
+ viewsOffset = _ref4.viewsOffset;
494
496
 
495
- var styleToApply = (0, _selectn["default"])("".concat(view), viewsOffset);
497
+ var styleToApply = (0, _selectn["default"])("".concat(view), viewsOffset);
496
498
 
497
- if (isMobile) {
498
- this.handleDropElementStyleUpdate({
499
- top: '',
500
- left: '',
501
- right: '',
502
- bottom: ''
503
- });
504
- } else {
505
- this.handleDropElementStyleUpdate(styleToApply);
499
+ if (isMobile) {
500
+ this.handleDropElementStyleUpdate({
501
+ top: '',
502
+ left: '',
503
+ right: '',
504
+ bottom: ''
505
+ });
506
+ } else {
507
+ this.handleDropElementStyleUpdate(styleToApply);
506
508
 
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));
509
+ if (this.positionRef.current !== view) {
510
+ dropElement.setAttribute('data-position', "".concat(view));
511
+ dropElement.setAttribute('data-box-direction', (0, _selectn["default"])("".concat(view, ".direction"), _DropBoxPositionMapping.positionMapping));
510
512
 
511
- if (needArrow) {
512
- dropElement.setAttribute('data-arrow-position', (0, _selectn["default"])("".concat(view, ".arrowPosition"), _DropBoxPositionMapping.positionMapping));
513
- }
513
+ if (needArrow) {
514
+ dropElement.setAttribute('data-arrow-position', (0, _selectn["default"])("".concat(view, ".arrowPosition"), _DropBoxPositionMapping.positionMapping));
515
+ }
514
516
 
515
- this.positionRef.current = view;
517
+ this.positionRef.current = view;
518
+ }
516
519
  }
517
520
  }
518
521
  }
@@ -899,22 +902,64 @@ var Popup = function Popup(Component) {
899
902
  });
900
903
  }
901
904
  }, {
902
- key: "handlePopupPosition",
903
- value: function handlePopupPosition() {
905
+ key: "setPosition",
906
+ value: function setPosition() {
904
907
  var _this6 = this;
905
908
 
909
+ this.cancelRaf('setPositionRafId');
910
+ var needArrow = this.getNeedArrow(this);
911
+ var isAbsolute = this.getIsAbsolutePopup(this);
912
+ var customOrder = this.getCustomPositionOrder(this);
913
+ this.setPositionRafId = requestAnimationFrame(function () {
914
+ var placeHolderElement = _this6.placeHolderElement,
915
+ dropElement = _this6.dropElement,
916
+ defaultPosition = _this6.defaultPosition;
917
+ var _this6$state = _this6.state,
918
+ position = _this6$state.position,
919
+ isPopupReady = _this6$state.isPopupReady;
920
+ var scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
921
+
922
+ var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
923
+ needArrow: needArrow,
924
+ isAbsolute: isAbsolute,
925
+ customOrder: customOrder
926
+ });
927
+
928
+ var _ref10 = betterPosition || _Common.DUMMY_OBJECT,
929
+ view = _ref10.view,
930
+ views = _ref10.views,
931
+ viewsOffset = _ref10.viewsOffset,
932
+ targetOffset = _ref10.targetOffset,
933
+ popupOffset = _ref10.popupOffset;
934
+
935
+ if (!isAbsolute) {
936
+ if (!isPopupReady) {
937
+ _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
938
+ }
939
+
940
+ _this6.setContainerDynamicPositioning(betterPosition, needArrow);
941
+ } else {
942
+ if (position !== view || !isPopupReady) {
943
+ _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
944
+ }
945
+ }
946
+
947
+ _this6.setPositionRafId = null;
948
+ });
949
+ }
950
+ }, {
951
+ key: "handlePopupPosition",
952
+ value: function handlePopupPosition() {
906
953
  var defaultPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottomCenter';
907
954
  var isUpdatePosition = arguments.length > 1 ? arguments[1] : undefined;
908
955
 
909
956
  // isUpdatePosition --->>> Window resize and dropBox resize and to update the position
910
- var _ref10 = this.context || {},
911
- direction = _ref10.direction;
957
+ var _ref11 = this.context || {},
958
+ direction = _ref11.direction;
912
959
 
913
960
  var placeHolderElement = this.placeHolderElement,
914
961
  dropElement = this.dropElement;
915
- var needArrow = this.getNeedArrow(this);
916
962
  var isAbsolute = this.getIsAbsolutePopup(this);
917
- var customOrder = this.getCustomPositionOrder(this);
918
963
 
919
964
  if (direction === 'rtl') {
920
965
  defaultPosition = isAbsolute ? _PositionMapping.rtlAbsolutePositionMapping[defaultPosition] : _PositionMapping.rtlFixedPositionMapping[defaultPosition];
@@ -922,6 +967,8 @@ var Popup = function Popup(Component) {
922
967
  defaultPosition = isAbsolute ? _PositionMapping.absolutePositionMapping[defaultPosition] : defaultPosition;
923
968
  }
924
969
 
970
+ this.defaultPosition = defaultPosition;
971
+
925
972
  if (!placeHolderElement && !dropElement) {
926
973
  var isMobile = (0, _isMobilePopover["default"])(true);
927
974
  this.setState({
@@ -932,58 +979,13 @@ var Popup = function Popup(Component) {
932
979
  return;
933
980
  }
934
981
 
935
- 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;
944
- var scrollContainer = placeHolderElement ? placeHolderElement.closest('[data-scroll=true]') || document.body : document.body;
945
-
946
- var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
947
- needArrow: needArrow,
948
- isAbsolute: isAbsolute,
949
- customOrder: customOrder
950
- });
951
-
952
- var _ref11 = betterPosition || _Common.DUMMY_OBJECT,
953
- view = _ref11.view,
954
- views = _ref11.views,
955
- viewsOffset = _ref11.viewsOffset,
956
- targetOffset = _ref11.targetOffset,
957
- popupOffset = _ref11.popupOffset;
958
-
959
- if (!isAbsolute) {
960
- if (!isPopupReady) {
961
- _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
962
- }
963
-
964
- if (!dropElement) {
965
- return;
966
- }
967
-
968
- _this6.setContainerDynamicPositioning(betterPosition, needArrow);
969
- } else {
970
- if (position !== view || !isPopupReady) {
971
- _this6.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
972
- }
973
- }
974
-
975
- _this6.setPositionRafId = null;
976
- });
977
- };
978
-
979
982
  if (isUpdatePosition) {
980
- setPosition();
983
+ this.setPosition();
981
984
  } else {
982
- this.defaultPosition = defaultPosition;
983
985
  this.setState({
984
986
  isPopupOpen: true,
985
987
  isPopupReady: false
986
- }, setPosition);
988
+ }, this.setPosition);
987
989
  }
988
990
  }
989
991
  }, {
@@ -1149,6 +1151,7 @@ var Popup = function Popup(Component) {
1149
1151
  openPopupOnly: this.openPopupOnly,
1150
1152
  closePopupOnly: this.closePopupOnly,
1151
1153
  togglePopup: this.togglePopup,
1154
+ recomputePosition: this.setPosition,
1152
1155
  removeClose: this.removeClose,
1153
1156
  getTargetRef: this.getTargetRef,
1154
1157
  getContainerRef: this.getContainerRef
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.4.19",
3
+ "version": "1.4.20",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -81,8 +81,8 @@
81
81
  "@zohodesk/a11y": "2.3.8",
82
82
  "@zohodesk/docstool": "1.0.0-alpha-2",
83
83
  "@zohodesk/dotkit": "1.0.3",
84
- "@zohodesk/hooks": "2.0.5",
85
- "@zohodesk/icons": "1.1.0",
84
+ "@zohodesk/hooks": "2.0.6",
85
+ "@zohodesk/icons": "1.1.1",
86
86
  "@zohodesk/layout": "3.1.0",
87
87
  "@zohodesk/svg": "1.2.2",
88
88
  "@zohodesk/utils": "1.3.15",
@@ -99,13 +99,13 @@
99
99
  "selectn": "1.1.2"
100
100
  },
101
101
  "peerDependencies": {
102
- "@zohodesk/icons": "1.1.0",
102
+ "@zohodesk/icons": "1.1.1",
103
103
  "@zohodesk/variables": "1.1.0",
104
104
  "@zohodesk/svg": "1.2.2",
105
105
  "@zohodesk/virtualizer": "1.0.13",
106
106
  "velocity-react": "1.4.3",
107
107
  "react-sortable-hoc": "^0.8.3",
108
- "@zohodesk/hooks": "2.0.5",
108
+ "@zohodesk/hooks": "2.0.6",
109
109
  "@zohodesk/utils": "1.3.15",
110
110
  "@zohodesk/a11y": "2.3.8",
111
111
  "@zohodesk/layout": "3.1.0",