@ringcentral/juno 1.12.4-beta.5847-6a74475d → 1.12.4
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 +3 -1
- package/components/Downshift/Downshift.js +1 -2
- package/components/Downshift/SuggestionList/SuggestionList.js +7 -5
- package/components/Downshift/SuggestionList/utils/useSuggestionList.d.ts +20 -7
- package/components/Downshift/SuggestionList/utils/useSuggestionList.js +88 -70
- package/components/Downshift/utils/DownshiftUtils.d.ts +2 -0
- package/components/Downshift/utils/DownshiftUtils.js +6 -0
- package/components/Downshift/utils/SelectItem.d.ts +3 -1
- package/components/Downshift/utils/index.d.ts +2 -0
- package/components/Downshift/utils/index.js +2 -0
- package/components/Downshift/utils/useDownshift.d.ts +13 -272
- package/components/Downshift/utils/useDownshift.js +132 -429
- package/components/Downshift/utils/useDownshiftGroup.js +4 -2
- package/components/Downshift/utils/useDownshiftTag.d.ts +554 -0
- package/components/Downshift/utils/useDownshiftTag.js +229 -0
- package/components/PortalHost/PortalManager/types.d.ts +1 -1
- package/es6/components/Buttons/SplitButton/SplitButton.js +3 -2
- package/es6/components/Downshift/Downshift.js +1 -2
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +7 -5
- package/es6/components/Downshift/SuggestionList/utils/useSuggestionList.js +90 -72
- package/es6/components/Downshift/utils/DownshiftUtils.js +5 -0
- package/es6/components/Downshift/utils/index.js +2 -0
- package/es6/components/Downshift/utils/useDownshift.js +135 -432
- package/es6/components/Downshift/utils/useDownshiftGroup.js +4 -2
- package/es6/components/Downshift/utils/useDownshiftTag.js +227 -0
- 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/es6/foundation/hooks/useRefState/useRefState.js +6 -1
- 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/foundation/hooks/useRefState/useRefState.js +6 -1
- package/foundation/theme/ThemeProvider.d.ts +5 -3
- package/package.json +1 -1
|
@@ -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,8 @@ export var useDownshiftGroup = function (_a) {
|
|
|
53
54
|
key: index,
|
|
54
55
|
index: index,
|
|
55
56
|
group: group,
|
|
56
|
-
|
|
57
|
+
order: acc.length,
|
|
58
|
+
options: [__assign(__assign({}, option), { indexInOwnGroup: 0 })],
|
|
57
59
|
expanded: false,
|
|
58
60
|
getExpandIconProps: function (additionExpandIconProps) {
|
|
59
61
|
return newGroup_1.options.length > 1
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { __assign, __read, __rest, __spread } from "tslib";
|
|
2
|
+
import { useMemo, useRef, useState } from 'react';
|
|
3
|
+
import isString from 'lodash/isString';
|
|
4
|
+
import uniqueId from 'lodash/uniqueId';
|
|
5
|
+
import { useControlled } from '@material-ui/core/utils';
|
|
6
|
+
import { combineProps, useEventCallback, useKeyboardMoveFocus, useRefState, } from '../../../foundation';
|
|
7
|
+
import { DEFAULT_GET_OPTION_LABEL, downshiftComponentName, stringArrToRegExp, } from './DownshiftUtils';
|
|
8
|
+
var DOWNSHIFT_ID_TOKEN = 'rc-chip-';
|
|
9
|
+
/** @inner inner hook work with useDownshift */
|
|
10
|
+
export var useDownshiftTag = function (_a) {
|
|
11
|
+
var downshiftId = _a.id, _b = _a.value, selectedItemsProp = _b === void 0 ? [] : _b, onSelectChange = _a.onChange, variant = _a.variant, _c = _a.getOptionLabel, getOptionLabel = _c === void 0 ? DEFAULT_GET_OPTION_LABEL : _c, onInputChangeProp = _a.onInputChange, wrapperRef = _a.wrapperRef, inputRef = _a.inputRef, freeSolo = _a.freeSolo, maxFreeSolo = _a.maxFreeSolo, keyToTags = _a.keyToTags, onMaxFreeSolo = _a.onMaxFreeSolo, multiple = _a.multiple, labelProp = _a.label, required = _a.required, disabled = _a.disabled, getStopCreateFreeSolo = _a.getStopCreateFreeSolo, onReset = _a.onReset;
|
|
12
|
+
var isAutocomplete = variant === 'autocomplete';
|
|
13
|
+
var isSelectedFromAutocompleteRef = useRef(false);
|
|
14
|
+
var _d = __read(useControlled({
|
|
15
|
+
controlled: selectedItemsProp,
|
|
16
|
+
default: [],
|
|
17
|
+
name: downshiftComponentName,
|
|
18
|
+
}), 2), tags = _d[0], _setTags = _d[1];
|
|
19
|
+
var _e = __read(useState(false), 2), focused = _e[0], setFocused = _e[1];
|
|
20
|
+
var _f = __read(useRefState(0), 2), focusedIndexRef = _f[0], setFocusedIndex = _f[1];
|
|
21
|
+
var freeSoloCount = useMemo(function () { return tags.filter(function (x) { return x.freeSolo; }).length; }, [tags]);
|
|
22
|
+
var setTags = function (_selectedItems) {
|
|
23
|
+
_setTags(_selectedItems);
|
|
24
|
+
onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(_selectedItems);
|
|
25
|
+
if (isAutocomplete && _selectedItems.length === 1) {
|
|
26
|
+
var result = getOptionLabel(_selectedItems[0]);
|
|
27
|
+
onInputChangeProp === null || onInputChangeProp === void 0 ? void 0 : onInputChangeProp(result);
|
|
28
|
+
isSelectedFromAutocompleteRef.current = true;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var _focusTag = function (tagToFocus) {
|
|
32
|
+
var _a;
|
|
33
|
+
var textFieldElm = wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current;
|
|
34
|
+
var inputElm = inputRef.current;
|
|
35
|
+
if (tagToFocus === -1) {
|
|
36
|
+
inputElm === null || inputElm === void 0 ? void 0 : inputElm.focus();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
(_a = textFieldElm === null || textFieldElm === void 0 ? void 0 : textFieldElm.querySelector("[data-tag-index=\"" + tagToFocus + "\"]")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var focusTag = useEventCallback(function (tagToFocus, focus) {
|
|
43
|
+
if (focus === void 0) { focus = true; }
|
|
44
|
+
if (focusedIndexRef.current === tagToFocus)
|
|
45
|
+
return;
|
|
46
|
+
setFocusedIndex(tagToFocus);
|
|
47
|
+
if (focus)
|
|
48
|
+
_focusTag(tagToFocus);
|
|
49
|
+
});
|
|
50
|
+
/** when return `true` mean add item success */
|
|
51
|
+
var checkAndAddFreeSolo = function (_a, e) {
|
|
52
|
+
var _b = _a === void 0 ? {} : _a, selectedItem = _b.selectedItem, value = _b.value;
|
|
53
|
+
var _c;
|
|
54
|
+
var isAddItem = false;
|
|
55
|
+
var currentValue = value !== null && value !== void 0 ? value : (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.value;
|
|
56
|
+
if (!(getStopCreateFreeSolo === null || getStopCreateFreeSolo === void 0 ? void 0 : getStopCreateFreeSolo()) &&
|
|
57
|
+
!selectedItem &&
|
|
58
|
+
freeSolo &&
|
|
59
|
+
currentValue &&
|
|
60
|
+
currentValue.length > 0) {
|
|
61
|
+
if (freeSoloCount < maxFreeSolo) {
|
|
62
|
+
var items = currentValue
|
|
63
|
+
.trim()
|
|
64
|
+
.split(stringArrToRegExp(keyToTags))
|
|
65
|
+
.filter(function (x) { return x.trim() !== ''; });
|
|
66
|
+
var toLength = freeSoloCount + items.length;
|
|
67
|
+
if (toLength > maxFreeSolo) {
|
|
68
|
+
items.splice(-(toLength - maxFreeSolo));
|
|
69
|
+
onMaxFreeSolo === null || onMaxFreeSolo === void 0 ? void 0 : onMaxFreeSolo(maxFreeSolo);
|
|
70
|
+
}
|
|
71
|
+
if (items.length > 0) {
|
|
72
|
+
setTags(__spread(tags, items.map(function (label) {
|
|
73
|
+
return ({
|
|
74
|
+
id: uniqueId(DOWNSHIFT_ID_TOKEN),
|
|
75
|
+
isSuggestion: false,
|
|
76
|
+
freeSolo: true,
|
|
77
|
+
label: label,
|
|
78
|
+
});
|
|
79
|
+
})));
|
|
80
|
+
isAddItem = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
onMaxFreeSolo === null || onMaxFreeSolo === void 0 ? void 0 : onMaxFreeSolo(maxFreeSolo);
|
|
85
|
+
}
|
|
86
|
+
onReset === null || onReset === void 0 ? void 0 : onReset(e);
|
|
87
|
+
}
|
|
88
|
+
return isAddItem;
|
|
89
|
+
};
|
|
90
|
+
var removeTag = function (selectedItem) {
|
|
91
|
+
var selectedItemIndex = tags.indexOf(selectedItem);
|
|
92
|
+
if (selectedItemIndex > -1) {
|
|
93
|
+
setTags(__spread(tags.slice(0, selectedItemIndex), tags.slice(selectedItemIndex + 1)));
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var addTag = function (selectedItem) {
|
|
97
|
+
// * change to uniqueId
|
|
98
|
+
if (selectedItem.freeSolo) {
|
|
99
|
+
if (freeSoloCount < maxFreeSolo) {
|
|
100
|
+
selectedItem.id = uniqueId(DOWNSHIFT_ID_TOKEN);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
onMaxFreeSolo === null || onMaxFreeSolo === void 0 ? void 0 : onMaxFreeSolo(maxFreeSolo);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (multiple) {
|
|
108
|
+
setTags(__spread(tags, [selectedItem]));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
setTags([selectedItem]);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var handleTagKey = useKeyboardMoveFocus({
|
|
115
|
+
options: tags,
|
|
116
|
+
focusedIndexRef: focusedIndexRef,
|
|
117
|
+
infinite: 'order',
|
|
118
|
+
onFocusedIndexChange: function (event, toIndex) {
|
|
119
|
+
focusTag(toIndex);
|
|
120
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
121
|
+
},
|
|
122
|
+
}).onKeyFocusedIndexHandle;
|
|
123
|
+
/**
|
|
124
|
+
* All Get props methods
|
|
125
|
+
*/
|
|
126
|
+
var getTagListBoxProps = function (props) {
|
|
127
|
+
return __assign({ 'aria-label': isString(labelProp) ? labelProp : undefined, 'aria-required': required || false, 'aria-disabled': disabled || false }, props);
|
|
128
|
+
};
|
|
129
|
+
var getTagProps = function (_a) {
|
|
130
|
+
var index = _a.index, selectedItem = _a.selectedItem, restTagProps = __rest(_a, ["index", "selectedItem"]);
|
|
131
|
+
var tabIndex =
|
|
132
|
+
// * when tag is not focus
|
|
133
|
+
!focused &&
|
|
134
|
+
// * and is first item
|
|
135
|
+
index === 0
|
|
136
|
+
? 0
|
|
137
|
+
: -1;
|
|
138
|
+
return combineProps({
|
|
139
|
+
tabIndex: tabIndex,
|
|
140
|
+
// TODO: wait for input can complete that.
|
|
141
|
+
// role: 'option',
|
|
142
|
+
role: 'button',
|
|
143
|
+
key: downshiftId + "-selected-item-" + index,
|
|
144
|
+
'data-tag-index': index,
|
|
145
|
+
'data-item-last': index === tags.length - 1,
|
|
146
|
+
onClick: function (e) {
|
|
147
|
+
e.stopPropagation();
|
|
148
|
+
},
|
|
149
|
+
onBlur: function () { return setFocused(false); },
|
|
150
|
+
onFocus: function () {
|
|
151
|
+
focusTag(index);
|
|
152
|
+
setFocused(true);
|
|
153
|
+
},
|
|
154
|
+
onKeyDown: function (e) {
|
|
155
|
+
var focusedIndex = focusedIndexRef.current;
|
|
156
|
+
switch (e.key) {
|
|
157
|
+
case 'Backspace':
|
|
158
|
+
{
|
|
159
|
+
var lengthBeforeDelete = tags.length;
|
|
160
|
+
focusTag(
|
|
161
|
+
// * when length is 1 mean that will be remove all
|
|
162
|
+
lengthBeforeDelete === 1
|
|
163
|
+
? -1
|
|
164
|
+
: focusedIndex === 0
|
|
165
|
+
? 0
|
|
166
|
+
: focusedIndex - 1);
|
|
167
|
+
removeTag(selectedItem);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
case 'Delete':
|
|
171
|
+
{
|
|
172
|
+
var lengthBeforeDelete = tags.length;
|
|
173
|
+
focusTag(
|
|
174
|
+
// * when length is 1 mean that will be remove all
|
|
175
|
+
lengthBeforeDelete === 1
|
|
176
|
+
? -1
|
|
177
|
+
: focusedIndex === tags.length - 1
|
|
178
|
+
? focusedIndex - 1
|
|
179
|
+
: focusedIndex);
|
|
180
|
+
removeTag(selectedItem);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
handleTagKey(e);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
onDelete: function (e) {
|
|
189
|
+
// * left button clicked
|
|
190
|
+
if (e.button === 0) {
|
|
191
|
+
removeTag(selectedItem);
|
|
192
|
+
setFocused(false);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
}, restTagProps);
|
|
196
|
+
};
|
|
197
|
+
return {
|
|
198
|
+
focused: focused,
|
|
199
|
+
setFocused: setFocused,
|
|
200
|
+
tags: tags,
|
|
201
|
+
isSelectedFromAutocompleteRef: isSelectedFromAutocompleteRef,
|
|
202
|
+
focusedIndex: focusedIndexRef.current,
|
|
203
|
+
checkAndAddFreeSolo: checkAndAddFreeSolo,
|
|
204
|
+
getTagListBoxProps: getTagListBoxProps,
|
|
205
|
+
getTagProps: getTagProps,
|
|
206
|
+
focusTag: focusTag,
|
|
207
|
+
addTag: addTag,
|
|
208
|
+
clearTags: function () {
|
|
209
|
+
setTags([]);
|
|
210
|
+
},
|
|
211
|
+
blur: function () {
|
|
212
|
+
if (focusedIndexRef.current !== -1) {
|
|
213
|
+
focusTag(-1, false);
|
|
214
|
+
}
|
|
215
|
+
setFocused(false);
|
|
216
|
+
},
|
|
217
|
+
// reset: () => {
|
|
218
|
+
// setActiveIndex(-1);
|
|
219
|
+
// },
|
|
220
|
+
focusLast: function () {
|
|
221
|
+
var currTagsLength = tags.length;
|
|
222
|
+
if (currTagsLength > 0) {
|
|
223
|
+
focusTag(currTagsLength - 1);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -27,7 +27,12 @@ export var useRefState = function (value, customUpdate) {
|
|
|
27
27
|
/**
|
|
28
28
|
* update ref value, set isUpdate to `false` will not trigger re-render
|
|
29
29
|
*/
|
|
30
|
-
var setInnerValue = useEventCallback(function (toValue,
|
|
30
|
+
var setInnerValue = useEventCallback(function (toValue,
|
|
31
|
+
/**
|
|
32
|
+
* is re-render
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
isUpdate) {
|
|
31
36
|
if (isUpdate === void 0) { isUpdate = true; }
|
|
32
37
|
innerValueRef.current = toValue;
|
|
33
38
|
if (isUpdate) {
|
|
@@ -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
|
+
};
|
|
@@ -29,7 +29,12 @@ exports.useRefState = function (value, customUpdate) {
|
|
|
29
29
|
/**
|
|
30
30
|
* update ref value, set isUpdate to `false` will not trigger re-render
|
|
31
31
|
*/
|
|
32
|
-
var setInnerValue = useEventCallback_1.useEventCallback(function (toValue,
|
|
32
|
+
var setInnerValue = useEventCallback_1.useEventCallback(function (toValue,
|
|
33
|
+
/**
|
|
34
|
+
* is re-render
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
isUpdate) {
|
|
33
38
|
if (isUpdate === void 0) { isUpdate = true; }
|
|
34
39
|
innerValueRef.current = toValue;
|
|
35
40
|
if (isUpdate) {
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import 'focus-visible';
|
|
2
2
|
import { FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
import { RcThemeInput } from './theme.type';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type RcSubThemeProviderProps = {
|
|
5
5
|
/** custom theme */
|
|
6
6
|
theme?: RcThemeInput;
|
|
7
7
|
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare type RcThemeProviderProps = {
|
|
8
10
|
/** prefix the mui global class */
|
|
9
11
|
prefixGlobalClass?: string;
|
|
10
|
-
};
|
|
12
|
+
} & RcSubThemeProviderProps;
|
|
11
13
|
/**
|
|
12
14
|
* sub theme provider,
|
|
13
15
|
* that will use when you want use multiple theme in one app
|
|
14
16
|
* that will user parent's theme when not set theme
|
|
15
17
|
*/
|
|
16
|
-
export declare const RcSubThemeProvider: FunctionComponent<
|
|
18
|
+
export declare const RcSubThemeProvider: FunctionComponent<RcSubThemeProviderProps>;
|
|
17
19
|
/**
|
|
18
20
|
* theme wrapper, apply in root,
|
|
19
21
|
* each app should always have one `RcThemeProvider` at root,
|