@finsemble/finsemble-ui 7.2.1 → 7.3.0-beta.1

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 (124) hide show
  1. package/package.json +14 -14
  2. package/react/assets/css/button.css +34 -6
  3. package/react/assets/css/contextMenu.css +118 -0
  4. package/react/assets/css/notificationsCenter.css +3 -214
  5. package/react/assets/css/userPreferences.css +2 -2
  6. package/react/components/common/Checkbox.d.ts +3 -2
  7. package/react/components/common/Checkbox.js +5 -21
  8. package/react/components/common/Checkbox.js.map +1 -1
  9. package/react/components/common/ContextMenu.d.ts +13 -0
  10. package/react/components/common/ContextMenu.js +69 -0
  11. package/react/components/common/ContextMenu.js.map +1 -0
  12. package/react/components/common/DropdownButton.d.ts +0 -4
  13. package/react/components/common/DropdownButton.js +39 -10
  14. package/react/components/common/DropdownButton.js.map +1 -1
  15. package/react/components/common/css/FinsembleToggle.css +0 -1
  16. package/react/components/common/css/application-edit-page.css +3 -4
  17. package/react/components/common/css/checkbox.css +60 -21
  18. package/react/components/common/css/icon.css +2 -2
  19. package/react/components/common/css/toggle.css +4 -1
  20. package/react/components/common/helpers.js +9 -0
  21. package/react/components/common/helpers.js.map +1 -1
  22. package/react/components/common/stories/ContextMenu.stories.d.ts +38 -0
  23. package/react/components/common/stories/ContextMenu.stories.js +70 -0
  24. package/react/components/common/stories/ContextMenu.stories.js.map +1 -0
  25. package/react/components/common/stories/DropdownButton.stories.d.ts +3 -3
  26. package/react/components/common/stories/DropdownButton.stories.js +11 -10
  27. package/react/components/common/stories/DropdownButton.stories.js.map +1 -1
  28. package/react/components/common/tests/Checkbox.spec.js +10 -12
  29. package/react/components/common/tests/Checkbox.spec.js.map +1 -1
  30. package/react/components/common/tests/ContextMenu.spec.d.ts +1 -0
  31. package/react/components/common/tests/ContextMenu.spec.js +108 -0
  32. package/react/components/common/tests/ContextMenu.spec.js.map +1 -0
  33. package/react/components/common/tests/DropdownButton.spec.d.ts +1 -0
  34. package/react/components/common/tests/DropdownButton.spec.js +32 -0
  35. package/react/components/common/tests/DropdownButton.spec.js.map +1 -0
  36. package/react/components/notifications/components/drawer/DrawerHeader.js +3 -3
  37. package/react/components/notifications/components/drawer/DrawerHeader.js.map +1 -1
  38. package/react/components/notifications/components/notificationsCenter/NotificationsCenter.js +1 -0
  39. package/react/components/notifications/components/notificationsCenter/NotificationsCenter.js.map +1 -1
  40. package/react/components/notifications/components/notificationsToasts/NotificationsToasts.js +2 -0
  41. package/react/components/notifications/components/notificationsToasts/NotificationsToasts.js.map +1 -1
  42. package/react/components/notifications/components/shared/IconButton.js +2 -1
  43. package/react/components/notifications/components/shared/IconButton.js.map +1 -1
  44. package/react/components/notifications/components/shared/NotificationCardShell.d.ts +2 -0
  45. package/react/components/notifications/components/shared/NotificationCardShell.js +55 -49
  46. package/react/components/notifications/components/shared/NotificationCardShell.js.map +1 -1
  47. package/react/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.js +2 -3
  48. package/react/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.js.map +1 -1
  49. package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.d.ts +4 -0
  50. package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.js +92 -13
  51. package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.js.map +1 -1
  52. package/react/components/notifications/components/views/ListView.js +5 -9
  53. package/react/components/notifications/components/views/ListView.js.map +1 -1
  54. package/react/components/notifications/css/notification-card.css +165 -0
  55. package/react/components/notifications/stories/NotificationCardShell.stories.d.ts +14 -0
  56. package/react/components/notifications/stories/NotificationCardShell.stories.js +108 -0
  57. package/react/components/notifications/stories/NotificationCardShell.stories.js.map +1 -0
  58. package/react/components/notifications/tests/NotificationCardShell.spec.d.ts +1 -0
  59. package/react/components/notifications/tests/NotificationCardShell.spec.js +91 -0
  60. package/react/components/notifications/tests/NotificationCardShell.spec.js.map +1 -0
  61. package/react/components/notifications/types.d.ts +4 -2
  62. package/react/components/notifications/types.js.map +1 -1
  63. package/react/components/sdd/AddApp.d.ts +3 -3
  64. package/react/components/sdd/AddApp.js +29 -21
  65. package/react/components/sdd/AddApp.js.map +1 -1
  66. package/react/components/sdd/AppEditPage.js +1 -8
  67. package/react/components/sdd/AppEditPage.js.map +1 -1
  68. package/react/components/sdd/Appearance.css +2 -1
  69. package/react/components/sdd/Applications.js +7 -7
  70. package/react/components/sdd/Applications.js.map +1 -1
  71. package/react/components/sdd/Navigation.js +2 -4
  72. package/react/components/sdd/Navigation.js.map +1 -1
  73. package/react/components/sdd/common/views.js +1 -14
  74. package/react/components/sdd/common/views.js.map +1 -1
  75. package/react/components/sdd/css/addApp.css +64 -1
  76. package/react/components/sdd/css/nav.css +50 -29
  77. package/react/components/sdd/fixtures/views.js +1 -14
  78. package/react/components/sdd/fixtures/views.js.map +1 -1
  79. package/react/components/sdd/tests/AddApp.spec.js +2 -2
  80. package/react/components/sdd/tests/AddApp.spec.js.map +1 -1
  81. package/react/components/sdd/tests/AppEditPage.spec.js +5 -8
  82. package/react/components/sdd/tests/AppEditPage.spec.js.map +1 -1
  83. package/react/components/sdd/tests/Export.spec.js +11 -11
  84. package/react/components/sdd/tests/Export.spec.js.map +1 -1
  85. package/react/components/sdd/tests/ExportZip.spec.js +3 -3
  86. package/react/components/sdd/tests/ExportZip.spec.js.map +1 -1
  87. package/react/components/sdd/tests/Navigation.spec.js +3 -2
  88. package/react/components/sdd/tests/Navigation.spec.js.map +1 -1
  89. package/react/components/sdd/tests/SmartDesktopDesigner.spec.js +1 -2
  90. package/react/components/sdd/tests/SmartDesktopDesigner.spec.js.map +1 -1
  91. package/react/components/toolbar/dashbar/Dashbar.js +18 -14
  92. package/react/components/toolbar/dashbar/Dashbar.js.map +1 -1
  93. package/react/components/toolbar/workspaceManagementMenu/components/Workspace.d.ts +9 -1
  94. package/react/components/toolbar/workspaceManagementMenu/components/Workspace.js +35 -1
  95. package/react/components/toolbar/workspaceManagementMenu/components/Workspace.js.map +1 -1
  96. package/react/components/toolbar/workspaceManagementMenu/stores/workspaceManagementMenuStore.js +1 -1
  97. package/react/components/toolbar/workspaceManagementMenu/stores/workspaceManagementMenuStore.js.map +1 -1
  98. package/react/components/userPreferences/components/content/Workspaces.d.ts +3 -1
  99. package/react/components/userPreferences/components/content/Workspaces.js +20 -3
  100. package/react/components/userPreferences/components/content/Workspaces.js.map +1 -1
  101. package/react/components/userPreferences/components/workspaces/WorkspaceItem.d.ts +1 -0
  102. package/react/components/userPreferences/components/workspaces/WorkspaceItem.js +3 -2
  103. package/react/components/userPreferences/components/workspaces/WorkspaceItem.js.map +1 -1
  104. package/react/components/userPreferences/tests/NotificationsPreferencesHome.spec.js +12 -9
  105. package/react/components/userPreferences/tests/NotificationsPreferencesHome.spec.js.map +1 -1
  106. package/react/components/userPreferences/tests/UserPreferencesBase.spec.js +2 -0
  107. package/react/components/userPreferences/tests/UserPreferencesBase.spec.js.map +1 -1
  108. package/react/components/windowTitleBar/WindowTitleBarShell.d.ts +99 -26
  109. package/react/components/windowTitleBar/WindowTitleBarShell.js +204 -131
  110. package/react/components/windowTitleBar/WindowTitleBarShell.js.map +1 -1
  111. package/react/components/windowTitleBar/components/left/LinkerButton.js +30 -21
  112. package/react/components/windowTitleBar/components/left/LinkerButton.js.map +1 -1
  113. package/react/hooks/useNotifications.js +8 -7
  114. package/react/hooks/useNotifications.js.map +1 -1
  115. package/react/tsconfig.tsbuildinfo +1 -1
  116. package/react/components/notifications/components/shared/OverflowMenu.d.ts +0 -16
  117. package/react/components/notifications/components/shared/OverflowMenu.js +0 -114
  118. package/react/components/notifications/components/shared/OverflowMenu.js.map +0 -1
  119. package/react/components/sdd/GettingStarted.d.ts +0 -8
  120. package/react/components/sdd/GettingStarted.js +0 -25
  121. package/react/components/sdd/GettingStarted.js.map +0 -1
  122. package/react/components/sdd/stories/GettingStarted.stories.d.ts +0 -11
  123. package/react/components/sdd/stories/GettingStarted.stories.js +0 -18
  124. package/react/components/sdd/stories/GettingStarted.stories.js.map +0 -1
