@ringcentral/juno 2.0.0-rc.0 → 2.0.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.
- package/README.md +2 -1
- package/components/Avatar/Avatar.js +36 -32
- package/components/Buttons/Button/Button.js +11 -7
- package/components/Buttons/IconButton/IconButton.js +5 -3
- package/components/Buttons/SplitButton/SplitButton.js +2 -1
- package/components/DetachedWindow/DetachedWindow.d.ts +1 -7
- package/components/DetachedWindow/DetachedWindow.js +8 -6
- package/components/Dialer/DialPad/utils/useKeyAudio.js +4 -4
- package/components/Dialog/Dialog.js +11 -7
- package/components/Downshift/Downshift.js +115 -108
- package/components/Downshift/utils/useDownshiftError.js +2 -1
- package/components/Forms/Checkbox/Checkbox.js +11 -7
- package/components/Forms/Picker/DatePicker/DatePicker.js +21 -17
- package/components/Forms/TextField/TextField.js +26 -22
- package/components/Icon/Icon.js +41 -37
- package/components/Icon/utils/IconUtils.js +24 -16
- package/components/Link/Link.js +16 -12
- package/components/List/ListItem/ListItem.js +16 -12
- package/components/List/ListItemText/ListItemText.js +21 -17
- package/components/Loading/Loading.js +6 -4
- package/components/Menu/MenuItem/MenuItem.js +6 -4
- package/components/PortalHost/PortalManager/PortalManager.js +24 -16
- package/components/Snackbar/SnackbarContent/SnackbarContent.js +11 -7
- package/components/Tag/Tag.js +11 -7
- package/components/Text/Text.js +1 -2
- package/components/Text/TextWithEllipsis.js +7 -4
- package/components/TextWithHighlight/TextWithHighlight.js +7 -4
- package/components/TextWithLink/TextWithLink.js +7 -4
- package/components/TextWithTooltip/TextWithTooltip.js +7 -4
- package/components/Thumbnail/Thumbnail.js +16 -12
- package/components/Tooltip/Tooltip.js +17 -11
- package/components/VirtualizedMenu/VirtualizedMenuList.js +8 -10
- package/es6/README.md +2 -1
- package/es6/components/Avatar/Avatar.js +37 -33
- package/es6/components/Buttons/Button/Button.js +12 -8
- package/es6/components/Buttons/IconButton/IconButton.js +6 -4
- package/es6/components/Buttons/SplitButton/SplitButton.js +2 -1
- package/es6/components/DetachedWindow/DetachedWindow.js +8 -6
- package/es6/components/Dialer/DialPad/utils/useKeyAudio.js +4 -4
- package/es6/components/Dialog/Dialog.js +12 -8
- package/es6/components/Downshift/Downshift.js +116 -109
- package/es6/components/Downshift/utils/useDownshiftError.js +3 -2
- package/es6/components/Forms/Checkbox/Checkbox.js +12 -8
- package/es6/components/Forms/Picker/DatePicker/DatePicker.js +22 -18
- package/es6/components/Forms/TextField/TextField.js +27 -23
- package/es6/components/Icon/Icon.js +42 -38
- package/es6/components/Icon/utils/IconUtils.js +24 -16
- package/es6/components/Link/Link.js +17 -13
- package/es6/components/List/ListItem/ListItem.js +17 -13
- package/es6/components/List/ListItemText/ListItemText.js +22 -18
- package/es6/components/Loading/Loading.js +6 -4
- package/es6/components/Menu/MenuItem/MenuItem.js +6 -4
- package/es6/components/PortalHost/PortalManager/PortalManager.js +24 -16
- package/es6/components/Snackbar/SnackbarContent/SnackbarContent.js +12 -8
- package/es6/components/Tag/Tag.js +12 -8
- package/es6/components/Text/Text.js +1 -2
- package/es6/components/Text/TextWithEllipsis.js +7 -4
- package/es6/components/TextWithHighlight/TextWithHighlight.js +7 -4
- package/es6/components/TextWithLink/TextWithLink.js +7 -4
- package/es6/components/TextWithTooltip/TextWithTooltip.js +7 -4
- package/es6/components/Thumbnail/Thumbnail.js +17 -13
- package/es6/components/Tooltip/Tooltip.js +18 -12
- package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +9 -11
- package/es6/foundation/config.js +77 -57
- package/es6/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
- package/es6/foundation/styles/opacity.js +6 -4
- package/es6/foundation/utils/clearReactReferencesInNode.js +9 -7
- package/es6/foundation/utils/hasValue.js +1 -1
- package/es6/foundation/utils/index.js +0 -1
- package/es6/foundation/utils/isShowJunoWarning.js +0 -2
- package/es6/foundation/utils/withDeprecatedCheck.js +14 -15
- package/foundation/config.d.ts +23 -13
- package/foundation/config.js +78 -58
- package/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
- package/foundation/styles/opacity.js +6 -4
- package/foundation/utils/clearReactReferencesInNode.js +9 -7
- package/foundation/utils/hasValue.js +1 -1
- package/foundation/utils/index.d.ts +0 -1
- package/foundation/utils/index.js +0 -1
- package/foundation/utils/isShowJunoWarning.d.ts +0 -1
- package/foundation/utils/isShowJunoWarning.js +0 -4
- package/foundation/utils/withDeprecatedCheck.d.ts +2 -2
- package/foundation/utils/withDeprecatedCheck.js +14 -15
- package/package.json +5 -5
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
2
|
import React, { forwardRef, memo } from 'react';
|
|
3
|
-
import { styled,
|
|
3
|
+
import { styled, useDeprecatedCheck, useThemeProps, } from '../../foundation';
|
|
4
4
|
import { TagStyle } from './styles';
|
|
5
5
|
var _RcTag = memo(forwardRef(function (inProps, ref) {
|
|
6
6
|
var props = useThemeProps({ props: inProps, name: 'RcTag' });
|
|
7
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
9
|
+
useDeprecatedCheck(RcTag, props, [
|
|
10
|
+
{
|
|
11
|
+
prop: 'content',
|
|
12
|
+
comment: 'you should replace with children',
|
|
13
|
+
time: '2021-1',
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
7
17
|
var color = props.color, children = props.children, content = props.content, textColor = props.textColor, borderColor = props.borderColor, radius = props.radius, rest = __rest(props, ["color", "children", "content", "textColor", "borderColor", "radius"]);
|
|
8
18
|
return (React.createElement("span", __assign({}, rest, { ref: ref }), content || children));
|
|
9
19
|
}));
|
|
10
|
-
var RcTag = styled(
|
|
11
|
-
{
|
|
12
|
-
prop: 'content',
|
|
13
|
-
comment: 'you should replace with children',
|
|
14
|
-
time: '2021-1',
|
|
15
|
-
},
|
|
16
|
-
]))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TagStyle);
|
|
20
|
+
var RcTag = styled(_RcTag)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TagStyle);
|
|
17
21
|
RcTag.defaultProps = {
|
|
18
22
|
color: 'highlight.b03',
|
|
19
23
|
textColor: 'neutral.f01',
|
|
@@ -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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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,
|
|
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(
|
|
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,
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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(
|
|
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,
|
|
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 (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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) {
|
package/es6/foundation/config.js
CHANGED
|
@@ -1,67 +1,87 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
var JUNO_WARNING_IGNORE_KEY = '__JUNO_WARNING_IGNORE__';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
console
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 };
|
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
}
|
|
@@ -27,13 +27,15 @@ function clearReactReferencesInNode(node) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
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 (
|
|
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 (
|
|
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
|
|
33
|
-
if (!isShowJunoWarning) {
|
|
34
|
-
return Component;
|
|
35
|
-
}
|
|
34
|
+
export function useDeprecatedCheck(Component, props, depreciates, source) {
|
|
36
35
|
var name = Component.displayName || source || '';
|
|
37
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
return React.createElement(Component, __assign({}, props, { ref: ref }));
|
|
56
|
-
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
57
56
|
}
|
package/foundation/config.d.ts
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
/**
|
|
17
|
-
|
|
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: (
|
|
37
|
+
export declare const configure: (options: RcConfigure) => void;
|
|
28
38
|
export { rcConfiguration };
|
|
29
39
|
export type { WarningFunctionType };
|