@ringcentral/juno 2.34.0 → 2.35.0

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.
@@ -35,8 +35,9 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
35
35
  var moreTabRef = react_1.useRef(null);
36
36
  var sentinelStartRef = react_1.useRef(null);
37
37
  var tabsRef = foundation_1.useForkRef(innerRef, ref);
38
+ var _c = foundation_1.useRcPortalWindowContext().externalWindow, externalWindow = _c === void 0 ? window : _c;
38
39
  var mountStateRef = foundation_1.useMountState();
39
- var _c = tslib_1.__read(react_1.useState(function () {
40
+ var _d = tslib_1.__read(react_1.useState(function () {
40
41
  var tabsInfo = getTabsInfoFromChildren(childrenProp);
41
42
  if (!tabsInfo) {
42
43
  return {
@@ -50,7 +51,7 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
50
51
  tab: tabsInfo,
51
52
  menu: [],
52
53
  };
53
- }), 2), groupInfo = _c[0], setGroupInfo = _c[1];
54
+ }), 2), groupInfo = _d[0], setGroupInfo = _d[1];
54
55
  var throttleCalculateGroupInfo = foundation_1.useThrottle(function () {
55
56
  var e_1, _a;
56
57
  var _b;
@@ -66,17 +67,15 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
66
67
  try {
67
68
  for (var allTabs_1 = tslib_1.__values(allTabs), allTabs_1_1 = allTabs_1.next(); !allTabs_1_1.done; allTabs_1_1 = allTabs_1.next()) {
68
69
  var tabEl = allTabs_1_1.value;
69
- if (tabEl instanceof HTMLElement) {
70
- if (typeof tabEl.dataset['tabOriginIndex'] === 'string') {
71
- var tabOriginIndex = Number(tabEl.dataset['tabOriginIndex']);
72
- var elSize = tabEl[sizeKey];
73
- allTabsSize[tabOriginIndex] = elSize;
74
- allTabsSizeSumWidthoutMoreButton += elSize;
75
- }
76
- else if (typeof tabEl.dataset['tabMoreButton'] === 'string') {
77
- var elSize = tabEl[sizeKey];
78
- moreButtonSize = elSize;
79
- }
70
+ if (typeof tabEl.dataset['tabOriginIndex'] === 'string') {
71
+ var tabOriginIndex = Number(tabEl.dataset['tabOriginIndex']);
72
+ var elSize = tabEl[sizeKey];
73
+ allTabsSize[tabOriginIndex] = elSize;
74
+ allTabsSizeSumWidthoutMoreButton += elSize;
75
+ }
76
+ else if (typeof tabEl.dataset['tabMoreButton'] === 'string') {
77
+ var elSize = tabEl[sizeKey];
78
+ moreButtonSize = elSize;
80
79
  }
81
80
  }
82
81
  }
@@ -139,7 +138,7 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
139
138
  var tablist = (_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[role="tablist"]');
140
139
  if (!tablist)
141
140
  return;
142
- var resizeObserver = foundation_1.getResizeObserver(throttleCalculateGroupInfo);
141
+ var resizeObserver = foundation_1.getResizeObserver(throttleCalculateGroupInfo, externalWindow);
143
142
  resizeObserver.observe(tablist);
144
143
  try {
145
144
  for (var _c = tslib_1.__values(Array.from(tablist.children)), _d = _c.next(); !_d.done; _d = _c.next()) {
@@ -157,19 +156,19 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
157
156
  }
158
157
  finally { if (e_2) throw e_2.error; }
159
158
  }
160
- var mutationObserver = new MutationObserver(function (mutations) {
159
+ var mutationObserver = new externalWindow.MutationObserver(function (mutations) {
161
160
  var e_3, _a;
162
161
  try {
163
162
  for (var mutations_1 = tslib_1.__values(mutations), mutations_1_1 = mutations_1.next(); !mutations_1_1.done; mutations_1_1 = mutations_1.next()) {
164
163
  var mutation = mutations_1_1.value;
165
164
  if (mutation.type === 'childList') {
166
165
  mutation.removedNodes.forEach(function (removedNode) {
167
- if (removedNode instanceof Element) {
166
+ if (removedNode.getAttribute('role') === 'tab') {
168
167
  resizeObserver.unobserve(removedNode);
169
168
  }
170
169
  });
171
170
  mutation.addedNodes.forEach(function (addedNode) {
172
- if (addedNode instanceof Element) {
171
+ if (addedNode.getAttribute('role') === 'tab') {
173
172
  resizeObserver.observe(addedNode,
174
173
  // TODO: remove this, after remove ResizeObserver polyfill
175
174
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  import { __assign, __makeTemplateObject, __read, __rest, __spread, __values } from "tslib";
2
2
  import MuiTabs from '@material-ui/core/Tabs';
3
3
  import React, { cloneElement, forwardRef, isValidElement, useEffect, useRef, useState, } from 'react';
4
- import { getResizeObserver, styled, useForkRef, useMountState, useOnReRender, useThrottle, } from '../../../../foundation';
4
+ import { getResizeObserver, styled, useForkRef, useMountState, useOnReRender, useThrottle, useRcPortalWindowContext, } from '../../../../foundation';
5
5
  import { DEFAULT_MORE_MENU_TAB_LABEL, MoreMenuTab, } from '../MoreMenuTab';
6
6
  import { MoreMenuTabSentinel } from './MoreMenuTabSentinel';
7
7
  // with of more button with a icon
@@ -33,8 +33,9 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
33
33
  var moreTabRef = useRef(null);
34
34
  var sentinelStartRef = useRef(null);
35
35
  var tabsRef = useForkRef(innerRef, ref);
36
+ var _c = useRcPortalWindowContext().externalWindow, externalWindow = _c === void 0 ? window : _c;
36
37
  var mountStateRef = useMountState();
37
- var _c = __read(useState(function () {
38
+ var _d = __read(useState(function () {
38
39
  var tabsInfo = getTabsInfoFromChildren(childrenProp);
39
40
  if (!tabsInfo) {
40
41
  return {
@@ -48,7 +49,7 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
48
49
  tab: tabsInfo,
49
50
  menu: [],
50
51
  };
51
- }), 2), groupInfo = _c[0], setGroupInfo = _c[1];
52
+ }), 2), groupInfo = _d[0], setGroupInfo = _d[1];
52
53
  var throttleCalculateGroupInfo = useThrottle(function () {
53
54
  var e_1, _a;
54
55
  var _b;
@@ -64,17 +65,15 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
64
65
  try {
65
66
  for (var allTabs_1 = __values(allTabs), allTabs_1_1 = allTabs_1.next(); !allTabs_1_1.done; allTabs_1_1 = allTabs_1.next()) {
66
67
  var tabEl = allTabs_1_1.value;
67
- if (tabEl instanceof HTMLElement) {
68
- if (typeof tabEl.dataset['tabOriginIndex'] === 'string') {
69
- var tabOriginIndex = Number(tabEl.dataset['tabOriginIndex']);
70
- var elSize = tabEl[sizeKey];
71
- allTabsSize[tabOriginIndex] = elSize;
72
- allTabsSizeSumWidthoutMoreButton += elSize;
73
- }
74
- else if (typeof tabEl.dataset['tabMoreButton'] === 'string') {
75
- var elSize = tabEl[sizeKey];
76
- moreButtonSize = elSize;
77
- }
68
+ if (typeof tabEl.dataset['tabOriginIndex'] === 'string') {
69
+ var tabOriginIndex = Number(tabEl.dataset['tabOriginIndex']);
70
+ var elSize = tabEl[sizeKey];
71
+ allTabsSize[tabOriginIndex] = elSize;
72
+ allTabsSizeSumWidthoutMoreButton += elSize;
73
+ }
74
+ else if (typeof tabEl.dataset['tabMoreButton'] === 'string') {
75
+ var elSize = tabEl[sizeKey];
76
+ moreButtonSize = elSize;
78
77
  }
79
78
  }
80
79
  }
@@ -137,7 +136,7 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
137
136
  var tablist = (_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.querySelector('[role="tablist"]');
138
137
  if (!tablist)
139
138
  return;
140
- var resizeObserver = getResizeObserver(throttleCalculateGroupInfo);
139
+ var resizeObserver = getResizeObserver(throttleCalculateGroupInfo, externalWindow);
141
140
  resizeObserver.observe(tablist);
142
141
  try {
143
142
  for (var _c = __values(Array.from(tablist.children)), _d = _c.next(); !_d.done; _d = _c.next()) {
@@ -155,19 +154,19 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
155
154
  }
156
155
  finally { if (e_2) throw e_2.error; }
157
156
  }
158
- var mutationObserver = new MutationObserver(function (mutations) {
157
+ var mutationObserver = new externalWindow.MutationObserver(function (mutations) {
159
158
  var e_3, _a;
160
159
  try {
161
160
  for (var mutations_1 = __values(mutations), mutations_1_1 = mutations_1.next(); !mutations_1_1.done; mutations_1_1 = mutations_1.next()) {
162
161
  var mutation = mutations_1_1.value;
163
162
  if (mutation.type === 'childList') {
164
163
  mutation.removedNodes.forEach(function (removedNode) {
165
- if (removedNode instanceof Element) {
164
+ if (removedNode.getAttribute('role') === 'tab') {
166
165
  resizeObserver.unobserve(removedNode);
167
166
  }
168
167
  });
169
168
  mutation.addedNodes.forEach(function (addedNode) {
170
- if (addedNode instanceof Element) {
169
+ if (addedNode.getAttribute('role') === 'tab') {
171
170
  resizeObserver.observe(addedNode,
172
171
  // TODO: remove this, after remove ResizeObserver polyfill
173
172
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.34.0",
3
+ "version": "2.35.0",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",