@ringcentral/juno 1.12.4-beta.5847-6a74475d → 1.12.4-beta.5864-e73e0ffc
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/components/Buttons/SplitButton/SplitButton.js +2 -1
- package/components/Downshift/Downshift.d.ts +2 -0
- package/components/Downshift/SuggestionList/SuggestionList.js +3 -0
- package/components/Downshift/utils/useDownshiftGroup.js +3 -2
- package/es6/components/Buttons/SplitButton/SplitButton.js +3 -2
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +3 -0
- package/es6/components/Downshift/utils/useDownshiftGroup.js +3 -2
- package/es6/foundation/hooks/index.js +1 -0
- package/es6/foundation/hooks/useEver/index.js +1 -0
- package/es6/foundation/hooks/useEver/useEver.js +30 -0
- package/foundation/hooks/index.d.ts +1 -0
- package/foundation/hooks/index.js +1 -0
- package/foundation/hooks/useEver/index.d.ts +1 -0
- package/foundation/hooks/useEver/index.js +4 -0
- package/foundation/hooks/useEver/useEver.d.ts +13 -0
- package/foundation/hooks/useEver/useEver.js +32 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ var _RcSplitButton = react_1.forwardRef(function (inProps, ref) {
|
|
|
27
27
|
var innerRef = react_1.useRef(null);
|
|
28
28
|
var splitRef = foundation_1.useForkRef(innerRef, ref);
|
|
29
29
|
var isMenuOpen = !!anchorEl;
|
|
30
|
+
var isMenuEverOpen = foundation_1.useEver(isMenuOpen);
|
|
30
31
|
var _h = react_1.useMemo(function () {
|
|
31
32
|
var result = foundation_1.combineClasses(utils_1.RcSplitButtonClasses, classesProp);
|
|
32
33
|
return {
|
|
@@ -158,7 +159,7 @@ var _RcSplitButton = react_1.forwardRef(function (inProps, ref) {
|
|
|
158
159
|
react_1.default.createElement(Button_1.RcButton, tslib_1.__assign({}, _ActionButtonProps)),
|
|
159
160
|
react_1.default.createElement(Button_1.RcButton, tslib_1.__assign({ "aria-haspopup": "listbox" }, _ControlButtonProps),
|
|
160
161
|
react_1.default.createElement(styles_1.StyledArrowIcon, tslib_1.__assign({ open: isMenuOpen, size: variantIs(['round', 'plainIcon']) ? size : toButtonSize }, ArrowIconProps)))),
|
|
161
|
-
react_1.default.createElement(Menu_1.RcMenu, tslib_1.__assign({}, MenuProps, { anchorEl: anchorEl, open: isMenuOpen, onClose: handleClose }), children)));
|
|
162
|
+
isMenuEverOpen && (react_1.default.createElement(Menu_1.RcMenu, tslib_1.__assign({}, MenuProps, { anchorEl: anchorEl, open: isMenuOpen, onClose: handleClose }), children))));
|
|
162
163
|
});
|
|
163
164
|
var RcSplitButton = foundation_1.styled(_RcSplitButton)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.splitButtonStyle);
|
|
164
165
|
exports.RcSplitButton = RcSplitButton;
|
|
@@ -14,6 +14,8 @@ export interface RcDownshiftRenderOptionState {
|
|
|
14
14
|
selected: boolean;
|
|
15
15
|
/** that item index */
|
|
16
16
|
index: number;
|
|
17
|
+
/** sort index in option own group */
|
|
18
|
+
indexInOwnGroup?: number;
|
|
17
19
|
/** if that item is group title, that have that `expanded` state */
|
|
18
20
|
expanded?: boolean;
|
|
19
21
|
/** if that item is group title, that will have that `expandIconProps` */
|
|
@@ -115,6 +115,8 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
115
115
|
});
|
|
116
116
|
var selected = highlightedIndex === index;
|
|
117
117
|
var resultProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, option), itemProps), { 'aria-setsize': itemCount - (isTitleGroup ? (optionsGroupList === null || optionsGroupList === void 0 ? void 0 : optionsGroupList.length) || 0 : 0), 'aria-posinset': index - (isTitleGroup ? groupIndex : 0), key: itemProps.id });
|
|
118
|
+
var indexInOwnGroup = resultProps.indexInOwnGroup;
|
|
119
|
+
delete resultProps.indexInOwnGroup;
|
|
118
120
|
// * when item is not disabled, that should check outside is that disabled
|
|
119
121
|
if (!resultProps.freeSolo && !resultProps.disabled && getOptionDisabled) {
|
|
120
122
|
resultProps.disabled = getOptionDisabled(option);
|
|
@@ -123,6 +125,7 @@ var SuggestionList = react_1.forwardRef(function (inProps, ref) {
|
|
|
123
125
|
inputValue: inputValue,
|
|
124
126
|
selected: selected,
|
|
125
127
|
index: index,
|
|
128
|
+
indexInOwnGroup: indexInOwnGroup,
|
|
126
129
|
};
|
|
127
130
|
if (renderGroup && isGroupTitle) {
|
|
128
131
|
return renderGroup(resultProps, tslib_1.__assign(tslib_1.__assign({}, state), { expanded: (_e = option.group) === null || _e === void 0 ? void 0 : _e.expanded, expandIconProps: expandIconProps }));
|
|
@@ -38,7 +38,8 @@ exports.useDownshiftGroup = function (_a) {
|
|
|
38
38
|
var result = filteredResult.reduce(function (acc, option, index) {
|
|
39
39
|
var group = groupBy(option);
|
|
40
40
|
if (acc.length > 0 && acc[acc.length - 1].group === group) {
|
|
41
|
-
|
|
41
|
+
var currGroup = acc[acc.length - 1];
|
|
42
|
+
acc[acc.length - 1].options.push(tslib_1.__assign(tslib_1.__assign({}, option), { group: currGroup, indexInOwnGroup: currGroup.options.length - 1 }));
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
45
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -55,7 +56,7 @@ exports.useDownshiftGroup = function (_a) {
|
|
|
55
56
|
key: index,
|
|
56
57
|
index: index,
|
|
57
58
|
group: group,
|
|
58
|
-
options: [tslib_1.__assign({}, option)],
|
|
59
|
+
options: [tslib_1.__assign(tslib_1.__assign({}, option), { indexInOwnGroup: 0 })],
|
|
59
60
|
expanded: false,
|
|
60
61
|
getExpandIconProps: function (additionExpandIconProps) {
|
|
61
62
|
return newGroup_1.options.length > 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __read, __rest } from "tslib";
|
|
2
2
|
import React, { forwardRef, useMemo, useRef, useState, } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { checkDefaultPrevented, combineClasses, combineProps, logInDev, omit, styled, useEventCallback, useForkRef, useTheme, useThemeProps, } from '../../../foundation';
|
|
4
|
+
import { checkDefaultPrevented, combineClasses, combineProps, logInDev, omit, styled, useEver, useEventCallback, useForkRef, useTheme, useThemeProps, } from '../../../foundation';
|
|
5
5
|
import { RcMenu } from '../../Menu/Menu';
|
|
6
6
|
import { RcButton } from '../Button';
|
|
7
7
|
import { RcButtonGroup } from '../ButtonGroup';
|
|
@@ -25,6 +25,7 @@ var _RcSplitButton = forwardRef(function (inProps, ref) {
|
|
|
25
25
|
var innerRef = useRef(null);
|
|
26
26
|
var splitRef = useForkRef(innerRef, ref);
|
|
27
27
|
var isMenuOpen = !!anchorEl;
|
|
28
|
+
var isMenuEverOpen = useEver(isMenuOpen);
|
|
28
29
|
var _h = useMemo(function () {
|
|
29
30
|
var result = combineClasses(RcSplitButtonClasses, classesProp);
|
|
30
31
|
return {
|
|
@@ -156,7 +157,7 @@ var _RcSplitButton = forwardRef(function (inProps, ref) {
|
|
|
156
157
|
React.createElement(RcButton, __assign({}, _ActionButtonProps)),
|
|
157
158
|
React.createElement(RcButton, __assign({ "aria-haspopup": "listbox" }, _ControlButtonProps),
|
|
158
159
|
React.createElement(StyledArrowIcon, __assign({ open: isMenuOpen, size: variantIs(['round', 'plainIcon']) ? size : toButtonSize }, ArrowIconProps)))),
|
|
159
|
-
React.createElement(RcMenu, __assign({}, MenuProps, { anchorEl: anchorEl, open: isMenuOpen, onClose: handleClose }), children)));
|
|
160
|
+
isMenuEverOpen && (React.createElement(RcMenu, __assign({}, MenuProps, { anchorEl: anchorEl, open: isMenuOpen, onClose: handleClose }), children))));
|
|
160
161
|
});
|
|
161
162
|
var RcSplitButton = styled(_RcSplitButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), splitButtonStyle);
|
|
162
163
|
RcSplitButton.displayName = 'RcSplitButton';
|
|
@@ -113,6 +113,8 @@ var SuggestionList = forwardRef(function (inProps, ref) {
|
|
|
113
113
|
});
|
|
114
114
|
var selected = highlightedIndex === index;
|
|
115
115
|
var resultProps = __assign(__assign(__assign({}, option), itemProps), { 'aria-setsize': itemCount - (isTitleGroup ? (optionsGroupList === null || optionsGroupList === void 0 ? void 0 : optionsGroupList.length) || 0 : 0), 'aria-posinset': index - (isTitleGroup ? groupIndex : 0), key: itemProps.id });
|
|
116
|
+
var indexInOwnGroup = resultProps.indexInOwnGroup;
|
|
117
|
+
delete resultProps.indexInOwnGroup;
|
|
116
118
|
// * when item is not disabled, that should check outside is that disabled
|
|
117
119
|
if (!resultProps.freeSolo && !resultProps.disabled && getOptionDisabled) {
|
|
118
120
|
resultProps.disabled = getOptionDisabled(option);
|
|
@@ -121,6 +123,7 @@ var SuggestionList = forwardRef(function (inProps, ref) {
|
|
|
121
123
|
inputValue: inputValue,
|
|
122
124
|
selected: selected,
|
|
123
125
|
index: index,
|
|
126
|
+
indexInOwnGroup: indexInOwnGroup,
|
|
124
127
|
};
|
|
125
128
|
if (renderGroup && isGroupTitle) {
|
|
126
129
|
return renderGroup(resultProps, __assign(__assign({}, state), { expanded: (_e = option.group) === null || _e === void 0 ? void 0 : _e.expanded, expandIconProps: expandIconProps }));
|
|
@@ -36,7 +36,8 @@ export var useDownshiftGroup = function (_a) {
|
|
|
36
36
|
var result = filteredResult.reduce(function (acc, option, index) {
|
|
37
37
|
var group = groupBy(option);
|
|
38
38
|
if (acc.length > 0 && acc[acc.length - 1].group === group) {
|
|
39
|
-
|
|
39
|
+
var currGroup = acc[acc.length - 1];
|
|
40
|
+
acc[acc.length - 1].options.push(__assign(__assign({}, option), { group: currGroup, indexInOwnGroup: currGroup.options.length - 1 }));
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
42
43
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -53,7 +54,7 @@ export var useDownshiftGroup = function (_a) {
|
|
|
53
54
|
key: index,
|
|
54
55
|
index: index,
|
|
55
56
|
group: group,
|
|
56
|
-
options: [__assign({}, option)],
|
|
57
|
+
options: [__assign(__assign({}, option), { indexInOwnGroup: 0 })],
|
|
57
58
|
expanded: false,
|
|
58
59
|
getExpandIconProps: function (additionExpandIconProps) {
|
|
59
60
|
return newGroup_1.options.length > 1
|
|
@@ -5,6 +5,7 @@ export * from './useChange';
|
|
|
5
5
|
export * from './useDebounce';
|
|
6
6
|
export * from './useEventCallback';
|
|
7
7
|
export * from './useEventListener';
|
|
8
|
+
export * from './useEver';
|
|
8
9
|
export * from './useForceUpdate';
|
|
9
10
|
export * from './useForkRef';
|
|
10
11
|
export * from './useHiddenTabindex';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useEver';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
var defaultEverTargetValue = function (value) { return !!value; };
|
|
3
|
+
/**
|
|
4
|
+
* that value ever to be `you want value`
|
|
5
|
+
* Return true when the value ever to be `you want value` once.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // once that isOpen is true, that result will always be `true`
|
|
10
|
+
* const isEverOpen = useEver(isOpen);
|
|
11
|
+
*
|
|
12
|
+
* const isEverToBe2 = useEver(count, (val) => val === 2);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export var useEver = function (
|
|
16
|
+
/** to be checked value */
|
|
17
|
+
value,
|
|
18
|
+
/**
|
|
19
|
+
* value ever to be callback, default when value to be exited.
|
|
20
|
+
*
|
|
21
|
+
* @default (value) => !!value
|
|
22
|
+
*/
|
|
23
|
+
targetValue) {
|
|
24
|
+
if (targetValue === void 0) { targetValue = defaultEverTargetValue; }
|
|
25
|
+
var result = useRef(false);
|
|
26
|
+
if (!result.current) {
|
|
27
|
+
result.current = targetValue(value);
|
|
28
|
+
}
|
|
29
|
+
return result.current;
|
|
30
|
+
};
|
|
@@ -5,6 +5,7 @@ export * from './useChange';
|
|
|
5
5
|
export * from './useDebounce';
|
|
6
6
|
export * from './useEventCallback';
|
|
7
7
|
export * from './useEventListener';
|
|
8
|
+
export * from './useEver';
|
|
8
9
|
export * from './useForceUpdate';
|
|
9
10
|
export * from './useForkRef';
|
|
10
11
|
export * from './useHiddenTabindex';
|
|
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./useChange"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./useDebounce"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./useEventCallback"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./useEventListener"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./useEver"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./useForceUpdate"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./useForkRef"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./useHiddenTabindex"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useEver';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* that value ever to be `you want value`
|
|
3
|
+
* Return true when the value ever to be `you want value` once.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* // once that isOpen is true, that result will always be `true`
|
|
8
|
+
* const isEverOpen = useEver(isOpen);
|
|
9
|
+
*
|
|
10
|
+
* const isEverToBe2 = useEver(count, (val) => val === 2);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const useEver: <T>(value: T, targetValue?: (value: T) => boolean) => boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var defaultEverTargetValue = function (value) { return !!value; };
|
|
5
|
+
/**
|
|
6
|
+
* that value ever to be `you want value`
|
|
7
|
+
* Return true when the value ever to be `you want value` once.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // once that isOpen is true, that result will always be `true`
|
|
12
|
+
* const isEverOpen = useEver(isOpen);
|
|
13
|
+
*
|
|
14
|
+
* const isEverToBe2 = useEver(count, (val) => val === 2);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
exports.useEver = function (
|
|
18
|
+
/** to be checked value */
|
|
19
|
+
value,
|
|
20
|
+
/**
|
|
21
|
+
* value ever to be callback, default when value to be exited.
|
|
22
|
+
*
|
|
23
|
+
* @default (value) => !!value
|
|
24
|
+
*/
|
|
25
|
+
targetValue) {
|
|
26
|
+
if (targetValue === void 0) { targetValue = defaultEverTargetValue; }
|
|
27
|
+
var result = react_1.useRef(false);
|
|
28
|
+
if (!result.current) {
|
|
29
|
+
result.current = targetValue(value);
|
|
30
|
+
}
|
|
31
|
+
return result.current;
|
|
32
|
+
};
|