@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
package/foundation/config.js
CHANGED
|
@@ -2,68 +2,88 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
4
|
var JUNO_WARNING_IGNORE_KEY = '__JUNO_WARNING_IGNORE__';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
set: function (value) {
|
|
5
|
+
// * use that way to avoid that code be exist in production code base
|
|
6
|
+
/**
|
|
7
|
+
* config global setting
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* configure({
|
|
11
|
+
* warning: false
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
* ## WARNING related method and only work in `development mode`
|
|
15
|
+
*
|
|
16
|
+
* `WARNING_IGNORE`: only work in `development mode`
|
|
17
|
+
* `WARNING_FUNCTION` only work in `development mode`
|
|
18
|
+
*/
|
|
19
|
+
var rcConfiguration = {};
|
|
20
|
+
exports.rcConfiguration = rcConfiguration;
|
|
21
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
+
var RcConfig = /** @class */ (function () {
|
|
23
|
+
function RcConfig() {
|
|
26
24
|
var _a;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Object.defineProperty(RcConfig.prototype, "WARNING_FUNCTION", {
|
|
39
|
-
get: function () {
|
|
40
|
-
return this._WARNING_FUNCTION;
|
|
41
|
-
},
|
|
42
|
-
set: function (func) {
|
|
43
|
-
if (typeof func === 'function') {
|
|
44
|
-
this._WARNING_FUNCTION = func;
|
|
25
|
+
this._WARNING_IGNORE = false;
|
|
26
|
+
this._WARNING_FUNCTION = function (message, options) {
|
|
27
|
+
console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
|
|
28
|
+
};
|
|
29
|
+
if (typeof window !== 'undefined') {
|
|
30
|
+
// SSR support
|
|
31
|
+
// * get value once when init
|
|
32
|
+
this._WARNING_IGNORE =
|
|
33
|
+
((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
|
|
34
|
+
// * also provide user to set variable from window
|
|
35
|
+
window.__JUNO__ = this;
|
|
45
36
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
|
|
39
|
+
get: function () {
|
|
40
|
+
return this._WARNING_IGNORE;
|
|
41
|
+
},
|
|
42
|
+
set: function (value) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (value) {
|
|
45
|
+
console.log('---------------- [Juno] ----------------');
|
|
46
|
+
console.log("Don't recommended you close it, we should avoid use any deprecated props or methods.");
|
|
47
|
+
console.log('---------------- [Juno] ----------------');
|
|
48
|
+
}
|
|
49
|
+
this._WARNING_IGNORE = !!value;
|
|
50
|
+
(_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);
|
|
51
|
+
},
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(RcConfig.prototype, "WARNING_FUNCTION", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._WARNING_FUNCTION;
|
|
58
|
+
},
|
|
59
|
+
set: function (func) {
|
|
60
|
+
if (typeof func === 'function') {
|
|
61
|
+
this._WARNING_FUNCTION = func;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.warn('[Juno] config warningFunction is not a function.');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
return RcConfig;
|
|
71
|
+
}());
|
|
72
|
+
exports.rcConfiguration = rcConfiguration = new RcConfig();
|
|
73
|
+
}
|
|
58
74
|
/**
|
|
59
75
|
* set config with Juno
|
|
76
|
+
*
|
|
77
|
+
* ## WARNING method only work in `development mode`
|
|
60
78
|
*/
|
|
61
|
-
exports.configure = function (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
exports.configure = function (options) {
|
|
80
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
81
|
+
var warning = options.warning, warningFunction = options.warningFunction;
|
|
82
|
+
if (warning !== undefined) {
|
|
83
|
+
rcConfiguration.WARNING_IGNORE = !warning;
|
|
84
|
+
}
|
|
85
|
+
if (warningFunction !== undefined) {
|
|
86
|
+
rcConfiguration.WARNING_FUNCTION = warningFunction;
|
|
87
|
+
}
|
|
68
88
|
}
|
|
69
89
|
};
|
|
@@ -16,13 +16,16 @@ var useResultRef_1 = require("../useResultRef");
|
|
|
16
16
|
exports.getResizeObserver = function (callback, externalWindow) {
|
|
17
17
|
if (externalWindow) {
|
|
18
18
|
if ((externalWindow === null || externalWindow === void 0 ? void 0 : externalWindow['ResizeObserver']) === undefined) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
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.";
|
|
21
|
+
utils_1.logInDev({
|
|
22
|
+
component: 'useResizeObserver',
|
|
23
|
+
level: 'error',
|
|
24
|
+
message: message,
|
|
25
|
+
});
|
|
26
|
+
throw Error(message);
|
|
27
|
+
}
|
|
28
|
+
throw Error('window.ResizeObserver not defined');
|
|
26
29
|
}
|
|
27
30
|
return new externalWindow['ResizeObserver'](callback);
|
|
28
31
|
}
|
|
@@ -28,10 +28,12 @@ function doAlpha(color, opacity, theme) {
|
|
|
28
28
|
return styles_1.alpha(color, +alpha.toFixed(2));
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
+
utils_1.logInDev({
|
|
33
|
+
component: 'setOpacity',
|
|
34
|
+
message: 'your color pass into setOpacity is error color, check your color again, please',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
35
37
|
return color;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -29,13 +29,15 @@ function clearReactReferencesInNode(node) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
33
|
+
withDeprecatedCheck_1.logInDev({
|
|
34
|
+
component: 'clearReactReferencesInNode',
|
|
35
|
+
message: "trigger clearReactReferencesInNode fail",
|
|
36
|
+
}, function () {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log(error);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
exports.clearReactReferencesInNode = clearReactReferencesInNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var utils_1 = require("@material-ui/core/InputBase/utils");
|
|
3
|
+
var utils_1 = require("@material-ui/core/InputBase/utils"); /* ts-import-sorter: disable */
|
|
4
4
|
/**
|
|
5
5
|
* Copy from Mui
|
|
6
6
|
* @see https://facebook.github.io/react/docs/forms.html#controlled-components
|
|
@@ -11,7 +11,6 @@ tslib_1.__exportStar(require("./getScrollbarSize"), exports);
|
|
|
11
11
|
tslib_1.__exportStar(require("./hasValue"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./isRcElement"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./isRef"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./isShowJunoWarning"), exports);
|
|
15
14
|
tslib_1.__exportStar(require("./isUrl"), exports);
|
|
16
15
|
tslib_1.__exportStar(require("./omit"), exports);
|
|
17
16
|
tslib_1.__exportStar(require("./outerSize"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isShowJunoWarning: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ComponentType } from 'react';
|
|
2
|
-
declare type
|
|
2
|
+
declare type UseDeprecatedCheckArgs<TKey> = {
|
|
3
3
|
prop: TKey;
|
|
4
4
|
comment?: string;
|
|
5
5
|
time: string;
|
|
@@ -18,5 +18,5 @@ export declare type ShowDeprecatedArgs = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare function logInDev(args: ShowDeprecatedArgs, cb?: Function): void;
|
|
20
20
|
export declare const useDeprecatedLog: (args: ShowDeprecatedArgs, cb?: Function | undefined) => void;
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function useDeprecatedCheck<T extends ComponentType<any>, K extends keyof ComponentProps<T>>(Component: T, props: any, depreciates: UseDeprecatedCheckArgs<K>[], source?: string): void;
|
|
22
22
|
export {};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var react_1 =
|
|
4
|
+
var react_1 = require("react");
|
|
5
5
|
var config_1 = require("../config");
|
|
6
|
-
var isShowJunoWarning_1 = require("./isShowJunoWarning");
|
|
7
6
|
function showDeprecated(_a) {
|
|
8
7
|
var component = _a.component, target = _a.target, time = _a.time, comment = _a.comment, message = _a.message, level = _a.level;
|
|
8
|
+
var _b;
|
|
9
9
|
var showMessage = message ||
|
|
10
10
|
"props => (" + target + ") be deprecated, that will be remove in " + time + " release" + (comment ? ", " + comment : '');
|
|
11
|
-
config_1.rcConfiguration.WARNING_FUNCTION("JUNO [" + component + "]: " + showMessage, {
|
|
11
|
+
(_b = config_1.rcConfiguration.WARNING_FUNCTION) === null || _b === void 0 ? void 0 : _b.call(config_1.rcConfiguration, "JUNO [" + component + "]: " + showMessage, {
|
|
12
12
|
level: level,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function logInDev(args, cb) {
|
|
16
|
-
if (
|
|
16
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
17
|
+
!config_1.rcConfiguration.WARNING_IGNORE) {
|
|
17
18
|
showDeprecated(args);
|
|
18
19
|
cb === null || cb === void 0 ? void 0 : cb();
|
|
19
20
|
}
|
|
@@ -24,7 +25,8 @@ exports.useDeprecatedLog = function () {
|
|
|
24
25
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
26
|
args[_i] = arguments[_i];
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
29
|
+
!config_1.rcConfiguration.WARNING_IGNORE) {
|
|
28
30
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
29
31
|
react_1.useEffect(function () {
|
|
30
32
|
logInDev.apply(void 0, tslib_1.__spread(args));
|
|
@@ -32,12 +34,11 @@ exports.useDeprecatedLog = function () {
|
|
|
32
34
|
}, []);
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
|
-
function
|
|
36
|
-
if (!isShowJunoWarning_1.isShowJunoWarning) {
|
|
37
|
-
return Component;
|
|
38
|
-
}
|
|
37
|
+
function useDeprecatedCheck(Component, props, depreciates, source) {
|
|
39
38
|
var name = Component.displayName || source || '';
|
|
40
|
-
|
|
39
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
40
|
+
!config_1.rcConfiguration.WARNING_IGNORE) {
|
|
41
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
42
|
react_1.useEffect(function () {
|
|
42
43
|
depreciates.forEach(function (_a) {
|
|
43
44
|
var prop = _a.prop, comment = _a.comment, time = _a.time;
|
|
@@ -53,9 +54,7 @@ function withDeprecatedCheck(Component, depreciates, source) {
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return react_1.default.createElement(Component, tslib_1.__assign({}, props, { ref: ref }));
|
|
59
|
-
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
60
59
|
}
|
|
61
|
-
exports.
|
|
60
|
+
exports.useDeprecatedCheck = useDeprecatedCheck;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ringcentral/juno",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"author": "RingCentral",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://
|
|
7
|
+
"url": "https://git.ringcentral.com/RCUI/rcui/issues"
|
|
8
8
|
},
|
|
9
|
-
"homepage": "https://
|
|
9
|
+
"homepage": "https://git.ringcentral.com/RCUI/rcui#readme",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://
|
|
12
|
+
"url": "https://git.ringcentral.com/RCUI/rcui.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@date-io/moment": "^1.3.11",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"default": "./es6/"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|