@ringcentral/juno 2.35.2 → 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') {
@@ -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') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.35.2",
3
+ "version": "2.35.3",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",