@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.
Files changed (84) hide show
  1. package/README.md +2 -1
  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 +115 -108
  11. package/components/Downshift/utils/useDownshiftError.js +2 -1
  12. package/components/Forms/Checkbox/Checkbox.js +11 -7
  13. package/components/Forms/Picker/DatePicker/DatePicker.js +21 -17
  14. package/components/Forms/TextField/TextField.js +26 -22
  15. package/components/Icon/Icon.js +41 -37
  16. package/components/Icon/utils/IconUtils.js +24 -16
  17. package/components/Link/Link.js +16 -12
  18. package/components/List/ListItem/ListItem.js +16 -12
  19. package/components/List/ListItemText/ListItemText.js +21 -17
  20. package/components/Loading/Loading.js +6 -4
  21. package/components/Menu/MenuItem/MenuItem.js +6 -4
  22. package/components/PortalHost/PortalManager/PortalManager.js +24 -16
  23. package/components/Snackbar/SnackbarContent/SnackbarContent.js +11 -7
  24. package/components/Tag/Tag.js +11 -7
  25. package/components/Text/Text.js +1 -2
  26. package/components/Text/TextWithEllipsis.js +7 -4
  27. package/components/TextWithHighlight/TextWithHighlight.js +7 -4
  28. package/components/TextWithLink/TextWithLink.js +7 -4
  29. package/components/TextWithTooltip/TextWithTooltip.js +7 -4
  30. package/components/Thumbnail/Thumbnail.js +16 -12
  31. package/components/Tooltip/Tooltip.js +17 -11
  32. package/components/VirtualizedMenu/VirtualizedMenuList.js +8 -10
  33. package/es6/README.md +2 -1
  34. package/es6/components/Avatar/Avatar.js +37 -33
  35. package/es6/components/Buttons/Button/Button.js +12 -8
  36. package/es6/components/Buttons/IconButton/IconButton.js +6 -4
  37. package/es6/components/Buttons/SplitButton/SplitButton.js +2 -1
  38. package/es6/components/DetachedWindow/DetachedWindow.js +8 -6
  39. package/es6/components/Dialer/DialPad/utils/useKeyAudio.js +4 -4
  40. package/es6/components/Dialog/Dialog.js +12 -8
  41. package/es6/components/Downshift/Downshift.js +116 -109
  42. package/es6/components/Downshift/utils/useDownshiftError.js +3 -2
  43. package/es6/components/Forms/Checkbox/Checkbox.js +12 -8
  44. package/es6/components/Forms/Picker/DatePicker/DatePicker.js +22 -18
  45. package/es6/components/Forms/TextField/TextField.js +27 -23
  46. package/es6/components/Icon/Icon.js +42 -38
  47. package/es6/components/Icon/utils/IconUtils.js +24 -16
  48. package/es6/components/Link/Link.js +17 -13
  49. package/es6/components/List/ListItem/ListItem.js +17 -13
  50. package/es6/components/List/ListItemText/ListItemText.js +22 -18
  51. package/es6/components/Loading/Loading.js +6 -4
  52. package/es6/components/Menu/MenuItem/MenuItem.js +6 -4
  53. package/es6/components/PortalHost/PortalManager/PortalManager.js +24 -16
  54. package/es6/components/Snackbar/SnackbarContent/SnackbarContent.js +12 -8
  55. package/es6/components/Tag/Tag.js +12 -8
  56. package/es6/components/Text/Text.js +1 -2
  57. package/es6/components/Text/TextWithEllipsis.js +7 -4
  58. package/es6/components/TextWithHighlight/TextWithHighlight.js +7 -4
  59. package/es6/components/TextWithLink/TextWithLink.js +7 -4
  60. package/es6/components/TextWithTooltip/TextWithTooltip.js +7 -4
  61. package/es6/components/Thumbnail/Thumbnail.js +17 -13
  62. package/es6/components/Tooltip/Tooltip.js +18 -12
  63. package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +9 -11
  64. package/es6/foundation/config.js +77 -57
  65. package/es6/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
  66. package/es6/foundation/styles/opacity.js +6 -4
  67. package/es6/foundation/utils/clearReactReferencesInNode.js +9 -7
  68. package/es6/foundation/utils/hasValue.js +1 -1
  69. package/es6/foundation/utils/index.js +0 -1
  70. package/es6/foundation/utils/isShowJunoWarning.js +0 -2
  71. package/es6/foundation/utils/withDeprecatedCheck.js +14 -15
  72. package/foundation/config.d.ts +23 -13
  73. package/foundation/config.js +78 -58
  74. package/foundation/hooks/useResizeObserver/useResizeObserver.js +10 -7
  75. package/foundation/styles/opacity.js +6 -4
  76. package/foundation/utils/clearReactReferencesInNode.js +9 -7
  77. package/foundation/utils/hasValue.js +1 -1
  78. package/foundation/utils/index.d.ts +0 -1
  79. package/foundation/utils/index.js +0 -1
  80. package/foundation/utils/isShowJunoWarning.d.ts +0 -1
  81. package/foundation/utils/isShowJunoWarning.js +0 -4
  82. package/foundation/utils/withDeprecatedCheck.d.ts +2 -2
  83. package/foundation/utils/withDeprecatedCheck.js +14 -15
  84. package/package.json +5 -5
