@ringcentral/juno 2.2.0 → 2.3.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 (142) hide show
  1. package/README.md +1 -2
  2. package/components/Animations/Highlight/Highlight.d.ts +2 -2
  3. package/components/Downshift/SuggestionList/utils/useSuggestionList.js +1 -2
  4. package/components/Downshift/utils/useDownshift.js +2 -3
  5. package/components/Downshift/utils/useDownshiftTag.js +1 -2
  6. package/components/Forms/Picker/DatePicker/DatePicker.js +10 -11
  7. package/components/Forms/Select/PlainSelect/PlainSelect.js +1 -2
  8. package/components/Table/Table.d.ts +14 -0
  9. package/components/Table/Table.js +17 -0
  10. package/components/Table/TableBody/TableBody.d.ts +8 -0
  11. package/components/Table/TableBody/TableBody.js +14 -0
  12. package/components/Table/TableBody/index.d.ts +1 -0
  13. package/components/Table/TableBody/index.js +4 -0
  14. package/components/Table/TableCell/TableCell.d.ts +27 -0
  15. package/components/Table/TableCell/TableCell.js +39 -0
  16. package/components/Table/TableCell/index.d.ts +1 -0
  17. package/components/Table/TableCell/index.js +4 -0
  18. package/components/Table/TableCell/styles/TableCellStyle.d.ts +3 -0
  19. package/components/Table/TableCell/styles/TableCellStyle.js +16 -0
  20. package/components/Table/TableCell/styles/index.d.ts +1 -0
  21. package/components/Table/TableCell/styles/index.js +4 -0
  22. package/components/Table/TableCell/utils/TableCellUtils.d.ts +1 -0
  23. package/components/Table/TableCell/utils/TableCellUtils.js +4 -0
  24. package/components/Table/TableCell/utils/index.d.ts +1 -0
  25. package/components/Table/TableCell/utils/index.js +4 -0
  26. package/components/Table/TableContainer/TableContainer.d.ts +19 -0
  27. package/components/Table/TableContainer/TableContainer.js +22 -0
  28. package/components/Table/TableContainer/index.d.ts +1 -0
  29. package/components/Table/TableContainer/index.js +4 -0
  30. package/components/Table/TableContainer/styles/TableContainerStyle.d.ts +3 -0
  31. package/components/Table/TableContainer/styles/TableContainerStyle.js +13 -0
  32. package/components/Table/TableContainer/styles/index.d.ts +1 -0
  33. package/components/Table/TableContainer/styles/index.js +4 -0
  34. package/components/Table/TableHead/TableHead.d.ts +8 -0
  35. package/components/Table/TableHead/TableHead.js +14 -0
  36. package/components/Table/TableHead/index.d.ts +1 -0
  37. package/components/Table/TableHead/index.js +4 -0
  38. package/components/Table/TableRow/TableRow.d.ts +15 -0
  39. package/components/Table/TableRow/TableRow.js +20 -0
  40. package/components/Table/TableRow/index.d.ts +1 -0
  41. package/components/Table/TableRow/index.js +4 -0
  42. package/components/Table/TableRow/styles/TableRowStyle.d.ts +3 -0
  43. package/components/Table/TableRow/styles/TableRowStyle.js +9 -0
  44. package/components/Table/TableRow/styles/index.d.ts +1 -0
  45. package/components/Table/TableRow/styles/index.js +4 -0
  46. package/components/Table/TableRow/utils/TableRowUtils.d.ts +1 -0
  47. package/components/Table/TableRow/utils/TableRowUtils.js +4 -0
  48. package/components/Table/TableRow/utils/index.d.ts +1 -0
  49. package/components/Table/TableRow/utils/index.js +4 -0
  50. package/components/Table/context.d.ts +10 -0
  51. package/components/Table/context.js +4 -0
  52. package/components/Table/index.d.ts +8 -0
  53. package/components/Table/index.js +10 -0
  54. package/components/Table/types.d.ts +1 -0
  55. package/components/Table/types.js +2 -0
  56. package/components/Tables/TableHead.d.ts +1 -1
  57. package/components/Tables/TableHead.js +1 -3
  58. package/components/Tables/TableHeadCell.d.ts +1 -1
  59. package/components/Tables/TableHeadCell.js +1 -2
  60. package/components/Tooltip/utils/useTooltipForceHide.js +24 -10
  61. package/components/index.d.ts +1 -1
  62. package/components/index.js +1 -1
  63. package/es6/README.md +1 -2
  64. package/es6/components/Downshift/SuggestionList/utils/useSuggestionList.js +1 -2
  65. package/es6/components/Downshift/utils/useDownshift.js +1 -2
  66. package/es6/components/Downshift/utils/useDownshiftTag.js +1 -2
  67. package/es6/components/Forms/Picker/DatePicker/DatePicker.js +1 -2
  68. package/es6/components/Forms/Select/PlainSelect/PlainSelect.js +1 -2
  69. package/es6/components/Table/Table.js +15 -0
  70. package/es6/components/Table/TableBody/TableBody.js +12 -0
  71. package/es6/components/Table/TableBody/index.js +1 -0
  72. package/es6/components/Table/TableCell/TableCell.js +37 -0
  73. package/es6/components/Table/TableCell/index.js +1 -0
  74. package/es6/components/Table/TableCell/styles/TableCellStyle.js +14 -0
  75. package/es6/components/Table/TableCell/styles/index.js +1 -0
  76. package/es6/components/Table/TableCell/utils/TableCellUtils.js +2 -0
  77. package/es6/components/Table/TableCell/utils/index.js +1 -0
  78. package/es6/components/Table/TableContainer/TableContainer.js +20 -0
  79. package/es6/components/Table/TableContainer/index.js +1 -0
  80. package/es6/components/Table/TableContainer/styles/TableContainerStyle.js +11 -0
  81. package/es6/components/Table/TableContainer/styles/index.js +1 -0
  82. package/es6/components/Table/TableHead/TableHead.js +12 -0
  83. package/es6/components/Table/TableHead/index.js +1 -0
  84. package/es6/components/Table/TableRow/TableRow.js +18 -0
  85. package/es6/components/Table/TableRow/index.js +1 -0
  86. package/es6/components/Table/TableRow/styles/TableRowStyle.js +7 -0
  87. package/es6/components/Table/TableRow/styles/index.js +1 -0
  88. package/es6/components/Table/TableRow/utils/TableRowUtils.js +2 -0
  89. package/es6/components/Table/TableRow/utils/index.js +1 -0
  90. package/es6/components/Table/context.js +2 -0
  91. package/es6/components/Table/index.js +7 -0
  92. package/es6/components/Table/types.js +0 -0
  93. package/es6/components/Tables/TableHead.js +1 -3
  94. package/es6/components/Tables/TableHeadCell.js +2 -3
  95. package/es6/components/Tooltip/utils/useTooltipForceHide.js +25 -11
  96. package/es6/components/index.js +1 -1
  97. package/es6/foundation/hooks/index.js +2 -0
  98. package/es6/foundation/hooks/useControlled/index.js +1 -0
  99. package/es6/foundation/hooks/useControlled/useControlled.js +1 -0
  100. package/es6/foundation/hooks/useEventListener/useEventListener.js +8 -6
  101. package/es6/foundation/hooks/useGlobalListener/index.js +1 -0
  102. package/es6/foundation/hooks/useGlobalListener/useGlobalListener.js +130 -0
  103. package/es6/foundation/hooks/useHiddenTabindex/useHiddenTabindex.js +4 -3
  104. package/es6/foundation/hooks/useLongPress/useLongPress.js +2 -3
  105. package/es6/foundation/hooks/useOverflow/useOverflow.js +18 -15
  106. package/es6/foundation/hooks/useResizeObserver/useResizeObserver.js +4 -4
  107. package/es6/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +8 -5
  108. package/es6/foundation/utils/getRefElement.js +13 -0
  109. package/es6/foundation/utils/index.js +1 -0
  110. package/es6/foundation/utils/removeClassName.js +4 -3
  111. package/es6/foundation/utils/selectionHandler.js +7 -6
  112. package/foundation/hooks/index.d.ts +2 -0
  113. package/foundation/hooks/index.js +2 -0
  114. package/foundation/hooks/useControlled/index.d.ts +1 -0
  115. package/foundation/hooks/useControlled/index.js +4 -0
  116. package/foundation/hooks/useControlled/useControlled.d.ts +1 -0
  117. package/foundation/hooks/useControlled/useControlled.js +4 -0
  118. package/foundation/hooks/useEventListener/useEventListener.d.ts +2 -2
  119. package/foundation/hooks/useEventListener/useEventListener.js +8 -6
  120. package/foundation/hooks/useGlobalListener/index.d.ts +1 -0
  121. package/foundation/hooks/useGlobalListener/index.js +4 -0
  122. package/foundation/hooks/useGlobalListener/useGlobalListener.d.ts +108 -0
  123. package/foundation/hooks/useGlobalListener/useGlobalListener.js +133 -0
  124. package/foundation/hooks/useHiddenTabindex/useHiddenTabindex.d.ts +2 -2
  125. package/foundation/hooks/useHiddenTabindex/useHiddenTabindex.js +4 -3
  126. package/foundation/hooks/useLongPress/useLongPress.js +1 -2
  127. package/foundation/hooks/useOverflow/useOverflow.d.ts +2 -3
  128. package/foundation/hooks/useOverflow/useOverflow.js +18 -15
  129. package/foundation/hooks/useResizeObserver/useResizeObserver.d.ts +2 -3
  130. package/foundation/hooks/useResizeObserver/useResizeObserver.js +3 -3
  131. package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +5 -1
  132. package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +8 -5
  133. package/foundation/theme/theme.type.d.ts +6 -3
  134. package/foundation/utils/getRefElement.d.ts +6 -0
  135. package/foundation/utils/getRefElement.js +15 -0
  136. package/foundation/utils/index.d.ts +1 -0
  137. package/foundation/utils/index.js +1 -0
  138. package/foundation/utils/removeClassName.d.ts +3 -3
  139. package/foundation/utils/removeClassName.js +4 -3
  140. package/foundation/utils/selectionHandler.d.ts +3 -3
  141. package/foundation/utils/selectionHandler.js +7 -6
  142. package/package.json +1 -1
