magneto365.ui 2.65.2 → 2.65.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.
package/dist/esm/index.js CHANGED
@@ -2683,6 +2683,8 @@ var DrawerPortal = function (_a) {
2683
2683
  var portalNode = useRef(null);
2684
2684
  var _b = useState(false), mounted = _b[0], setMounted = _b[1];
2685
2685
  useEffect(function () {
2686
+ if (!document)
2687
+ return;
2686
2688
  portalNode.current = document.createElement('div');
2687
2689
  portalNode.current.classList.add('magneto-ui-drawer');
2688
2690
  document.body.appendChild(portalNode.current);
@@ -4526,6 +4528,26 @@ var MobileSearchbar = Component$1x;
4526
4528
 
4527
4529
  var styles$1p = {"magneto-ui-modal":"mg_modal_magneto-ui-modal_1vun3","magneto-ui-modal__close-btn":"mg_modal_magneto-ui-modal_close-btn_1vun3","magneto-ui-modal__title":"mg_modal_magneto-ui-modal_title_1vun3","magneto-ui-modal__description":"mg_modal_magneto-ui-modal_description_1vun3","magneto-ui-modal__children-container":"mg_modal_magneto-ui-modal_children-container_1vun3","magneto-ui-background-modal":"mg_modal_magneto-ui-background-modal_1vun3","fadeIn":"mg_modal_fadeIn_1vun3"};
4528
4530
 
4531
+ var ModalPortal = function (_a) {
4532
+ var children = _a.children;
4533
+ var portalNode = useRef(null);
4534
+ var _b = useState(false), mounted = _b[0], setMounted = _b[1];
4535
+ useEffect(function () {
4536
+ if (!document)
4537
+ return;
4538
+ portalNode.current = document.createElement('div');
4539
+ portalNode.current.classList.add('modal-ui-drawer');
4540
+ document.body.appendChild(portalNode.current);
4541
+ setMounted(true);
4542
+ return function () {
4543
+ if (portalNode.current) {
4544
+ document.body.removeChild(portalNode.current);
4545
+ }
4546
+ };
4547
+ }, []);
4548
+ return mounted && portalNode.current ? ReactDOM.createPortal(children, portalNode.current) : null;
4549
+ };
4550
+
4529
4551
  var Modal = function (_a) {
4530
4552
  var onClose = _a.onClose, isOpen = _a.isOpen, children = _a.children, title = _a.title, description = _a.description, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.blockBackgroundClose, blockBackgroundClose = _c === void 0 ? false : _c;
4531
4553
  useEffect(function () {
@@ -4536,7 +4558,7 @@ var Modal = function (_a) {
4536
4558
  }, [isOpen]);
4537
4559
  if (!isOpen)
4538
4560
  return null;
4539
- return (React.createElement(Fragment, null,
4561
+ return (React.createElement(ModalPortal, null,
4540
4562
  React.createElement("div", { className: "".concat(styles$1p["".concat(classMUI, "-modal")], " ").concat(className) },
4541
4563
  title ? React.createElement("h2", { className: "".concat(styles$1p["".concat(classMUI, "-modal__title")]) }, title) : null,
4542
4564
  description ? React.createElement("p", { className: "".concat(styles$1p["".concat(classMUI, "-modal__description")]) }, description) : null,
@@ -5312,21 +5334,6 @@ var MegaMenuEmpty = function (_a) {
5312
5334
  React.createElement("img", { className: style$y['mega-menu-empty__image'], src: staticMessages[imageData], height: 170 })));
5313
5335
  };
5314
5336
 
5315
- var ModalPortal = function (_a) {
5316
- var children = _a.children;
5317
- var portalNode = useRef(null);
5318
- var _b = useState(false), mounted = _b[0], setMounted = _b[1];
5319
- useEffect(function () {
5320
- if (!document)
5321
- return;
5322
- portalNode.current = document.createElement('div');
5323
- portalNode.current.classList.add('modal-ui-drawer');
5324
- document.body.appendChild(portalNode.current);
5325
- setMounted(true);
5326
- }, []);
5327
- return mounted && portalNode.current ? ReactDOM.createPortal(children, portalNode.current) : null;
5328
- };
5329
-
5330
5337
  var styles$10 = {"notification":"mg_notification_notification_ylzl6","top-left":"mg_notification_top-left_ylzl6","top-right":"mg_notification_top-right_ylzl6","bottom-left":"mg_notification_bottom-left_ylzl6","bottom-right":"mg_notification_bottom-right_ylzl6","notification__content":"mg_notification_notification_content_ylzl6","notification__message":"mg_notification_notification_message_ylzl6","notification__close-btn":"mg_notification_notification_close-btn_ylzl6"};
5331
5338
 
5332
5339
  var Notification = function (_a) {
@@ -7754,8 +7761,25 @@ var useSelect2 = function (_a) {
7754
7761
  }
7755
7762
  }, [searchValue, setTerm]);
7756
7763
  useEffect(function () {
7757
- if (!currentFields || !currentFields.length) {
7758
- setValueSelected([]);
7764
+ if (!currentFields) {
7765
+ if (valueSelected.length !== 0) {
7766
+ setValueSelected([]);
7767
+ }
7768
+ return;
7769
+ }
7770
+ if (!Array.isArray(currentFields)) {
7771
+ if ('id' in currentFields && 'name' in currentFields) {
7772
+ var newValue = [currentFields];
7773
+ if (JSON.stringify(valueSelected) !== JSON.stringify(newValue)) {
7774
+ setValueSelected(newValue);
7775
+ }
7776
+ }
7777
+ return;
7778
+ }
7779
+ if (currentFields.length === 0) {
7780
+ if (valueSelected.length !== 0) {
7781
+ setValueSelected([]);
7782
+ }
7759
7783
  return;
7760
7784
  }
7761
7785
  setValueSelected(function (prev) {
@@ -7764,7 +7788,7 @@ var useSelect2 = function (_a) {
7764
7788
  }
7765
7789
  return currentFields;
7766
7790
  });
7767
- }, [currentFields]);
7791
+ }, [currentFields, valueSelected]);
7768
7792
  useEffect(function () {
7769
7793
  if (limitSelections && valueSelected.length >= limitSelections) {
7770
7794
  setDisableList(true);