@@ -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
- var RcConfig = /** @class */ (function () {
6
- function RcConfig() {
7
- var _a;
8
- this._WARNING_IGNORE = false;
9
- this._WARNING_FUNCTION = function (message, options) {
10
- console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
11
- };
12
- if (typeof window !== 'undefined') {
13
- // SSR support
14
- // * get value once when init
15
- this._WARNING_IGNORE =
16
- ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
17
- // * also provide user to set variable from window
18
- window.__JUNO__ = this;
19
- }
20
- }
21
- Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
22
- get: function () {
23
- return this._WARNING_IGNORE;
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
- if (value) {
28
- console.log('---------------- [Juno] ----------------');
29
- console.log("Don't recommended you close it, we should avoid use any deprecated props or methods.");
30
- console.log('---------------- [Juno] ----------------');
31
- }
32
- this._WARNING_IGNORE = !!value;
33
- (_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);
34
- },
35
- enumerable: true,
36
- configurable: true
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
- else {
47
- console.warn('[Juno] config warningFunction is not a function.');
48
- }
49
- },
50
- enumerable: true,
51
- configurable: true
52
- });
53
- return RcConfig;
54
- }());
55
- /** config instance */
56
- var rcConfiguration = new RcConfig();
57
- exports.rcConfiguration = rcConfiguration;
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 (_a) {
62
- var warning = _a.warning, warningFunction = _a.warningFunction;
63
- if (warning !== undefined) {
64
- rcConfiguration.WARNING_IGNORE = !warning;
65
- }
66
- if (warningFunction !== undefined) {
67
- rcConfiguration.WARNING_FUNCTION = warningFunction;
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
- 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.";
20
- utils_1.logInDev({
21
- component: 'useResizeObserver',
22
- level: 'error',
23
- message: message,
24
- });
25
- throw Error(message);
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
- utils_1.logInDev({
32
- component: 'setOpacity',
33
- message: 'your color pass into setOpacity is error color, check your color again, please',
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
- withDeprecatedCheck_1.logInDev({
33
- component: 'clearReactReferencesInNode',
34
- message: "trigger clearReactReferencesInNode fail",
35
- }, function () {
36
- // eslint-disable-next-line no-console
37
- console.log(error);
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
@@ -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';
@@ -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,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var config_1 = require("../config");
4
- exports.isShowJunoWarning = !config_1.rcConfiguration.WARNING_IGNORE && process.env.NODE_ENV !== 'production';
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps, ComponentType } from 'react';
2
- declare type WithDeprecatedCheckArgs<TKey> = {
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 withDeprecatedCheck<T extends ComponentType<any>, K extends keyof ComponentProps<T>>(Component: T, depreciates: WithDeprecatedCheckArgs<K>[], source?: string): T;
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 = tslib_1.__importStar(require("react"));
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 (isShowJunoWarning_1.isShowJunoWarning) {
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 (isShowJunoWarning_1.isShowJunoWarning) {
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 withDeprecatedCheck(Component, depreciates, source) {
36
- if (!isShowJunoWarning_1.isShowJunoWarning) {
37
- return Component;
38
- }
37
+ function useDeprecatedCheck(Component, props, depreciates, source) {
39
38
  var name = Component.displayName || source || '';
40
- return react_1.forwardRef(function (props, ref) {
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
- // eslint-disable-next-line react-hooks/exhaustive-deps
57
- }, []);
58
- return react_1.default.createElement(Component, tslib_1.__assign({}, props, { ref: ref }));
59
- });
57
+ });
58
+ }
60
59
  }
61
- exports.withDeprecatedCheck = withDeprecatedCheck;
60
+ exports.useDeprecatedCheck = useDeprecatedCheck;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "bugs": {
7
- "url": "https://github.com/ringcentral/juno/issues"
7
+ "url": "https://git.ringcentral.com/RCUI/rcui/issues"
8
8
  },
9
- "homepage": "https://github.com/ringcentral/juno#readme",
9
+ "homepage": "https://git.ringcentral.com/RCUI/rcui#readme",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/ringcentral/juno.git"
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
+ }