@@ -2,8 +2,7 @@ import { __assign, __read, __rest, __spread } from "tslib";
2
2
  import { useMemo, useRef, useState } from 'react';
3
3
  import isString from 'lodash/isString';
4
4
  import uniqueId from 'lodash/uniqueId';
5
- import { useControlled } from '@material-ui/core/utils';
6
- import { combineProps, useEventCallback, useKeyboardMoveFocus, useRefState, } from '../../../foundation';
5
+ import { combineProps, useControlled, useEventCallback, useKeyboardMoveFocus, useRefState, } from '../../../foundation';
7
6
  import { DEFAULT_GET_OPTION_LABEL, downshiftComponentName, stringArrToRegExp, } from './DownshiftUtils';
8
7
  var DOWNSHIFT_ID_TOKEN = 'rc-chip-';
9
8
  /** @inner inner hook work with useDownshift */
@@ -2,11 +2,10 @@ import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
2
2
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, } from 'react';
3
3
  import moment from 'moment';
4
4
  import MomentUtils from '@date-io/moment';
5
- import { useControlled } from '@material-ui/core/utils';
6
5
  import { MuiPickersUtilsProvider, useUtils as useMuiUtils, } from '@material-ui/pickers';
7
6
  import { findClosestEnabledDate as MuiFindClosestEnabledDate } from '@material-ui/pickers/_helpers/date-utils';