@@ -531,24 +531,6 @@ export class WindowTitleBarShell extends React.Component {
531
531
  bodyElement.style.overflowY = "auto";
532
532
  }
533
533
  }
534
- beginAdjustment() {
535
- const header = document.getElementsByClassName("fsbl-header")[0];
536
- if (header) {
537
- const bodyElement = document.querySelector("body");
538
- const headerHeight = window.getComputedStyle(header, null).getPropertyValue("height");
539
- if (bodyElement) {
540
- bodyElement.style.height = `calc(100vh - ${headerHeight})`;
541
- }
542
- if (this.state.adjustContentHeights)
543
- this.adjustTopLevelHeight(Number(headerHeight.split("px")[0]));
544
- this.bumpElements(this.state.bumpElements);
545
- if (this.state.bumpElements.monitorFixedAdditions)
546
- this.monitorFixedPositionedElements(headerHeight);
547
- }
548
- else {
549
- Logger.system.error("WindowTitleBarShell.maybeAdjustWindow:could not find the header.");
550
- }
551
- }
552
534
  /**
553
535
  * Once document is ready and header is injected into DOM, begin adjusting the height of elements and bump fixed/absolute elements
554
536
  */
@@ -565,79 +547,71 @@ export class WindowTitleBarShell extends React.Component {
565
547
  }
