@ringcentral/juno 2.0.0-rc.0 → 2.0.3-beta.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.
Files changed (95) hide show
  1. package/README.md +3 -2
  2. package/components/Avatar/Avatar.js +36 -32
  3. package/components/Buttons/Button/Button.js +11 -7
  4. package/components/Buttons/IconButton/IconButton.js +5 -3
  5. package/components/Buttons/SplitButton/SplitButton.js +2 -1
  6. package/components/DetachedWindow/DetachedWindow.d.ts +1 -7
  7. package/components/DetachedWindow/DetachedWindow.js +8 -6
  8. package/components/Dialer/DialPad/utils/useKeyAudio.js +4 -4
  9. package/components/Dialog/Dialog.js +11 -7
  10. package/components/Downshift/Downshift.js +116 -109
  11. package/components/Downshift/SuggestionList/SuggestionList.d.ts +7 -1
  12. package/components/Downshift/SuggestionList/SuggestionList.js +13 -5
  13. package/components/Downshift/utils/useDownshiftError.js +2 -1
  14. package/components/Forms/Checkbox/Checkbox.js +11 -7
  15. package/components/Forms/Picker/DatePicker/DatePicker.js +21 -17
  16. package/components/Forms/TextField/TextField.js +26 -22
  17. package/components/Icon/Icon.js +41 -37
  18. package/components/Icon/utils/IconUtils.js +24 -16
  19. package/components/Link/Link.js +16 -12
  20. package/components/List/ListItem/ListItem.js +16 -12
  21. package/components/List/ListItemText/ListItemText.js +21 -17
  22. package/components/Loading/Loading.js +6 -4
  23. package/components/Menu/MenuItem/MenuItem.js +6 -4
  24. package/components/PortalHost/PortalManager/PortalManager.js +24 -16
  25. package/components/Snackbar/SnackbarContent/SnackbarContent.js +11 -7
  26. package/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabs.js +11 -8
  27. package/components/Tag/Tag.js +11 -7
  28. package/components/Text/Text.js +1 -2
  29. package/components/Text/TextWithEllipsis.js +7 -4
  30. package/components/TextWithHighlight/TextWithHighlight.js +7 -4
  31. package/components/TextWithLink/TextWithLink.js +7 -4
  32. package/components/TextWithTooltip/TextWithTooltip.js +7 -4
  33. package/components/Thumbnail/Thumbnail.js +16 -12
  34. package/components/Tooltip/Tooltip.js +17 -11
  35. package/components/VirtualizedMenu/VirtualizedMenuList.js +8 -10
  36. package/es6/README.md +3 -2
  37. package/es6/components/Avatar/Avatar.js +37 -33
  38. package/es6/components/Buttons/Button/Button.js +12 -8
  39. package/es6/components/Buttons/IconButton/IconButton.js +6 -4
  40. package/es6/components/Buttons/SplitButton/SplitButton.js +2 -1
  41. package/es6/components/DetachedWindow/DetachedWindow.js +8 -6
  42. package/es6/components/Dialer/DialPad/utils/useKeyAudio.js +4 -4
  43. package/es6/components/Dialog/Dialog.js +12 -8
  44. package/es6/components/Downshift/Downshift.js +117 -110
  45. package/es6/components/Downshift/SuggestionList/SuggestionList.js +13 -5
  46. package/es6/components/Downshift/utils/useDownshiftError.js +3 -2
  47. package/es6/components/Forms/Checkbox/Checkbox.js +12 -8
  48. package/es6/components/Forms/Picker/DatePicker/DatePicker.js +22 -18
  49. package/es6/components/Forms/TextField/TextField.js +27 -23
  50. package/es6/components/Icon/Icon.js +42 -38
  51. package/es6/components/Icon/utils/IconUtils.js +24 -16
  52. package/es6/components/Link/Link.js +17 -13
  53. package/es6/components/List/ListItem/ListItem.js +17 -13
  54. package/es6/components/List/ListItemText/ListItemText.js +22 -18
  55. package/es6/components/Loading/Loading.js +6 -4
  56. package/es6/components/Menu/MenuItem/MenuItem.js +6 -4
  57. package/es6/components/PortalHost/PortalManager/PortalManager.js +24 -16
  58. package/es6/components/Snackbar/SnackbarContent/SnackbarContent.js +12 -8
  59. package/es6/components/Tabs/Tabs/MoreMenuTabs/MoreMenuTabs.js +12 -9
  60. package/es6/components/Tag/Tag.js +12 -8
  61. package/es6/components/Text/Text.js +1 -2
  62. package/es6/components/Text/TextWithEllipsis.js +7 -4
  63. package/es6/components/TextWithHighlight/TextWithHighlight.js +7 -4
  64. package/es6/components/TextWithLink/TextWithLink.js +7 -4
  65. package/es6/components/TextWithTooltip/TextWithTooltip.js +7 -4
  66. package/es6/components/Thumbnail/Thumbnail.js +17 -13
  67. package/es6/components/Tooltip/Tooltip.js +18 -12
  68. package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +9 -11
  69. package/es6/foundation/config.js +77 -57
  70. package/es6/foundation/hooks/useAudio/useAudio.js +1 -1
  71. package/es6/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
  72. package/es6/foundation/styles/opacity.js +6 -4
  73. package/es6/foundation/theme/useThemeProps.js +1 -1
  74. package/es6/foundation/utils/clearReactReferencesInNode.js +9 -7
  75. package/es6/foundation/utils/hasValue.js +1 -1
  76. package/es6/foundation/utils/index.js +0 -1
  77. package/es6/foundation/utils/isShowJunoWarning.js +0 -2
  78. package/es6/foundation/utils/withDeprecatedCheck.js +14 -15
  79. package/foundation/config.d.ts +23 -13
  80. package/foundation/config.js +78 -58
  81. package/foundation/hooks/useAudio/useAudio.d.ts +1 -1
  82. package/foundation/hooks/useAudio/useAudio.js +1 -1
  83. package/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
  84. package/foundation/styles/opacity.js +6 -4
  85. package/foundation/theme/useThemeProps.d.ts +1 -1
  86. package/foundation/theme/useThemeProps.js +1 -1
  87. package/foundation/utils/clearReactReferencesInNode.js +9 -7
  88. package/foundation/utils/hasValue.js +1 -1
  89. package/foundation/utils/index.d.ts +0 -1
  90. package/foundation/utils/index.js +0 -1
  91. package/foundation/utils/isShowJunoWarning.d.ts +0 -1
  92. package/foundation/utils/isShowJunoWarning.js +0 -4
  93. package/foundation/utils/withDeprecatedCheck.d.ts +2 -2
  94. package/foundation/utils/withDeprecatedCheck.js +14 -15
  95. package/package.json +2 -2