8
7
  import { DateBorder } from '@ringcentral/juno-icon';
9
- import { combineClasses, combineProps, omit, styled, useDeprecatedCheck, useEventCallback, useThemeProps, } from '../../../../foundation';
8
+ import { combineClasses, combineProps, omit, styled, useControlled, useDeprecatedCheck, useEventCallback, useThemeProps, } from '../../../../foundation';
10
9
  import { PickerTextField, } from '../utils';
11
10
  import { Calendar } from './Calendar';
12
11
  import { invalidateDateInRange, RcDatePickerClasses, ScreenReaderProvider, } from './utils';
@@ -1,7 +1,6 @@
1
1
  import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
2
2
  import React, { forwardRef, useMemo, useState } from 'react';
3
- import { useControlled } from '@material-ui/core';
4
- import { combineProps, hasValue, logInDev, styled, } from '../../../../foundation';
3
+ import { combineProps, hasValue, logInDev, useControlled, styled, } from '../../../../foundation';
5
4
  import { RcButton } from '../../../Buttons';
6
5
  import { RcMenu } from '../../../Menu';
7
6
  import { RcVirtualizedMenu } from '../../../VirtualizedMenu';
@@ -0,0 +1,15 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import MuiTable from '@material-ui/core/Table';
3
+ import { styled, useThemeProps } from '../../foundation';
4
+ import React, { forwardRef, useMemo } from 'react';
5
+ import { RcTableContext } from './context';
6
+ var _RcTable = forwardRef(function (props, ref) {
7
+ var _a = useThemeProps({ props: props, name: 'RcTable' }), children = _a.children, size = _a.size, rest = __rest(_a, ["children", "size"]);
8
+ var tableContextValue = useMemo(function () { return ({ size: size }); }, [size]);
9
+ return (React.createElement(MuiTable, __assign({}, rest, { ref: ref }),
10
+ React.createElement(RcTableContext.Provider, { value: tableContextValue }, children)));
11
+ });
12
+ var RcTable = styled(_RcTable)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
13
+ RcTable.displayName = 'RcTable';
14
+ export { RcTable };
15
+ var templateObject_1;
@@ -0,0 +1,12 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import MuiTableBody from '@material-ui/core/TableBody';
3
+ import React, { forwardRef } from 'react';
4
+ import { styled, useThemeProps } from '../../../foundation';
5
+ var _RcTableBody = forwardRef(function (props, ref) {
6
+ var _a = useThemeProps({ props: props, name: 'RcTableHead' }), children = _a.children, rest = __rest(_a, ["children"]);
7
+ return (React.createElement(MuiTableBody, __assign({}, rest, { ref: ref }), children));
8
+ });
9
+ var RcTableBody = styled(_RcTableBody)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
10
+ RcTableBody.displayName = 'RcTableBody';
11
+ export { RcTableBody };
12
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableBody';
@@ -0,0 +1,37 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import React, { forwardRef, useMemo, useContext } from 'react';
3
+ import MuiTableCell from '@material-ui/core/TableCell';
4
+ import { combineClasses, styled, useThemeProps, } from '../../../foundation';
5
+ import { TableCellStyle } from './styles';
6
+ import { RcTableCellClasses } from './utils';
7
+ import { RcButtonBase } from '../../Buttons';
8
+ import { RcIcon } from '../../Icon';
9
+ import { JumpToLatest as AscSortIcon, JumpToUnread as DescSortIcon, } from '@ringcentral/juno-icon';
10
+ import clsx from 'clsx';
11
+ import { RcTableContext } from '../context';
12
+ var _RcTableCell = forwardRef(function (props, ref) {
13
+ var _a = useThemeProps({ props: props, name: 'RcTableCell' }), classesProp = _a.classes, childrenProp = _a.children, size = _a.size, sortDirection = _a.sortDirection, _b = _a.activeSort, activeSort = _b === void 0 ? false : _b, rest = __rest(_a, ["classes", "children", "size", "sortDirection", "activeSort"]);
14
+ var classes = combineClasses(RcTableCellClasses, classesProp);
15
+ var children = useMemo(function () {
16
+ var _a;
17
+ if (sortDirection) {
18
+ return (React.createElement(RcButtonBase, { disableRipple: true, className: clsx(classes.sortButton, (_a = {},
19
+ _a[classes.activeSort] = activeSort,
20
+ _a)) },
21
+ childrenProp,
22
+ React.createElement(RcIcon, { size: "small", className: classes.sortIcon, symbol: sortDirection === 'asc' ? DescSortIcon : AscSortIcon })));
23
+ }
24
+ return childrenProp;
25
+ }, [activeSort, childrenProp, classes, sortDirection]);
26
+ return (React.createElement(MuiTableCell, __assign({}, rest, (sortDirection ? { sortDirection: sortDirection } : {}), { ref: ref, classes: classes }), children));
27
+ });
28
+ var RcTableCell = styled(_RcTableCell).attrs(function (_a) {
29
+ var _b;
30
+ var sizeProp = _a.size, _c = _a.sortDirection, sortDirection = _c === void 0 ? false : _c, rest = __rest(_a, ["size", "sortDirection"]);
31
+ var contextSize = useContext(RcTableContext).size;
32
+ var size = (_b = sizeProp !== null && sizeProp !== void 0 ? sizeProp : contextSize) !== null && _b !== void 0 ? _b : 'medium';
33
+ return __assign(__assign({}, rest), { size: size, sortDirection: sortDirection });
34
+ })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TableCellStyle);
35
+ RcTableCell.displayName = 'RcTableCell';
36
+ export { RcTableCell };
37
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableCell';
@@ -0,0 +1,14 @@
1
+ import { __makeTemplateObject } from "tslib";
2
+ import { css, fakeBorder, focusVisible, palette2, px, spacing, typography, } from '../../../../foundation';
3
+ import { RcIcon } from '../../../Icon';
4
+ import { RcTableCellClasses } from '../utils';
5
+ var SizeMap = {
6
+ large: 56,
7
+ medium: 48,
8
+ small: 40,
9
+ };
10
+ export var TableCellStyle = function (prop) {
11
+ var size = prop.size, sortDirection = prop.sortDirection;
12
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n padding: ", ";\n min-width: 96px;\n\n &.", " {\n ", "\n height: 40px;\n border-bottom: 1px solid ", ";\n color: ", ";\n background-color: ", ";\n\n padding: ", ";\n\n .", " {\n opacity: 0;\n padding: ", ";\n }\n\n .", " {\n color: ", ";\n\n .", " {\n opacity: 1;\n }\n }\n\n .", " {\n display: inline-flex;\n justify-content: flex-start;\n flex-direction: inherit;\n align-items: center;\n\n height: 100%;\n width: 100%;\n padding: ", ";\n\n ", " {\n color: ", ";\n }\n\n &:hover {\n background-color: ", ";\n\n .", " {\n opacity: 1;\n }\n }\n\n ", " {\n ", "\n background-color: ", ";\n }\n }\n }\n\n &.", " {\n ", "\n color: ", ";\n\n padding: ", ";\n height: ", ";\n }\n "], ["\n box-sizing: border-box;\n padding: ", ";\n min-width: 96px;\n\n &.", " {\n ", "\n height: 40px;\n border-bottom: 1px solid ", ";\n color: ", ";\n background-color: ", ";\n\n padding: ", ";\n\n .", " {\n opacity: 0;\n padding: ", ";\n }\n\n .", " {\n color: ", ";\n\n .", " {\n opacity: 1;\n }\n }\n\n .", " {\n display: inline-flex;\n justify-content: flex-start;\n flex-direction: inherit;\n align-items: center;\n\n height: 100%;\n width: 100%;\n padding: ", ";\n\n ", " {\n color: ", ";\n }\n\n &:hover {\n background-color: ", ";\n\n .", " {\n opacity: 1;\n }\n }\n\n ", " {\n ", "\n background-color: ", ";\n }\n }\n }\n\n &.", " {\n ", "\n color: ", ";\n\n padding: ", ";\n height: ", ";\n }\n "])), spacing(0, 2), RcTableCellClasses.head, typography('caption2'), palette2('neutral', 'l02'), palette2('neutral', 'f05'), palette2('neutral', 'b02'), Boolean(sortDirection) && 'unset', RcTableCellClasses.sortIcon, spacing(0, 2), RcTableCellClasses.activeSort, palette2('interactive', 'f01'), RcTableCellClasses.sortIcon, RcTableCellClasses.sortButton, spacing(0, 2), RcIcon, palette2('neutral', 'f04'), palette2('neutral', 'b03'), RcTableCellClasses.sortIcon, focusVisible, fakeBorder({ color: palette2('interactive', 'f01') }), palette2('neutral', 'b03'), RcTableCellClasses.body, typography('body1'), palette2('neutral', 'f06'), size === 'auto' && spacing(3, 2), size !== 'auto' && px(SizeMap[size]));
13
+ };
14
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableCellStyle';
@@ -0,0 +1,2 @@
1
+ import { RcClasses } from '../../../../foundation';
2
+ export var RcTableCellClasses = RcClasses(['head', 'body', 'sortIcon', 'activeSort', 'sortButton'], 'RcTableCell');
@@ -0,0 +1 @@
1
+ export * from './TableCellUtils';
@@ -0,0 +1,20 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import MuiTableContainer from '@material-ui/core/TableContainer';
3
+ import React, { forwardRef } from 'react';
4
+ import { styled, useThemeProps } from '../../../foundation';
5
+ import { TableContainerStyle } from './styles';
6
+ var _RcTableContainer = forwardRef(function (props, ref) {
7
+ var _a = useThemeProps({
8
+ props: props,
9
+ name: 'RcTableContainer',
10
+ }), children = _a.children, bordered = _a.bordered, rest = __rest(_a, ["children", "bordered"]);
11
+ return (React.createElement(MuiTableContainer, __assign({}, rest, { ref: ref }), children));
12
+ });
13
+ var RcTableContainer = styled(_RcTableContainer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TableContainerStyle);
14
+ RcTableContainer.defaultProps = {
15
+ bordered: false,
16
+ square: false,
17
+ };
18
+ RcTableContainer.displayName = 'RcTableContainer';
19
+ export { RcTableContainer };
20
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableContainer';
@@ -0,0 +1,11 @@
1
+ import { __makeTemplateObject } from "tslib";
2
+ import { css, palette2, px } from '../../../../foundation';
3
+ import { RcTableBody } from '../../TableBody';
4
+ import { RcTableCell } from '../../TableCell';
5
+ import { RcTableRow } from '../../TableRow';
6
+ export var TableContainerStyle = function (props) {
7
+ var bordered = props.bordered, square = props.square;
8
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n "], ["\n ",
9
+ "\n "])), bordered && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: ", ";\n border: 1px solid ", ";\n\n ", " ", ":last-child ", " {\n border: none;\n }\n "], ["\n border-radius: ", ";\n border: 1px solid ", ";\n\n ", " ", ":last-child ", " {\n border: none;\n }\n "])), !square && px(4), palette2('neutral', 'l02'), RcTableBody, RcTableRow, RcTableCell));
10
+ };
11
+ var templateObject_1, templateObject_2;
@@ -0,0 +1 @@
1
+ export * from './TableContainerStyle';
@@ -0,0 +1,12 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import MuiTableHead from '@material-ui/core/TableHead';
3
+ import React, { forwardRef } from 'react';
4
+ import { styled, useThemeProps } from '../../../foundation';
5
+ var _RcTableHead = forwardRef(function (props, ref) {
6
+ var _a = useThemeProps({ props: props, name: 'RcTableHead' }), children = _a.children, rest = __rest(_a, ["children"]);
7
+ return (React.createElement(MuiTableHead, __assign({}, rest, { ref: ref }), children));
8
+ });
9
+ var RcTableHead = styled(_RcTableHead)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
10
+ RcTableHead.displayName = 'RcTableHead';
11
+ export { RcTableHead };
12
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableHead';
@@ -0,0 +1,18 @@
1
+ import { __assign, __makeTemplateObject, __rest } from "tslib";
2
+ import React, { forwardRef, useMemo } from 'react';
3
+ import MuiTableRow from '@material-ui/core/TableRow';
4
+ import { combineClasses, styled, useThemeProps, } from '../../../foundation';
5
+ import { TableRowStyle } from './styles';
6
+ import { RcTableRowClasses } from './utils';
7
+ import clsx from 'clsx';
8
+ var _RcTableRow = forwardRef(function (props, ref) {
9
+ var _a;
10
+ var _b = useThemeProps({ props: props, name: 'RcTableRow' }), className = _b.className, classesProp = _b.classes, children = _b.children, disabled = _b.disabled, rest = __rest(_b, ["className", "classes", "children", "disabled"]);
11
+ var classes = useMemo(function () { return combineClasses(RcTableRowClasses, classesProp); }, [classesProp]);
12
+ return (React.createElement(MuiTableRow, __assign({}, rest, { ref: ref, classes: classes, className: clsx(className, (_a = {}, _a[RcTableRowClasses.disabled] = disabled, _a)) }), children));
13
+ });
14
+ var RcTableRow = styled(_RcTableRow)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TableRowStyle);
15
+ RcTableRow.defaultProps = {};
16
+ RcTableRow.displayName = 'RcTableRow';
17
+ export { RcTableRow };
18
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableRow';
@@ -0,0 +1,7 @@
1
+ import { __makeTemplateObject } from "tslib";
2
+ import { css, nonTouchHoverMedia, palette2, setOpacity, } from '../../../../foundation';
3
+ import { RcTableRowClasses } from '../utils';
4
+ export var TableRowStyle = function () {
5
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", " {\n &.", ", &:hover {\n background-color: ", ";\n }\n }\n\n &.", " {\n &,\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", " {\n &.", ", &.", ", &:hover {\n background-color: unset;\n }\n }\n "], ["\n ", " {\n &.", ", &:hover {\n background-color: ", ";\n }\n }\n\n &.", " {\n &,\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", " {\n &.", ", &.", ", &:hover {\n background-color: unset;\n }\n }\n "])), nonTouchHoverMedia, RcTableRowClasses.hover, setOpacity(palette2('action', 'grayLight'), '08'), RcTableRowClasses.selected, setOpacity(palette2('interactive', 'f01'), '08'), RcTableRowClasses.disabled, RcTableRowClasses.selected, RcTableRowClasses.hover);
6
+ };
7
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export * from './TableRowStyle';
@@ -0,0 +1,2 @@
1
+ import { RcClasses } from '../../../../foundation';
2
+ export var RcTableRowClasses = RcClasses(['selected', 'hover', 'disabled'], 'RcTableRow');
@@ -0,0 +1 @@
1
+ export * from './TableRowUtils';
@@ -0,0 +1,2 @@
1
+ import { createContext } from 'react';
2
+ export var RcTableContext = createContext({});
@@ -0,0 +1,7 @@
1
+ export * from './Table';
2
+ export * from './TableBody';
3
+ export * from './TableCell';
4
+ export * from './TableContainer';
5
+ export * from './TableHead';
6
+ export * from './TableRow';
7
+ export * from './context';
File without changes
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
- import { useThemeProps } from '../../foundation';
3
2
  import { StyledTableRow } from './styled';
4
3
  import { RcTableHeadCell } from './TableHeadCell';
5
4
  import { ORDER_TABLE_BY } from './types';
6
- var RcTableHeadView = function (inProps) {
7
- var props = useThemeProps({ props: inProps, name: 'RcTableHeadView' });
5
+ var RcTableHeadView = function (props) {
8
6
  var columnData = props.columnData, sortMap = props.sortMap, sortHandler = props.sortHandler;
9
7
  return (React.createElement("thead", null,
10
8
  React.createElement(StyledTableRow, null, columnData.map(function (column) {
@@ -3,12 +3,11 @@ import React, { useMemo } from 'react';
3
3
  import isFunction from 'lodash/isFunction';
4
4
  import isNumber from 'lodash/isNumber';
5
5
  import { JumpToLatest as arrowDown, JumpToUnread as arrowUp, } from '@ringcentral/juno-icon';
6
- import { useA11yKeyEvent, useThemeProps } from '../../foundation';
6
+ import { useA11yKeyEvent } from '../../foundation';
7
7
  import { RcIcon } from '../Icon';
8
8
  import { StyledSortIconWrapper, StyledTableHeadCell, StyledTableHeadCellContent, StyledTableHeadText, } from './styled';
9
9
  import { ARIA_SORT_VALUES, ORDER_TABLE_BY, SORT_ICON_CLASS, } from './types';
10
- var RcTableHeadCell = function (inProps) {
11
- var props = useThemeProps({ props: inProps, name: 'RcTableHeadCell' });
10
+ var RcTableHeadCell = function (props) {
12
11
  var automationID = props.automationID, title = props.title, width = props.width, sortDirection = props.sortDirection, sortKey = props.sortKey, textAlign = props.textAlign;
13
12
  var onClick = function () {
14
13
  var sortHandler = props.sortHandler, sortKey = props.sortKey, sortDirection = props.sortDirection;
@@ -1,8 +1,24 @@
1
1
  import { __read } from "tslib";
2
+ /* eslint-disable react-hooks/rules-of-hooks */
2
3
  import { useRef } from 'react';
3
- import { useChange, useEventCallback, useEventListener, usePrevious, useRefState, } from '../../../foundation';
4
+ import { logInDev, useChange, useEventCallback, useEventListener, usePrevious, useRefState, } from '../../../foundation';
4
5
  export var useTooltipForceHide = function (_a) {
5
6
  var tooltipForceHide = _a.tooltipForceHide, openProp = _a.open, onClose = _a.onClose, onOpen = _a.onOpen, ref = _a.ref;
7
+ if (process.env.NODE_ENV !== 'production') {
8
+ useChange(function (prev) {
9
+ // ignore first time
10
+ if (prev !== undefined) {
11
+ logInDev({
12
+ component: 'RcTooltip',
13
+ message: 'Should not change tooltipForceHide between controlled and uncontrolled, tooltipForceHide should always be boolean value',
14
+ level: 'error',
15
+ });
16
+ }
17
+ }, function () { return tooltipForceHide === undefined; });
18
+ }
19
+ // * when not set tooltipForceHide, always return undefined directly, not bind any event addition
20
+ if (tooltipForceHide === undefined)
21
+ return undefined;
6
22
  var _b = __read(useRefState(false), 2), openRef = _b[0], setOpen = _b[1];
7
23
  var isOverRef = useRef(false);
8
24
  var openState = tooltipForceHide ? false : openProp !== null && openProp !== void 0 ? openProp : openRef.current;
@@ -35,14 +51,12 @@ export var useTooltipForceHide = function (_a) {
35
51
  setOpen(false);
36
52
  onClose === null || onClose === void 0 ? void 0 : onClose(event);
37
53
  });
38
- return tooltipForceHide !== undefined
39
- ? {
40
- disableFocusListener: tooltipForceHide,
41
- disableHoverListener: tooltipForceHide,
42
- disableTouchListener: tooltipForceHide,
43
- open: openState,
44
- onOpen: handleOpen,
45
- onClose: handleClose,
46
- }
47
- : undefined;
54
+ return {
55
+ disableFocusListener: tooltipForceHide,
56
+ disableHoverListener: tooltipForceHide,
57
+ disableTouchListener: tooltipForceHide,
58
+ open: openState,
59
+ onOpen: handleOpen,
60
+ onClose: handleClose,
61
+ };
48
62
  };
@@ -41,7 +41,7 @@ export * from './Responsive';
41
41
  export * from './Snackbar';
42
42
  export * from './Stepper';
43
43
  export * from './TablePagination';
44
- export * from './Tables';
44
+ export * from './Table';
45
45
  export * from './Tabs';
46
46
  export * from './Tag';
47
47
  export * from './Text';
@@ -2,12 +2,14 @@ export * from './useA11yKeyEvent';
2
2
  export * from './useAnnouncer';
3
3
  export * from './useAudio';
4
4
  export * from './useChange';
5
+ export * from './useControlled';
5
6
  export * from './useDebounce';
6
7
  export * from './useEventCallback';
7
8
  export * from './useEventListener';
8
9
  export * from './useEver';
9
10
  export * from './useForceUpdate';
10
11
  export * from './useForkRef';
12
+ export * from './useGlobalListener';
11
13
  export * from './useHiddenTabindex';
12
14
  export * from './useId';
13
15
  export * from './useInterval';
@@ -0,0 +1 @@
1
+ export * from './useControlled';
@@ -0,0 +1 @@
1
+ export { useControlled } from '@material-ui/core/utils';
@@ -1,6 +1,6 @@
1
1
  import { __read } from "tslib";
2
2
  import { useEffect, useRef } from 'react';
3
- import { isRef } from '../../utils/isRef';
3
+ import { getRefElement } from '../../utils';
4
4
  import { useEventCallback } from '../useEventCallback';
5
5
  /**
6
6
  * bind event when component mount and auto remove event when destroy.
@@ -26,16 +26,18 @@ export function useEventListener(target) {
26
26
  var listener = useEventCallback(cb);
27
27
  var cancelRef = useRef(function () { });
28
28
  var bindRef = useRef(function () { });
29
- var currentRefElm = isRef(target) && target.current;
29
+ var currentRefElm = getRefElement(target);
30
30
  useEffect(function () {
31
31
  if (!target)
32
32
  return;
33
- var elm = isRef(target) ? target.current : target;
34
- if (!elm) {
33
+ var currentElm = getRefElement(target);
34
+ if (!currentElm) {
35
35
  return cancelRef.current;
36
36
  }
37
- bindRef.current = function () { return elm.addEventListener(key, listener, options); };
38
- cancelRef.current = function () { return elm.removeEventListener(key, listener, options); };
37
+ bindRef.current = function () { return currentElm.addEventListener(key, listener, options); };
38
+ cancelRef.current = function () {
39
+ return currentElm.removeEventListener(key, listener, options);
40
+ };
39
41
  bindRef.current();
40
42
  return cancelRef.current;
41
43
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -0,0 +1 @@
1
+ export * from './useGlobalListener';
@@ -0,0 +1,130 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { getRefElement, logInDev } from '../../utils';
3
+ import { useEventCallback } from '../useEventCallback';
4
+ export var globalListenerEventMap = new Map();
5
+ /**
6
+ * create globalListener handler for share one listener event
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const globalListener = createGlobalListener('focus', () => { console.log('focus') });
11
+ * const globalListener2 = createGlobalListener('focus', () => { console.log('focus') });
12
+ * globalListener.listen();
13
+ * globalListener2.listen();
14
+ *
15
+ * => // that will only create an event listener on window, but every callback will get emit value when event triggered
16
+ * ```
17
+ */
18
+ export var createGlobalListener = function (key, listener, _a) {
19
+ var _b = _a === void 0 ? {} : _a, _c = _b.customKey, customKey = _c === void 0 ? key : _c, _d = _b.target, targetProp = _d === void 0 ? window : _d;
20
+ var listening = false;
21
+ var getMapValue = function () { return globalListenerEventMap.get(customKey); };
22
+ var addListener = function () {
23
+ if (listening)
24
+ return;
25
+ var savedEvent = getMapValue();
26
+ if (!(savedEvent === null || savedEvent === void 0 ? void 0 : savedEvent.exec)) {
27
+ var exec = function (e) {
28
+ var event = getMapValue();
29
+ event === null || event === void 0 ? void 0 : event.listeners.forEach(function (c) { return c(e); });
30
+ };
31
+ globalListenerEventMap.set(customKey, {
32
+ exec: exec,
33
+ listeners: new Set([listener]),
34
+ });
35
+ var target = getRefElement(targetProp);
36
+ target === null || target === void 0 ? void 0 : target.addEventListener(key, exec);
37
+ }
38
+ else {
39
+ savedEvent.listeners.add(listener);
40
+ }
41
+ listening = true;
42
+ };
43
+ var removeListener = function () {
44
+ if (!listening)
45
+ return;
46
+ listening = false;
47
+ var _savedEvent = getMapValue();
48
+ if (!_savedEvent)
49
+ return;
50
+ var listeners = _savedEvent.listeners;
51
+ listeners.delete(listener);
52
+ if (listeners.size === 0) {
53
+ var target = getRefElement(targetProp);
54
+ target === null || target === void 0 ? void 0 : target.removeEventListener(key, _savedEvent.exec);
55
+ globalListenerEventMap.delete(customKey);
56
+ }
57
+ };
58
+ return {
59
+ /**
60
+ * bind listener again
61
+ */
62
+ listen: function () { return addListener(); },
63
+ /**
64
+ * remove listener
65
+ */
66
+ remove: function () { return removeListener(); },
67
+ /**
68
+ * current listener state
69
+ */
70
+ get state() {
71
+ return {
72
+ /**
73
+ * current listener state count
74
+ */
75
+ get count() {
76
+ var _a;
77
+ return ((_a = getMapValue()) === null || _a === void 0 ? void 0 : _a.listeners.size) || 0;
78
+ },
79
+ /**
80
+ * is that be listening
81
+ */
82
+ listening: listening,
83
+ };
84
+ },
85
+ };
86
+ };
87
+ /**
88
+ * bind global event, when you bind same key event,
89
+ * that will reuse one event listener and trigger both callback once that listener be triggered.
90
+ *
91
+ * also you can control listener with method `listen` and `remove`
92
+ * and get listener `state` for check listener count number and current listing state.
93
+ *
94
+ * - `key` `options` only work when set first time, never change after first render
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * useGlobalListener('keyup', () => console.log('window key up1'))
99
+ * useGlobalListener('keyup', () => console.log('window key up2'))
100
+ * useGlobalListener('keyup', () => console.log('window key up3'))
101
+ *
102
+ * => // that will only create an event listener on `window`, but every callback will get emit value when event triggered
103
+ * ```
104
+ */
105
+ export function useGlobalListener(key, listener, options) {
106
+ if (options === void 0) { options = {}; }
107
+ var _listener = useEventCallback(listener);
108
+ var globalListener = useRef(createGlobalListener(key, _listener, options)).current;
109
+ if (process.env.NODE_ENV !== 'production') {
110
+ var _a = options.customKey, customKey_1 = _a === void 0 ? key : _a, _b = options.target, targetProp_1 = _b === void 0 ? window : _b;
111
+ // eslint-disable-next-line react-hooks/rules-of-hooks
112
+ useEffect(function () {
113
+ var target = getRefElement(targetProp_1);
114
+ if (target !== window && customKey_1 === key) {
115
+ logInDev({
116
+ component: 'useGlobalListener',
117
+ message: 'When you custom binding event target, you must custom key for determining different event group',
118
+ level: 'error',
119
+ });
120
+ }
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ }, []);
123
+ }
124
+ useEffect(function () {
125
+ globalListener.listen();
126
+ return globalListener.remove;
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ }, []);
129
+ return globalListener;
130
+ }
@@ -1,17 +1,18 @@
1
+ import { getRefElement } from '../../utils';
1
2
  import { useEventCallback } from '../useEventCallback';
2
3
  /**
3
4
  * group hidden logic, when binding events element focus,
4
5
  * that hiddenRef will auto be `tabindex={-1}` *
5
6
  */
6
- export var useHiddenTabindex = function (hiddenRef) {
7
+ export var useHiddenTabindex = function (target) {
7
8
  var handleFocus = useEventCallback(function () {
8
- var hiddenElm = hiddenRef.current;
9
+ var hiddenElm = getRefElement(target);
9
10
  if (hiddenElm && hiddenElm.tabIndex === 0) {
10
11
  hiddenElm.tabIndex = -1;
11
12
  }
12
13
  });
13
14
  var handleBlur = useEventCallback(function () {
14
- var hiddenElm = hiddenRef.current;
15
+ var hiddenElm = getRefElement(target);
15
16
  if (hiddenElm && hiddenElm.tabIndex === -1) {
16
17
  hiddenElm.tabIndex = 0;
17
18
  }
@@ -3,7 +3,7 @@ import { useEffect, useRef } from 'react';
3
3
  import { useA11yKeyEvent } from '../useA11yKeyEvent';
4
4
  import { useDebounce } from '../useDebounce';
5
5
  import { useEventCallback } from '../useEventCallback';
6
- import { isElmEqualOrContainRef, useTouchMouseEvent, } from '../useTouchMouseEvent';
6
+ import { isElmEqualOrContain, useTouchMouseEvent, } from '../useTouchMouseEvent';
7
7
  /**
8
8
  * Provide longPress helper, both `click`/`tab`/`keydown` will trigger event
9
9
  *
@@ -30,8 +30,7 @@ export var useLongPress = function (_a, _b, _c) {
30
30
  var end = function (e) {
31
31
  // ! mouse up only trigger when up on element, so we host that in document
32
32
  document.removeEventListener('mouseup', onMouseUp);
33
- if (!isEmittedRef.current &&
34
- isElmEqualOrContainRef(e.target, elmRef)) {
33
+ if (!isEmittedRef.current && isElmEqualOrContain(e.target, elmRef)) {
35
34
  onTap === null || onTap === void 0 ? void 0 : onTap(e, reasonRef.current);
36
35
  }
37
36
  reasonRef.current = 'click';