566
548
  }
567
549
  /**
568
- * Monitors the DOM for mutations, if the added node has a fixed position with a top style of 0px, it will be bumped by the title bar height.
569
- * @param headerHeight the height of the header
570
- */
571
- monitorFixedPositionedElements(headerHeight) {
572
- const options = {
573
- childList: true,
574
- subtree: true,
575
- };
576
- /**
577
- * MutationObserver interface provides the ability to watch for
578
- * changes to the DOM tree using the observe method
579
- */
580
- const mutationObserver = new MutationObserver((mutations) => {
581
- mutations.forEach((mutation) => {
582
- mutation.addedNodes.forEach((node) => {
583
- var _a;
584
- if (!((_a = node.className) === null || _a === void 0 ? void 0 : _a.includes("bumped-element"))) {
585
- try {
586
- const nodeStyle = window.getComputedStyle(node);
587
- const topStyle = nodeStyle.top;
588
- // make sure node is fixed, has top style set to 0, and has not been bumped
589
- if (nodeStyle.position === "fixed" && possibleZeros.includes(topStyle)) {
590
- node.style.top = this.calculateBumpValue("0Positioned", topStyle, headerHeight);
591
- node.classList.add("bumped-element");
592
- }
593
- }
594
- catch (err) {
595
- // Expected to error if the node is not an Element e.g text is not of type Element
596
- }
597
- }
598
- });
599
- });
600
- });
601
- // We observe the body and do not disconnect because there may be other elements that are dynamically loaded, such as a dialogue menu.
602
- mutationObserver.observe(document.body, options);
603
- }
604
- /**
605
- * Calls functions to bump fixed and/or absolute elements if configured to do so.
606
- * @param {object} config bumpElements object
550
+ * Begin adjusting the body and top level elements and their direct descendants by the header height.
607
551
  */
