@ringcentral/juno 2.35.1 → 2.35.3

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.
@@ -20,6 +20,7 @@ var Calendar = react_1.forwardRef(function (_a, ref) {
20
20
  var calendarRef = react_1.useRef(null);
21
21
  var previousFocusDate = foundation_1.usePrevious(function () { return focusedDate; });
22
22
  var previousView = foundation_1.usePrevious(function () { return view; });
23
+ var doc = foundation_1.useRcPortalWindowContext().document;
23
24
  var weeks = react_1.useRef([]);
24
25
  // * `getWeekdays` not set locale, need set locale before get
25
26
  dayjs_1.default.locale(utils.locale);
@@ -152,19 +153,21 @@ var Calendar = react_1.forwardRef(function (_a, ref) {
152
153
  // same month anchor switch
153
154
  react_1.useLayoutEffect(function () {
154
155
  if (sameMonthDate && !viewChange) {
155
- utils_2.focusDayElement();
156
+ utils_2.focusDayElement(doc);
156
157
  }
157
158
  });
158
159
  // when view change and current is day also focusDay again
159
160
  react_1.useLayoutEffect(function () {
160
161
  if (previousView && view === 'day' && viewChange) {
161
- utils_2.focusDayElement();
162
+ utils_2.focusDayElement(doc);
162
163
  }
163
- }, [previousView, view, viewChange]);
164
+ }, [previousView, view, viewChange, doc]);
164
165
  react_1.useLayoutEffect(function () {
165
- utils_2.focusDayElement();
166
- calendarRef.current = document.querySelector("." + utils_2.RcDatePickerClasses.popover + " ." + utils_2.RcDatePickerClasses.popoverPaper);
167
- var unsubscribe = utils_1.transitionendSubscriber(calendarRef.current, utils_2.onTransitionEnd);
166
+ utils_2.focusDayElement(doc);
167
+ calendarRef.current = doc.querySelector("." + utils_2.RcDatePickerClasses.popover + " ." + utils_2.RcDatePickerClasses.popoverPaper);
168
+ var unsubscribe = utils_1.transitionendSubscriber(calendarRef.current, function (event) {
169
+ utils_2.onTransitionEnd(event, doc);
170
+ });
168
171
  return function () {
169
172
  unsubscribe();
170
173
  };
@@ -13,12 +13,12 @@ declare type DatePickerVolume = {
13
13
  };
14
14
  export declare const RcDatePickerSizes: UnitMap<RcDatePickerSize, DatePickerVolume>;
15
15
  export declare const RcDatePickerIconWidths: UnitMap<RcDatePickerSize, string>;
16
- export declare const focusDayElement: () => void;
16
+ export declare const focusDayElement: (doc?: Document) => void;
17
17
  export declare const isSameYearAndMonth: ({ source, comparing }: {
18
18
  source: MuiPickersDate;
19
19
  comparing: MuiPickersDate;
20
20
  }, utils: import("@date-io/core/IUtils").IUtils<MuiPickersDate>) => boolean;
21
- export declare const onTransitionEnd: (event: any) => void;
21
+ export declare const onTransitionEnd: (event: any, doc?: Document) => void;
22
22
  declare type ValidateDateInRange = {
23
23
  now: MuiPickersDate;
24
24
  } & Pick<CalendarProps, 'dateRange' | 'disableFuture' | 'disablePast'>;
@@ -33,8 +33,9 @@ exports.RcDatePickerIconWidths = {
33
33
  small: '18px',
34
34
  medium: '28px',
35
35
  };
36
- exports.focusDayElement = function () {
37
- var elm = document.querySelector('[data-picker-focused]');
36
+ exports.focusDayElement = function (doc) {
37
+ if (doc === void 0) { doc = document; }
38
+ var elm = doc.querySelector('[data-picker-focused]');
38
39
  elm === null || elm === void 0 ? void 0 : elm.focus();
39
40
  };
40
41
  exports.isSameYearAndMonth = function (_a, utils) {
@@ -48,8 +49,9 @@ exports.isSameYearAndMonth = function (_a, utils) {
48
49
  var comparingYear = utils.getYear(comparing);
49
50
  return thisMonth === comparingMonth && thisYear === comparingYear;
50
51
  };
51
- exports.onTransitionEnd = function (event) {
52
- var activeElm = document.activeElement;
52
+ exports.onTransitionEnd = function (event, doc) {
53
+ if (doc === void 0) { doc = document; }
54
+ var activeElm = doc.activeElement;
53
55
  if (event.target.dataset['transitionTag'] &&
54
56
  // * check is not focus on other thing, like click next month
55
57
  activeElm.dataset['pickerAction'] !== 'true') {
@@ -208,40 +208,42 @@ var _MoreMenuTabs = react_1.forwardRef(function (props, ref) {
208
208
  throttleCalculateGroupInfo();
209
209
  }, [value], false);
210
210
  foundation_1.useOnReRender(function () {
211
- var e_4, _a;
212
211
  var tabsInfo = getTabsInfoFromChildren(childrenProp);
213
212
  var newGroupInfo = {
214
213
  all: tabsInfo,
215
214
  tab: [],
216
215
  menu: [],
217
216
  };
218
- var _loop_1 = function (tabInfo) {
219
- if (groupInfo.tab.some(function (_a) {
220
- var key = _a.key;
221
- return tabInfo.key === key;
222
- })) {
223
- newGroupInfo.tab.push(tabInfo);
224
- }
225
- else {
226
- // push new tab or invisible old tab to menu group
227
- newGroupInfo.menu.push(tabInfo);
228
- }
229
- };
230
- try {
231
- // Prevent moreButton from flickering after children update
232
- for (var tabsInfo_1 = tslib_1.__values(tabsInfo), tabsInfo_1_1 = tabsInfo_1.next(); !tabsInfo_1_1.done; tabsInfo_1_1 = tabsInfo_1.next()) {
233
- var tabInfo = tabsInfo_1_1.value;
234
- _loop_1(tabInfo);
235
- }
236
- }
237
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
238
- finally {
217
+ setGroupInfo(function (preGroupInfo) {
218
+ var e_4, _a;
219
+ var _loop_1 = function (tabInfo) {
220
+ if (preGroupInfo.tab.some(function (_a) {
221
+ var key = _a.key;
222
+ return tabInfo.key === key;
223
+ })) {
224
+ newGroupInfo.tab.push(tabInfo);
225
+ }
226
+ else {
227
+ // push new tab or invisible old tab to menu group
228
+ newGroupInfo.menu.push(tabInfo);
229
+ }
230
+ };
239
231
  try {
240
- if (tabsInfo_1_1 && !tabsInfo_1_1.done && (_a = tabsInfo_1.return)) _a.call(tabsInfo_1);
232
+ // Prevent moreButton from flickering after children update
233
+ for (var tabsInfo_1 = tslib_1.__values(tabsInfo), tabsInfo_1_1 = tabsInfo_1.next(); !tabsInfo_1_1.done; tabsInfo_1_1 = tabsInfo_1.next()) {
234
+ var tabInfo = tabsInfo_1_1.value;
235
+ _loop_1(tabInfo);
236
+ }
241
237
  }
242
- finally { if (e_4) throw e_4.error; }
243
- }
244
- setGroupInfo(newGroupInfo);
238
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
239
+ finally {
240
+ try {
241
+ if (tabsInfo_1_1 && !tabsInfo_1_1.done && (_a = tabsInfo_1.return)) _a.call(tabsInfo_1);
242
+ }
243
+ finally { if (e_4) throw e_4.error; }
244
+ }
245
+ return newGroupInfo;
246
+ });
245
247
  }, [childrenProp], false);
246
248
  react_1.useEffect(function () {
247
249
  onGroupInfoChange === null || onGroupInfoChange === void 0 ? void 0 : onGroupInfoChange([
@@ -4,7 +4,7 @@ import dayjs from 'dayjs';
4
4
  import MuiCircularProgress from '@material-ui/core/CircularProgress';
5
5
  import { useUtils as useMuiUtils } from '@material-ui/pickers';
6
6
  import { runKeyHandler } from '@material-ui/pickers/_shared/hooks/useKeyDown';
7
- import { pick, useEventCallback, usePrevious, useResultRef, } from '../../../../foundation';
7
+ import { pick, useEventCallback, usePrevious, useRcPortalWindowContext, useResultRef, } from '../../../../foundation';
8
8
  import { RcButton } from '../../../Buttons';
9
9
  import { transitionendSubscriber } from '../../../Transitions/utils';
10
10
  import { DatePickerHeader, } from './DatePickerHeader';
@@ -18,6 +18,7 @@ var Calendar = forwardRef(function (_a, ref) {
18
18
  var calendarRef = useRef(null);
19
19
  var previousFocusDate = usePrevious(function () { return focusedDate; });
20
20
  var previousView = usePrevious(function () { return view; });
21
+ var doc = useRcPortalWindowContext().document;
21
22
  var weeks = useRef([]);
22
23
  // * `getWeekdays` not set locale, need set locale before get
23
24
  dayjs.locale(utils.locale);
@@ -150,19 +151,21 @@ var Calendar = forwardRef(function (_a, ref) {
150
151
  // same month anchor switch
151
152
  useLayoutEffect(function () {
152
153
  if (sameMonthDate && !viewChange) {
153
- focusDayElement();
154
+ focusDayElement(doc);
154
155
  }
155
156
  });
156
157
  // when view change and current is day also focusDay again
157
158
  useLayoutEffect(function () {
158
159
  if (previousView && view === 'day' && viewChange) {
159
- focusDayElement();
160
+ focusDayElement(doc);
160
161
  }
161
- }, [previousView, view, viewChange]);
162
+ }, [previousView, view, viewChange, doc]);
162
163
  useLayoutEffect(function () {
163
- focusDayElement();
164
- calendarRef.current = document.querySelector("." + RcDatePickerClasses.popover + " ." + RcDatePickerClasses.popoverPaper);
165
- var unsubscribe = transitionendSubscriber(calendarRef.current, onTransitionEnd);
164
+ focusDayElement(doc);
165
+ calendarRef.current = doc.querySelector("." + RcDatePickerClasses.popover + " ." + RcDatePickerClasses.popoverPaper);
166
+ var unsubscribe = transitionendSubscriber(calendarRef.current, function (event) {
167
+ onTransitionEnd(event, doc);
168
+ });
166
169
  return function () {
167
170
  unsubscribe();
168
171
  };
@@ -31,8 +31,9 @@ export var RcDatePickerIconWidths = {
31
31
  small: '18px',
32
32
  medium: '28px',
33
33
  };
34
- export var focusDayElement = function () {
35
- var elm = document.querySelector('[data-picker-focused]');
34
+ export var focusDayElement = function (doc) {
35
+ if (doc === void 0) { doc = document; }
36
+ var elm = doc.querySelector('[data-picker-focused]');
36
37
  elm === null || elm === void 0 ? void 0 : elm.focus();
37
38
  };
38
39
  export var isSameYearAndMonth = function (_a, utils) {
@@ -46,8 +47,9 @@ export var isSameYearAndMonth = function (_a, utils) {
46
47
  var comparingYear = utils.getYear(comparing);
47
48
  return thisMonth === comparingMonth && thisYear === comparingYear;
48
49
  };
49
- export var onTransitionEnd = function (event) {
50
- var activeElm = document.activeElement;
50
+ export var onTransitionEnd = function (event, doc) {
51
+ if (doc === void 0) { doc = document; }
52
+ var activeElm = doc.activeElement;
51
53
  if (event.target.dataset['transitionTag'] &&
52
54
  // * check is not focus on other thing, like click next month
53
55
  activeElm.dataset['pickerAction'] !== 'true') {
@@ -206,40 +206,42 @@ var _MoreMenuTabs = forwardRef(function (props, ref) {
206
206
  throttleCalculateGroupInfo();
207
207
  }, [value], false);
208
208
  useOnReRender(function () {
209
- var e_4, _a;
210
209
  var tabsInfo = getTabsInfoFromChildren(childrenProp);
211
210
  var newGroupInfo = {
212
211
  all: tabsInfo,
213
212
  tab: [],
214
213
  menu: [],
215
214
  };
216
- var _loop_1 = function (tabInfo) {
217
- if (groupInfo.tab.some(function (_a) {
218
- var key = _a.key;
219
- return tabInfo.key === key;
220
- })) {
221
- newGroupInfo.tab.push(tabInfo);
222
- }
223
- else {
224
- // push new tab or invisible old tab to menu group
225
- newGroupInfo.menu.push(tabInfo);
226
- }
227
- };
228
- try {
229
- // Prevent moreButton from flickering after children update
230
- for (var tabsInfo_1 = __values(tabsInfo), tabsInfo_1_1 = tabsInfo_1.next(); !tabsInfo_1_1.done; tabsInfo_1_1 = tabsInfo_1.next()) {
231
- var tabInfo = tabsInfo_1_1.value;
232
- _loop_1(tabInfo);
233
- }
234
- }
235
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
236
- finally {
215
+ setGroupInfo(function (preGroupInfo) {
216
+ var e_4, _a;
217
+ var _loop_1 = function (tabInfo) {
218
+ if (preGroupInfo.tab.some(function (_a) {
219
+ var key = _a.key;
220
+ return tabInfo.key === key;
221
+ })) {
222
+ newGroupInfo.tab.push(tabInfo);
223
+ }
224
+ else {
225
+ // push new tab or invisible old tab to menu group
226
+ newGroupInfo.menu.push(tabInfo);
227
+ }
228
+ };
237
229
  try {
238
- if (tabsInfo_1_1 && !tabsInfo_1_1.done && (_a = tabsInfo_1.return)) _a.call(tabsInfo_1);
230
+ // Prevent moreButton from flickering after children update
231
+ for (var tabsInfo_1 = __values(tabsInfo), tabsInfo_1_1 = tabsInfo_1.next(); !tabsInfo_1_1.done; tabsInfo_1_1 = tabsInfo_1.next()) {
232
+ var tabInfo = tabsInfo_1_1.value;
233
+ _loop_1(tabInfo);
234
+ }
239
235
  }
240
- finally { if (e_4) throw e_4.error; }
241
- }
242
- setGroupInfo(newGroupInfo);
236
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
237
+ finally {
238
+ try {
239
+ if (tabsInfo_1_1 && !tabsInfo_1_1.done && (_a = tabsInfo_1.return)) _a.call(tabsInfo_1);
240
+ }
241
+ finally { if (e_4) throw e_4.error; }
242
+ }
243
+ return newGroupInfo;
244
+ });
243
245
  }, [childrenProp], false);
244
246
  useEffect(function () {
245
247
  onGroupInfoChange === null || onGroupInfoChange === void 0 ? void 0 : onGroupInfoChange([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.35.1",
3
+ "version": "2.35.3",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",