@@ -27,8 +27,7 @@ var _RcText = forwardRef(function (inProps, ref) {
27
27
  }, [TooltipPropsProp, isShowTitle]);
28
28
  return (React.createElement(RcTypography, __assign({ ref: textRef, title: isShowTitle || useRcTooltip // * if useRcTooltip always keep title pass into
29
29
  ? // * if user pass title, use title first
30
- title || (isString(children) ? children : undefined)
31
- : undefined, TooltipProps: TooltipProps, useRcTooltip: useRcTooltip, variant: highlight ? 'inherit' : undefined, component: highlight ? 'span' : undefined, className: className }, rest), children));
30
+ title !== null && title !== void 0 ? title : (isString(children) ? children : undefined) : undefined, TooltipProps: TooltipProps, useRcTooltip: useRcTooltip, variant: highlight ? 'inherit' : undefined, component: highlight ? 'span' : undefined, className: className }, rest), children));
32
31
  });
33
32
  /**
34
33
  * `RcText` will auto add title with children when that children is string
@@ -4,10 +4,13 @@ import { Typography as MuiTypography } from '@material-ui/core';
4
4
  import { ellipsis, useDeprecatedLog } from '../../foundation';
5
5
  import styled from '../../foundation/styled-components';
6
6
  var _RcTextWithEllipsis = forwardRef(function (props, ref) {
7
- useDeprecatedLog({
8
- component: 'RcTextWithEllipsis',
9
- message: 'should not use that, just use `RcText` with `titleWhenOverflow` and `flexFull`',
10
- });
7
+ if (process.env.NODE_ENV !== 'production') {
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useDeprecatedLog({
10
+ component: 'RcTextWithEllipsis',
11
+ message: 'should not use that, just use `RcText` with `titleWhenOverflow` and `flexFull`',
12
+ });
13
+ }
11
14
  return React.createElement(MuiTypography, __assign({}, props, { ref: ref }));
12
15
  });
13
16
  /** @deprecated should not use that, just use `RcText` with `titleWhenOverflow` and `flexFull` */
@@ -5,10 +5,13 @@ import styled from '../../foundation/styled-components';
5
5
  var StyledSpan = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n background-color: ", ";\n a {\n color: inherit;\n }\n"], ["\n color: ", ";\n background-color: ", ";\n a {\n color: inherit;\n }\n"])), palette2('highlight', 'f01'), palette2('highlight', 'b02'));