608
- bumpElements(config) {
609
- if ((config === null || config === void 0 ? void 0 : config.bumpBy) && (config === null || config === void 0 ? void 0 : config.bumpBy) !== "0px") {
610
- if (config.fixed)
611
- this.bumpFixedElements(config);
612
- if (config.absolute)
613
- this.bumpAbsoluteElements(config);
552
+ beginAdjustment() {
553
+ const header = document.getElementsByClassName("fsbl-header")[0];
554
+ if (header) {
555
+ const bodyElement = document.querySelector("body");
556
+ const headerHeight = window.getComputedStyle(header, null).getPropertyValue("height");
557
+ if (bodyElement) {
558
+ bodyElement.style.height = `calc(100vh - ${headerHeight})`;
559
+ }
560
+ if (this.state.adjustContentHeights)
561
+ this.adjustTopLevelHeight(Number.parseInt(headerHeight, 10));
562
+ this.bumpElements(this.state.bumpElements);
563
+ if (this.state.bumpElements.monitorFixedAdditions)
564
+ this.monitorFixedPositionedElements(headerHeight);
614
565
  }
615
- }
616
- /**
617
- * Set the max height of each element to be the height of the parent container
618
- * subtracted by the height of the previous element. This forces the element to either obey its
619
- * predefined height or stay within the bounds of the max height.
620
- * @param {object} elem HTML element
621
- * @param {number} prev height of previous sibling
622
- * @param maxHeight
623
- */
624
- adjust(elem, prev, maxHeight = "100vh") {
625
- var _a, _b;
626
- if (!((_a = elem.classList) === null || _a === void 0 ? void 0 : _a.contains("adjusted-element")) &&
627
- // workaround to fix dnd scrim disappearing
628
- !((_b = elem.classList) === null || _b === void 0 ? void 0 : _b.contains("fsbl-share-scrim"))) {
629
- const clientHeight = elem.clientHeight ? elem.clientHeight : 0;
630
- const offsetHeight = elem.offsetHeight ? elem.offsetHeight : 0;
631
- const offset = offsetHeight - clientHeight;
632
- const adjustPrev = prev + offset;
633
- elem.style.maxHeight = `calc(${maxHeight} - ${adjustPrev}px)`;
634
- elem.classList.add("adjusted-element");
566
+ else {
567
+ Logger.system.error("WindowTitleBarShell.maybeAdjustWindow:could not find the header.");
635
568
  }
636
569
  }
637
570
  /**
638
- * Adjusts the top level content view height to be its height subtracted by the headerHeight and its
639
- * maxHeight to be 100vh subtracted by the total height of the previous elements.
571
+ * Togglable setting found in `foreign.components.["Window Manager"].FSBLHeader.adjustContentHeights`
572
+ * Called from beginAdjustment()
573
+ *
574
+ * Adjusts the top level content maxHeight to be 100vh subtracted by the total height of the previous elements.
640
575
  * The height of the previous elements are added to this calculation if they are not fixed or absolute.
576
+ * These top level elements will be passed into adjustContentHeight where their descendants
577
+ * will also have their heights adjusted.
578
+ * Example:
579
+ * In this below situation, the B element extends passed the view because the header is injected. B doesn't have a
580
+ * set height so it'll extend as far as it needs.
581
+ * --------------------
582
+ * |******************|
583
+ * |* Titlebar *|
584
+ * |******************|
585
+ * |******************|
586
+ * |* A *|
587
+ * |* *|
588
+ * |******************|
589
+ * |******************|
590
+ * |* *|
591
+ * |* *|
592
+ * |* B *|
593
+ * |* *|
594
+ * |* *|
595
+ * |* *|
596
+ * --------------------
597
+ * The chain of adjust functions will set the maxHeight of A and B to ensure they both occupy space that the above element doesn't
598
+ * and keep it within the bounds of the view.
599
+ * --------------------
600
+ * |******************|
601
+ * |* Titlebar *|
602
+ * |******************|
603
+ * |******************|
604
+ * |* A *|
605
+ * |* *|
606
+ * |******************|
607
+ * |******************|
608
+ * |* *|
609
+ * |* *|
610
+ * |* B *|
611
+ * |* *|
612
+ * |* *|
613
+ * |******************|
614
+ * --------------------
641
615
  * @param {number} headerHeight the height of the header
642
616
  */
643
617
  adjustTopLevelHeight(headerHeight) {
@@ -653,12 +627,13 @@ export class WindowTitleBarShell extends React.Component {
653
627
  });
654
628
  }
655
629
  /**
656
- * Adjusts the content view height to be maximum the parent container height subtracted by the total height elements above it.
657
- * The height of the previous elements are added to this calculation if they are not fixed or absolute.
658
- * @param {object} headerNode window titlebar
630
+ * Adjusts the content view height to be maximum of the parent container (passed in by adjustTopLevelHeight()) height
631
+ * subtracted by the total height of elements above it. The height of the previous elements are added to this calculation
632
+ * if they are not fixed or absolute.
633
+ * @param {object} parentElem parent element
659
634
  */
660
- adjustContentHeight(headerNode) {
661
- const elem = headerNode;
635
+ adjustContentHeight(parentElem) {
636
+ const elem = parentElem;
662
637
  const maxHeight = `100%`;
663
638
  const { children } = elem;
664
639
  const len = children.length;
@@ -672,55 +647,57 @@ export class WindowTitleBarShell extends React.Component {
672
647
  }
673
648
  }
674
649
  /**
675
- * Calculates value to bump element by. If 'all' return top style and header height, if '0Positioned' return header height
676
- * @param type Whether all elements are being bumped by the header height and their top style or just header height
677
- * @param topStyle Element top value
678
- * @param bumpBy Value to bump element by
679
- * @returns Top style for element
650
+ * This is used in adjustTopLevelHeight() and adjustContentHeight()
651
+ *
652
+ * Set the max height of each element to be the height of the parent container
653
+ * subtracted by the height of the previous element. This forces the element to either obey its
654
+ * predefined height or stay within the bounds of the max height.
655
+ *
656
+ * @param {object} elem HTML element
657
+ * @param {number} prev height of previous sibling
658
+ * @param {string} maxHeight maximum height of the element
680
659
  */
681
- calculateBumpValue(type, topStyle, bumpBy) {
682
- let topVal = topStyle;
683
- if (type == "all") {
684
- topVal = `calc(${topStyle} + ${bumpBy})`;
685
- }
686
- else if (type == "0Positioned" && possibleZeros.includes(topStyle)) {
687
- topVal = bumpBy;
660
+ adjust(elem, prev, maxHeight = "100vh") {
661
+ var _a, _b;
662
+ if (!((_a = elem.classList) === null || _a === void 0 ? void 0 : _a.contains("adjusted-element")) &&
663
+ // workaround to fix dnd scrim disappearing
664
+ !((_b = elem.classList) === null || _b === void 0 ? void 0 : _b.contains("fsbl-share-scrim"))) {
665
+ const clientHeight = elem.clientHeight ? elem.clientHeight : 0;
666
+ const offsetHeight = elem.offsetHeight ? elem.offsetHeight : 0;
667
+ const offset = offsetHeight - clientHeight;
668
+ const adjustPrev = prev + offset;
669
+ elem.style.maxHeight = `calc(${maxHeight} - ${adjustPrev}px)`;
670
+ elem.classList.add("adjusted-element");
688
671
  }
689
- return topVal;
690
672
  }
691
673
  /**
692
- * Recursively traverse through the HTML document and return an array of the top level elements
693
- * and elements with static parents
694
- * @param {object} element The HTML element
695
- * @param {array} acc accumulator
696
- * @returns {array} array top level elements and elements with static parents
674
+ * Togglable setting found in `foreign.components.["Window Manager"].FSBLHeader.bumpElements.[bumpBy|fixed|absolute]`
675
+ * Called from beginAdjustment()
697
676
  *
677
+ * Calls bumpFixedElements and bumpAbsoluteElements to bump fixed and/or absolute elements by the value of bumpBy if configured to do so.
678
+ * Since absolute and fixed positioned elements are removed from the document flow their positions will not be adjusted when the titlebar
679
+ * is injected and they have a set top style. However, if the element is an absolute positioned element and it's
680
+ * parent container has a position that is not set to static, then it'll adjust relative to the parent. Fixed positioned elements, on the otherhand,
681
+ * won't adjust unless their top stlyes are changed.
682
+ * @param {object} config bumpElements object
698
683
  */
699
- traverseHtml(element, acc = []) {
700
- const elems = element.children;
701
- const len = elems.length;
702
- if (!len) {
703
- acc.push(element);
704
- }
705
- else {
706
- for (let i = 0; i < len; i++) {
707
- const style = window.getComputedStyle(elems[i], null);
708
- if (style.getPropertyValue("position") == "static") {
709
- acc = this.traverseHtml(elems[i], acc);
710
- }
711
- else {
712
- acc.push(elems[i]);
713
- }
714
- }
684
+ bumpElements(config) {
685
+ if ((config === null || config === void 0 ? void 0 : config.bumpBy) !== "0px") {
686
+ if (config.fixed)
687
+ this.bumpFixedElements(config);
688
+ if (config.absolute)
689
+ this.bumpAbsoluteElements(config);
715
690
  }
716
- return acc;
717
691
  }
718
692
  /**
719
- * Bumps elements with fixed positioning down by the configured amount.
693
+ * Called from bumpElements
694
+ *
695
+ * Bumps all elements with fixed positioning, that are not in the header, down by the configured amount.
720
696
  * @private
697
+ * @param {object} params bumpElements object
721
698
  */
722
699
  bumpFixedElements(params) {
723
- var _a;
700
+ var _a, _b;
724
701
  let { fixed, bumpBy } = params;
725
702
  const getFixedElements = (selector) => {
726
703
  const fixedElems = [];
@@ -739,18 +716,21 @@ export class WindowTitleBarShell extends React.Component {
739
716
  for (let i = 0; i < len; i++) {
740
717
  const style = window.getComputedStyle(elems[i], null);
741
718
  const topStyle = style.getPropertyValue("top");
742
- if (!((_a = elems[i].className) === null || _a === void 0 ? void 0 : _a.includes("bumped-element"))) {
719
+ if (!((_b = (_a = elems[i]) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains("bumped-element"))) {
743
720
  elems[i].style.top = this.calculateBumpValue(fixed, topStyle, bumpBy);
744
721
  elems[i].classList.add("bumped-element");
745
722
  }
746
723
  }
747
724
  }
748
725
  /**
749
- * Bumps absolute positioned elements with static parents down by the configured amount.
726
+ * Called from bumpElements
727
+ *
728
+ * Bumps all absolute positioned elements with static parents, that are not in the header, down by the configured amount.
750
729
  * @private
730
+ * @param {object} params bumpElements object
751
731
  */
752
732
  bumpAbsoluteElements(params) {
753
- var _a;
733
+ var _a, _b;
754
734
  let { absolute, bumpBy } = params;
755
735
  const selector = "*:not(#FSBLHeader, .fsbl-header)";
756
736
  // Get top level absolute positioned elements and elements who have static parents
@@ -760,12 +740,105 @@ export class WindowTitleBarShell extends React.Component {
760
740
  const style = window.getComputedStyle(elems[i], null);
761
741
  const topStyle = style.getPropertyValue("top");
762
742
  // Target absolute positioned elements
763
- if (style.getPropertyValue("position") == "absolute" && !((_a = elems[i].className) === null || _a === void 0 ? void 0 : _a.includes("bumped-element"))) {
743
+ if (style.getPropertyValue("position") == "absolute" && !((_b = (_a = elems[i]) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains("bumped-element"))) {
764
744
  elems[i].style.top = this.calculateBumpValue(absolute, topStyle, bumpBy);
765
745
  elems[i].classList.add("bumped-element");
766
746
  }
767
747
  }
768
748
  }
749
+ /**
750
+ * Used in bumpFixedElements and bumpAbsoluteElements
751
+ * Calculates value to bump element by. If 'all' return top style plus the header height, if '0Positioned' return just header height
752
+ * @param type Whether all elements are being bumped by the header height and their top style or just header height
753
+ * @param topStyle Element top value
754
+ * @param bumpBy Value to bump element by
755
+ * @returns Top style for element
756
+ */
757
+ calculateBumpValue(type, topStyle, bumpBy) {
758
+ let topVal = topStyle;
759
+ if (type == "all") {
760
+ topVal = `calc(${topStyle} + ${bumpBy})`;
761
+ }
762
+ else if (type == "0Positioned" && possibleZeros.includes(topStyle)) {
763
+ topVal = bumpBy;
764
+ }
765
+ return topVal;
766
+ }
767
+ /**
768
+ * Used in bumpAbsoluteElements
769
+ *
770
+ * Recursively traverse through the HTML document and return an array of the top level elements
771
+ * and elements with static parents
772
+ * @param {object} element The HTML element
773
+ * @param {array} acc accumulator
774
+ * @returns {array} array top level elements and elements with static parents
775
+ *
776
+ */
777
+ traverseHtml(element, acc = []) {
778
+ const elems = element.children;
779
+ const len = elems.length;
780
+ if (!len) {
781
+ acc.push(element);
782
+ }
783
+ else {
784
+ for (let i = 0; i < len; i++) {
785
+ const style = window.getComputedStyle(elems[i], null);
786
+ if (style.getPropertyValue("position") == "static") {
787
+ acc = this.traverseHtml(elems[i], acc);
788
+ }
789
+ else {
790
+ acc.push(elems[i]);
791
+ }
792
+ }
793
+ }
794
+ return acc;
795
+ }
796
+ /**
797
+ * Togglable setting found in `foreign.components.["Window Manager"].FSBLHeader.bumpElements.[monitorFixedAdditions]`
798
+ * Called from beginAdjustment()
799
+ *
800
+ * Monitors the DOM for mutations, if the added node has a fixed position with a top style of 0px, it will be bumped by the title bar height.
801
+ * This ensures that if a fixed positioned element is dynamically added to the DOM, for example a pop-up modal, it'll have it's height adjusted
802
+ * by the header height since the initial bumping of elements can happen before this element exists.
803
+ *
804
+ * Element heights are not monitored and adjusted since this would require that all pre-existing elements have ther height recalculated each time
805
+ * a new element is dynamically added onto the page. Absolute postioned elements, however, could be monitored and adjusted since all we would
806
+ * need to check for is that it's parent has a static position or not, if it does then it can be adjusted.
807
+ * @param headerHeight the height of the header
808
+ */
809
+ monitorFixedPositionedElements(headerHeight) {
810
+ const options = {
811
+ childList: true,
812
+ subtree: true,
813
+ };
814
+ /**
815
+ * MutationObserver interface provides the ability to watch for
816
+ * changes to the DOM tree using the observe method
817
+ */
818
+ const mutationObserver = new MutationObserver((mutations) => {
819
+ mutations.forEach((mutation) => {
820
+ mutation.addedNodes.forEach((node) => {
821
+ var _a;
822
+ if (!((_a = node === null || node === void 0 ? void 0 : node.classList) === null || _a === void 0 ? void 0 : _a.contains("bumped-element"))) {
823
+ try {
824
+ const nodeStyle = window.getComputedStyle(node);
825
+ const topStyle = nodeStyle.top;
826
+ // make sure node is fixed, has top style set to 0, and has not been bumped
827
+ if (nodeStyle.position === "fixed" && possibleZeros.includes(topStyle)) {
828
+ node.style.top = this.calculateBumpValue("0Positioned", topStyle, headerHeight);
829
+ node.classList.add("bumped-element");
830
+ }
831
+ }
832
+ catch (err) {
833
+ // Expected to error if the node is not an Element e.g text is not of type Element
834
+ }
835
+ }
836
+ });
837
+ });
838
+ });
839
+ // We observe the body and do not disconnect because there may be other elements that are dynamically loaded, such as a dialogue menu.
840
+ mutationObserver.observe(document.body, options);
841
+ }
769
842
  render() {
770
843
  let showDockingIcon = !this.state.dockingEnabled ? false : this.state.dockingIcon;
771
844
  let isGrouped = this.state.dockingIcon == "ejector";