6
6
  /** @deprecated should not use that, just use RcText with `highlight` */
7
7
  var RcTextWithHighlight = function (props) {
8
- useDeprecatedLog({
9
- component: 'RcTextWithHighlight',
10
- message: 'should not use that, just use RcText with `highlight`',
11
- });
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ // eslint-disable-next-line react-hooks/rules-of-hooks
10
+ useDeprecatedLog({
11
+ component: 'RcTextWithHighlight',
12
+ message: 'should not use that, just use RcText with `highlight`',
13
+ });
14
+ }
12
15
  return React.createElement(StyledSpan, __assign({ className: "highlight-term" }, props));
13
16
  };
14
17
  export { RcTextWithHighlight };
@@ -7,10 +7,13 @@ import { RcLink } from '../Link';
7
7
  var TipsText = styled(MuiTypography)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n color: ", ";\n ", ";\n * {\n ", ";\n }\n }\n"], ["\n && {\n color: ", ";\n ", ";\n * {\n ", ";\n }\n }\n"])), palette2('neutral', 'f04'), typography('caption1'), typography('caption1'));
8
8
  /** @deprecated please don't use that component, just use RcText and RcLink directly */
9
9
  var RcTextWithLink = memo(function (props) {
10
- useDeprecatedLog({
11
- component: 'RcTextWithLink',
12
- message: "please don't use that component, just use `RcText` and RcLink directly",
13
- });
10
+ if (process.env.NODE_ENV !== 'production') {
11
+ // eslint-disable-next-line react-hooks/rules-of-hooks
12
+ useDeprecatedLog({
13
+ component: 'RcTextWithLink',
14
+ message: "please don't use that component, just use `RcText` and RcLink directly",
15
+ });
16
+ }
14
17
  var text = props.text, linkText = props.linkText, onClick = props.onClick, TypographyProps = props.TypographyProps, RcLinkProps = props.RcLinkProps;
15
18
  var textProps;
16
19
  if (TypographyProps) {
@@ -8,10 +8,13 @@ var StyledText = styled.span(templateObject_1 || (templateObject_1 = __makeTempl
8
8
  });
9
9
  /** @deprecated please don't use that component, just use `RcText` with `title` directly */
10
10
  var RcTextWithTooltip = function (props) {
11
- useDeprecatedLog({
12
- component: 'RcTextWithTooltip',
13
- message: "please don't use that component, just use `RcText` with `title` directly",
14
- });
11
+ if (process.env.NODE_ENV !== 'production') {
12
+ // eslint-disable-next-line react-hooks/rules-of-hooks
13
+ useDeprecatedLog({
14
+ component: 'RcTextWithTooltip',
15
+ message: "please don't use that component, just use `RcText` with `title` directly",
16
+ });
17
+ }
15
18
  var tooltip = props.tooltip, children = props.children, _a = props.textColor, textColor = _a === void 0 ? ['neutral', 'f06'] : _a;
16
19
  var ref = useRef(null);
17
20
  var _b = __read(useState(false), 2), showTooltip = _b[0], setShowTooltip = _b[1];
@@ -1,25 +1,29 @@
1
1
  import { __assign, __makeTemplateObject, __rest } from "tslib";
2
2
  import React, { forwardRef, memo } from 'react';
3
- import { styled, useThemeProps, withDeprecatedCheck, } from '../../foundation';
3
+ import { styled, useDeprecatedCheck, useThemeProps, } from '../../foundation';
4
4
  import { RcIcon } from '../Icon';
5
5
  import { StyledThumbnail } from './styles';
6
6
  var _RcThumbnail = forwardRef(function (inProps, ref) {
7
7
  var props = useThemeProps({ props: inProps, name: 'RcThumbnail' });
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ // eslint-disable-next-line react-hooks/rules-of-hooks
10
+ useDeprecatedCheck(RcThumbnail, props, [
11
+ {
12
+ prop: 'iconType',
13
+ time: '2021-2',
14
+ comment: 'Please use symbol to set icon',
15
+ },
16
+ {
17
+ prop: 'url',
18
+ time: '2021-2',
19
+ comment: 'Please use src to set url',
20
+ },
21
+ ]);
22
+ }
8
23
  var url = props.url, _a = props.src, src = _a === void 0 ? url : _a, iconType = props.iconType, size = props.size, symbol = props.symbol, rest = __rest(props, ["url", "src", "iconType", "size", "symbol"]);
9
24
  return (React.createElement(React.Fragment, null, src ? (React.createElement(StyledThumbnail, __assign({ ref: ref, src: src, size: size, "data-test-automation-id": "thumbnail" }, rest))) : (React.createElement(RcIcon, __assign({ ref: ref, "data-test-automation-id": "iconThumbnail" }, rest, { size: size === 'small' ? 'small' : 'xxxlarge', symbol: symbol }), iconType))));
10
25
  });
11
- var RcThumbnail = styled(withDeprecatedCheck(memo(_RcThumbnail), [
12
- {
13
- prop: 'iconType',
14
- time: '2021-2',
15
- comment: 'Please use symbol to set icon',
16
- },
17
- {
18
- prop: 'url',
19
- time: '2021-2',
20
- comment: 'Please use src to set url',
21
- },
22
- ], 'RcThumbnail'))(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
26
+ var RcThumbnail = styled(memo(_RcThumbnail))(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
23
27
  RcThumbnail.defaultProps = {
24
28
  size: 'large',
25
29
  };
@@ -1,11 +1,21 @@
1
1
  import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
2
2
  import React, { forwardRef, useLayoutEffect, useMemo, useRef, useState, } from 'react';
3
3
  import MuiTooltip from '@material-ui/core/Tooltip';
4
- import { combineClasses, combineProps, logInDev, styled, useForkRef, useRcPortalWindowContext, useThemeProps, withDeprecatedCheck, } from '../../foundation';
4
+ import { combineClasses, combineProps, logInDev, styled, useDeprecatedCheck, useForkRef, useRcPortalWindowContext, useThemeProps, } from '../../foundation';
5
5
  import { Mask, tooltipStyle } from './styles';
6
6
  import { RcTooltipClasses, useTooltipForceHide } from './utils';
7
7
  var _RcTooltip = forwardRef(function (inProps, ref) {
8
8
  var props = useThemeProps({ props: inProps, name: 'RcTooltip' });
9
+ if (process.env.NODE_ENV !== 'production') {
10
+ // eslint-disable-next-line react-hooks/rules-of-hooks
11
+ useDeprecatedCheck(RcTooltip, props, [
12
+ {
13
+ prop: 'injectGlobalStyle',
14
+ time: '2021-3',
15
+ comment: "@deprecated now need anymore */",
16
+ },
17
+ ]);
18
+ }
9
19
  var children = props.children, tooltipForceHide = props.tooltipForceHide, openProp = props.open, onOpen = props.onOpen, onClose = props.onClose,
10
20
  // * that className will pass into children, just pick that and pass into root popper
11
21
  // * that also not a props in mui doc https://material-ui.com/api/tooltip/
@@ -44,10 +54,12 @@ var _RcTooltip = forwardRef(function (inProps, ref) {
44
54
  childNode.tagName.toLowerCase() === 'button' &&
45
55
  childNode.disabled) {
46
56
  setIsDisabledButton(true);
47
- logInDev({
48
- component: 'RcTooltip',
49
- message: 'You have set a tooltip on disabled button, A disabled element does not fire events.',
50
- });
57
+ if (process.env.NODE_ENV !== 'production') {
58
+ logInDev({
59
+ component: 'RcTooltip',
60
+ message: 'You have set a tooltip on disabled button, A disabled element does not fire events.',
61
+ });
62
+ }
51
63
  }
52
64
  else if (isDisabledButton) {
53
65
  setIsDisabledButton(false);
@@ -56,13 +68,7 @@ var _RcTooltip = forwardRef(function (inProps, ref) {
56
68
  return (React.createElement(MuiTooltip, __assign({ ref: tooltipRef, title: isDisabledButton ? '' : title, arrow: true, classes: classes, PopperProps: PopperProps }, additionProp, rest), ignorePointer ? (React.createElement(Mask, __assign({}, maskProps), children)) : (children)));
57
69
  });
58
70
  /** @release */
59
- var RcTooltip = styled(withDeprecatedCheck(_RcTooltip, [
60
- {
61
- prop: 'injectGlobalStyle',
62
- time: '2021-3',
63
- comment: "@deprecated now need anymore */",
64
- },
65
- ], 'RcTooltip'))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), tooltipStyle);
71
+ var RcTooltip = styled(_RcTooltip)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), tooltipStyle);
66
72
  RcTooltip.defaultProps = {
67
73
  placement: 'bottom',
68
74
  color: 'neutral.b04',
@@ -1,7 +1,7 @@
1
1
  import { __assign, __makeTemplateObject, __rest } from "tslib";
2
2
  import React, { forwardRef, useImperativeHandle, useMemo, useRef, } from 'react';
3
3
  import { isFragment } from 'react-is';
4
- import { combineProps, getScrollbarSize, isRcElement, isShowJunoWarning, logInDev, styled, useDebounce, useEventCallback, useForkRef, useHiddenTabindex, useKeyboardMoveFocus, useMountState, useOnlyOneFocusable, useRcPortalWindowContext, useTheme, useThemeProps, } from '../../foundation';
4
+ import { combineProps, getScrollbarSize, isRcElement, logInDev, styled, useDebounce, useEventCallback, useForkRef, useHiddenTabindex, useKeyboardMoveFocus, useMountState, useOnlyOneFocusable, useRcPortalWindowContext, useTheme, useThemeProps, } from '../../foundation';
5
5
  import { RcList } from '../List/List/List';
6
6
  import { isOutOfRange, useDynamicHeight, useHighlightScroll, Virtuoso, } from '../Virtuoso';
7
7
  import { RcVisuallyHidden } from '../VisuallyHidden';
@@ -33,16 +33,14 @@ var _RcVirtualizedMenuList = forwardRef(function (inProps, ref) {
33
33
  if (!React.isValidElement(child)) {
34
34
  return;
35
35
  }
36
- if (isShowJunoWarning) {
37
- if (isFragment(child)) {
38
- logInDev({
39
- component: 'RcVirtualizedMenuList',
40
- message: [
41
- "Material-UI: The Menu component doesn't accept a Fragment as a child.",
42
- 'Consider providing an array instead.',
43
- ].join('\n'),
44
- });
45
- }
36
+ if (process.env.NODE_ENV !== 'production' && isFragment(child)) {
37
+ logInDev({
38
+ component: 'RcVirtualizedMenuList',
39
+ message: [
40
+ "Material-UI: The Menu component doesn't accept a Fragment as a child.",
41
+ 'Consider providing an array instead.',
42
+ ].join('\n'),
43
+ });
46
44
  }
47
45
  if (!child.props.disabled) {
48
46
  if (variant === 'selectedMenu' && child.props.selected) {
@@ -1,67 +1,87 @@
1
1
  /* eslint-disable no-console */
2
2
  var JUNO_WARNING_IGNORE_KEY = '__JUNO_WARNING_IGNORE__';
3
- var RcConfig = /** @class */ (function () {
4
- function RcConfig() {
5
- var _a;
6
- this._WARNING_IGNORE = false;
7
- this._WARNING_FUNCTION = function (message, options) {
8
- console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
9
- };
10
- if (typeof window !== 'undefined') {
11
- // SSR support
12
- // * get value once when init
13
- this._WARNING_IGNORE =
14
- ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
15
- // * also provide user to set variable from window
16
- window.__JUNO__ = this;
17
- }
18
- }
19
- Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
20
- get: function () {
21
- return this._WARNING_IGNORE;
22
- },
23
- set: function (value) {
3
+ // * use that way to avoid that code be exist in production code base
4
+ /**
5
+ * config global setting
6
+ *
7
+ * ```ts
8
+ * configure({
9
+ * warning: false
10
+ * })
11
+ * ```
12
+ * ## WARNING related method and only work in `development mode`
13
+ *
14
+ * `WARNING_IGNORE`: only work in `development mode`
15
+ * `WARNING_FUNCTION` only work in `development mode`
16
+ */
17
+ var rcConfiguration = {};
18
+ if (process.env.NODE_ENV !== 'production') {
19
+ var RcConfig = /** @class */ (function () {
20
+ function RcConfig() {
24
21
  var _a;
25
- if (value) {
26
- console.log('---------------- [Juno] ----------------');
27
- console.log("Don't recommended you close it, we should avoid use any deprecated props or methods.");
28
- console.log('---------------- [Juno] ----------------');
29
- }
30
- this._WARNING_IGNORE = !!value;
31
- (_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.setItem(JUNO_WARNING_IGNORE_KEY, "" + this._WARNING_IGNORE);
32
- },
33
- enumerable: true,
34
- configurable: true
35
- });
36
- Object.defineProperty(RcConfig.prototype, "WARNING_FUNCTION", {
37
- get: function () {
38
- return this._WARNING_FUNCTION;
39
- },
40
- set: function (func) {
41
- if (typeof func === 'function') {
42
- this._WARNING_FUNCTION = func;
22
+ this._WARNING_IGNORE = false;
23
+ this._WARNING_FUNCTION = function (message, options) {
24
+ console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
25
+ };
26
+ if (typeof window !== 'undefined') {
27
+ // SSR support
28
+ // * get value once when init
29
+ this._WARNING_IGNORE =
30
+ ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
31
+ // * also provide user to set variable from window
32
+ window.__JUNO__ = this;
43
33
  }
44
- else {
45
- console.warn('[Juno] config warningFunction is not a function.');
46
- }
47
- },
48
- enumerable: true,
49
- configurable: true
50
- });
51
- return RcConfig;
52
- }());
53
- /** config instance */
54
- var rcConfiguration = new RcConfig();
34
+ }
35
+ Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
36
+ get: function () {
37
+ return this._WARNING_IGNORE;
38
+ },
39
+ set: function (value) {
40
+ var _a;
41
+ if (value) {
42
+ console.log('---------------- [Juno] ----------------');
43
+ console.log("Don't recommended you close it, we should avoid use any deprecated props or methods.");
44
+ console.log('---------------- [Juno] ----------------');
45
+ }
46
+ this._WARNING_IGNORE = !!value;
47
+ (_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.setItem(JUNO_WARNING_IGNORE_KEY, "" + this._WARNING_IGNORE);
48
+ },
49
+ enumerable: true,
50
+ configurable: true
51
+ });
52
+ Object.defineProperty(RcConfig.prototype, "WARNING_FUNCTION", {
53
+ get: function () {
54
+ return this._WARNING_FUNCTION;
55
+ },
56
+ set: function (func) {
57
+ if (typeof func === 'function') {
58
+ this._WARNING_FUNCTION = func;
59
+ }
60
+ else {
61
+ console.warn('[Juno] config warningFunction is not a function.');
62
+ }
63
+ },
64
+ enumerable: true,
65
+ configurable: true
66
+ });
67
+ return RcConfig;
68
+ }());
69
+ rcConfiguration = new RcConfig();
70
+ }
55
71
  /**
56
72
  * set config with Juno
73
+ *
74
+ * ## WARNING method only work in `development mode`
57
75
  */
58
- export var configure = function (_a) {
59
- var warning = _a.warning, warningFunction = _a.warningFunction;
60
- if (warning !== undefined) {
61
- rcConfiguration.WARNING_IGNORE = !warning;
62
- }
63
- if (warningFunction !== undefined) {
64
- rcConfiguration.WARNING_FUNCTION = warningFunction;
76
+ export var configure = function (options) {
77
+ if (process.env.NODE_ENV !== 'production') {
78
+ var warning = options.warning, warningFunction = options.warningFunction;
79
+ if (warning !== undefined) {
80
+ rcConfiguration.WARNING_IGNORE = !warning;
81
+ }
82
+ if (warningFunction !== undefined) {
83
+ rcConfiguration.WARNING_FUNCTION = warningFunction;
84
+ }
65
85
  }
66
86
  };
67
87
  export { rcConfiguration };
@@ -17,7 +17,7 @@ import { useResultRef } from '../useResultRef';
17
17
  *
18
18
  * click();
19
19
  * ```
20
- * @see stories {@link https://develop-rcui-int.fiji.gliprc.com/?path=/story/%F0%9F%94%A7-foundation-hooks-useaudio--simple-announcer 🔧-foundation-hooks-useaudio--simple-announcer}
20
+ * @see stories {@link https://ringcentral.github.io/juno/?path=/story/%F0%9F%94%A7-foundation-hooks-useaudio--simple-announcer 🔧-foundation-hooks-useaudio--simple-announcer}
21
21
  * @see {@link https://chromium-review.googlesource.com/c/chromium/src/+/2816118}
22
22
  */
23
23
  export var useAudio = function (init) {
@@ -14,13 +14,16 @@ import { useResultRef } from '../useResultRef';
14
14
  export var getResizeObserver = function (callback, externalWindow) {
15
15
  if (externalWindow) {
16
16
  if ((externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow['ResizeObserver']) === undefined) {
17
- var message = "window.ResizeObserver is not a constructor,\n should load polyfill script from 'foundation/polyfill/resize-observer-polyfill/ResizeObserver.global.js' or other CDN polyfill on render window.";
18
- logInDev({
19
- component: 'useResizeObserver',
20
- level: 'error',
21
- message: message,
22
- });
23
- throw Error(message);
17
+ if (process.env.NODE_ENV !== 'production') {
18
+ var message = "window.ResizeObserver is not a constructor,\n should load polyfill script from 'foundation/polyfill/resize-observer-polyfill/ResizeObserver.global.js' or other CDN polyfill on render window.";
19
+ logInDev({
20
+ component: 'useResizeObserver',
21
+ level: 'error',
22
+ message: message,
23
+ });
24
+ throw Error(message);
25
+ }
26
+ throw Error('window.ResizeObserver not defined');
24
27
  }
25
28
  return new externalWindow['ResizeObserver'](callback);
26
29
  }
@@ -25,10 +25,12 @@ export function doAlpha(color, opacity, theme) {
25
25
  return MuiAlpha(color, +alpha.toFixed(2));
26
26
  }
27
27
  catch (error) {
28
- logInDev({
29
- component: 'setOpacity',
30
- message: 'your color pass into setOpacity is error color, check your color again, please',
31
- });
28
+ if (process.env.NODE_ENV !== 'production') {
29
+ logInDev({
30
+ component: 'setOpacity',
31
+ message: 'your color pass into setOpacity is error color, check your color again, please',
32
+ });
33
+ }
32
34
  return color;
33
35
  }
34
36
  }
@@ -3,7 +3,7 @@ import { combineProps } from '../utils/combineProps';
3
3
  /**
4
4
  * use combine props from default theme props
5
5
  *
6
- * @see stories {@link https://develop-rcui-int.fiji.gliprc.com/?path=/story/api-reference-hooks-usethemeprops--page 🔧-foundation-hooks-usethemeprops--use-theme-props-example}
6
+ * @see stories {@link https://ringcentral.github.io/juno/?path=/story/api-reference-hooks-usethemeprops--page 🔧-foundation-hooks-usethemeprops--use-theme-props-example}
7
7
  */
8
8
  export function useThemeProps(_a) {
9
9
  var props = _a.props, name = _a.name;
@@ -27,13 +27,15 @@ function clearReactReferencesInNode(node) {
27
27
  }
28
28
  }
29
29
  catch (error) {
30
- logInDev({
31
- component: 'clearReactReferencesInNode',
32
- message: "trigger clearReactReferencesInNode fail",
33
- }, function () {
34
- // eslint-disable-next-line no-console
35
- console.log(error);
36
- });
30
+ if (process.env.NODE_ENV !== 'production') {
31
+ logInDev({
32
+ component: 'clearReactReferencesInNode',
33
+ message: "trigger clearReactReferencesInNode fail",
34
+ }, function () {
35
+ // eslint-disable-next-line no-console
36
+ console.log(error);
37
+ });
38
+ }
37
39
  }
38
40
  }
39
41
  export { clearReactReferencesInNode };
@@ -1,4 +1,4 @@
1
- import { hasValue as MuiHasValue, isFilled as MuiIsFilled, } from '@material-ui/core/InputBase/utils';
1
+ import { hasValue as MuiHasValue, isFilled as MuiIsFilled, } from '@material-ui/core/InputBase/utils'; /* ts-import-sorter: disable */
2
2
  /**
3
3
  * Copy from Mui
4
4
  * @see https://facebook.github.io/react/docs/forms.html#controlled-components
@@ -8,7 +8,6 @@ export * from './getScrollbarSize';
8
8
  export * from './hasValue';
9
9
  export * from './isRcElement';
10
10
  export * from './isRef';
11
- export * from './isShowJunoWarning';
12
11
  export * from './isUrl';
13
12
  export * from './omit';
14
13
  export * from './outerSize';
@@ -1,2 +0,0 @@
1
- import { rcConfiguration } from '../config';
2
- export var isShowJunoWarning = !rcConfiguration.WARNING_IGNORE && process.env.NODE_ENV !== 'production';
@@ -1,17 +1,18 @@
1
- import { __assign, __read, __spread } from "tslib";
2
- import React, { forwardRef, useEffect, } from 'react';
1
+ import { __read, __spread } from "tslib";
2
+ import { useEffect } from 'react';
3
3
  import { rcConfiguration } from '../config';
4
- import { isShowJunoWarning } from './isShowJunoWarning';
5
4
  function showDeprecated(_a) {
6
5
  var component = _a.component, target = _a.target, time = _a.time, comment = _a.comment, message = _a.message, level = _a.level;
6
+ var _b;
7
7
  var showMessage = message ||
8
8
  "props => (" + target + ") be deprecated, that will be remove in " + time + " release" + (comment ? ", " + comment : '');
9
- rcConfiguration.WARNING_FUNCTION("JUNO [" + component + "]: " + showMessage, {
9
+ (_b = rcConfiguration.WARNING_FUNCTION) === null || _b === void 0 ? void 0 : _b.call(rcConfiguration, "JUNO [" + component + "]: " + showMessage, {
10
10
  level: level,
11
11
  });
12
12
  }
13
13
  export function logInDev(args, cb) {
14
- if (isShowJunoWarning) {
14
+ if (process.env.NODE_ENV !== 'production' &&
15
+ !rcConfiguration.WARNING_IGNORE) {
15
16
  showDeprecated(args);
16
17
  cb === null || cb === void 0 ? void 0 : cb();
17
18
  }
@@ -21,7 +22,8 @@ export var useDeprecatedLog = function () {
21
22
  for (var _i = 0; _i < arguments.length; _i++) {
22
23
  args[_i] = arguments[_i];
23
24
  }
24
- if (isShowJunoWarning) {
25
+ if (process.env.NODE_ENV !== 'production' &&
26
+ !rcConfiguration.WARNING_IGNORE) {
25
27
  // eslint-disable-next-line react-hooks/rules-of-hooks
26
28
  useEffect(function () {
27
29
  logInDev.apply(void 0, __spread(args));
@@ -29,12 +31,11 @@ export var useDeprecatedLog = function () {
29
31
  }, []);
30
32
  }
31
33
  };
32
- export function withDeprecatedCheck(Component, depreciates, source) {
33
- if (!isShowJunoWarning) {
34
- return Component;
35
- }
34
+ export function useDeprecatedCheck(Component, props, depreciates, source) {
36
35
  var name = Component.displayName || source || '';
37
- return forwardRef(function (props, ref) {
36
+ if (process.env.NODE_ENV !== 'production' &&
37
+ !rcConfiguration.WARNING_IGNORE) {
38
+ // eslint-disable-next-line react-hooks/rules-of-hooks
38
39
  useEffect(function () {
39
40
  depreciates.forEach(function (_a) {
40
41
  var prop = _a.prop, comment = _a.comment, time = _a.time;
@@ -50,8 +51,6 @@ export function withDeprecatedCheck(Component, depreciates, source) {
50
51
  });
51
52
  }
52
53
  });
53
- // eslint-disable-next-line react-hooks/exhaustive-deps
54
- }, []);
55
- return React.createElement(Component, __assign({}, props, { ref: ref }));
56
- });
54
+ });
55
+ }
57
56
  }
@@ -1,20 +1,28 @@
1
1
  import { ShowDeprecatedArgs } from './utils';
2
- declare type WarningFunctionType = (
2
+ declare type WarningFunctionType = ((
3
3
  /** warning message */
4
4
  message: string,
5
5
  /** addition options with that warning */
6
- options?: Pick<ShowDeprecatedArgs, 'level'>) => void;
7
- declare class RcConfig {
8
- private _WARNING_IGNORE;
9
- private _WARNING_FUNCTION;
10
- constructor();
11
- set WARNING_IGNORE(value: boolean);
12
- get WARNING_IGNORE(): boolean;
13
- set WARNING_FUNCTION(func: WarningFunctionType);
14
- get WARNING_FUNCTION(): WarningFunctionType;
6
+ options?: Pick<ShowDeprecatedArgs, 'level'>) => void) | undefined;
7
+ interface RcConfigurationType {
8
+ /** is ignore all warning show from juno */
9
+ WARNING_IGNORE: boolean;
10
+ WARNING_FUNCTION: WarningFunctionType;
15
11
  }
16
- /** config instance */
17
- declare const rcConfiguration: RcConfig;
12
+ /**
13
+ * config global setting
14
+ *
15
+ * ```ts
16
+ * configure({
17
+ * warning: false
18
+ * })
19
+ * ```
20
+ * ## WARNING related method and only work in `development mode`
21
+ *
22
+ * `WARNING_IGNORE`: only work in `development mode`
23
+ * `WARNING_FUNCTION` only work in `development mode`
24
+ */
25
+ declare let rcConfiguration: RcConfigurationType;
18
26
  declare type RcConfigure = {
19
27
  /** is show warning message in development */
20
28
  warning?: boolean;
@@ -23,7 +31,9 @@ declare type RcConfigure = {
23
31
  };
24
32
  /**
25
33
  * set config with Juno
34
+ *
35
+ * ## WARNING method only work in `development mode`
26
36
  */
27
- export declare const configure: ({ warning, warningFunction }: RcConfigure) => void;
37
+ export declare const configure: (options: RcConfigure) => void;
28
38
  export { rcConfiguration };
29
39
  export type { WarningFunctionType };