@ringcentral/juno 1.12.4-beta.5841-601f173e → 1.12.4-beta.5882-b67a215e
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/es6/foundation/theme/assets/zIndex.json +1 -2
- 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/{components/Toast/styles → foundation/hooks/useEver}/index.js +1 -1
- 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/foundation/theme/assets/zIndex.json +1 -2
- package/package.json +1 -1
- package/components/Toast/Toast.d.ts +0 -30
- package/components/Toast/Toast.js +0 -49
- package/components/Toast/ToastContainer.d.ts +0 -12
- package/components/Toast/ToastContainer.js +0 -17
- package/components/Toast/index.d.ts +0 -3
- package/components/Toast/index.js +0 -7
- package/components/Toast/styles/ToastStyle.d.ts +0 -4
- package/components/Toast/styles/ToastStyle.js +0 -12
- package/components/Toast/styles/index.d.ts +0 -1
- package/components/Toast/utils/ToastUtils.d.ts +0 -1
- package/components/Toast/utils/ToastUtils.js +0 -3
- package/components/Toast/utils/index.d.ts +0 -1
- package/components/Toast/utils/index.js +0 -4
- package/es6/components/Toast/Toast.js +0 -47
- package/es6/components/Toast/ToastContainer.js +0 -15
- package/es6/components/Toast/index.js +0 -3
- package/es6/components/Toast/styles/ToastStyle.js +0 -10
- package/es6/components/Toast/styles/index.js +0 -1
- package/es6/components/Toast/utils/ToastUtils.js +0 -1
- package/es6/components/Toast/utils/index.js +0 -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,
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { SnackbarCloseReason } from '@material-ui/core';
|
|
2
|
-
import React, { ComponentProps } from 'react';
|
|
3
|
-
import { RcBaseProps } from '../../foundation';
|
|
4
|
-
import { RcPortalProps } from '../Portal';
|
|
5
|
-
import { RcSnackbar } from '../Snackbar';
|
|
6
|
-
declare type ToastCloseReason = Exclude<SnackbarCloseReason, 'clickaway'> | 'dismissButton';
|
|
7
|
-
declare type RcToastProps = {
|
|
8
|
-
/**
|
|
9
|
-
* @default 'RC_TOAST_CONTAINER_ID'
|
|
10
|
-
* like `container` of RcPortal, but you can pass a element id either.
|
|
11
|
-
*/
|
|
12
|
-
container?: RcPortalProps['container'] | 'string';
|
|
13
|
-
/**
|
|
14
|
-
* if you pass id to `container` prop
|
|
15
|
-
* you can use this prop to specify a window
|
|
16
|
-
*/
|
|
17
|
-
getWindow?: () => Window;
|
|
18
|
-
/** If `true`, `toast` is open */
|
|
19
|
-
open: boolean;
|
|
20
|
-
/** trigger when toast close */
|
|
21
|
-
onClose: (event: React.SyntheticEvent<any>, reason: ToastCloseReason) => void;
|
|
22
|
-
/**
|
|
23
|
-
* @default false
|
|
24
|
-
*/
|
|
25
|
-
dismissButton?: boolean;
|
|
26
|
-
} & RcBaseProps<ComponentProps<typeof RcSnackbar>, 'open' | 'onClose' | 'anchorOrigin'>;
|
|
27
|
-
declare const RcToast: import("styled-components").StyledComponentClass<Pick<RcToastProps, "key" | "className" | "color" | "id" | "lang" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "innerRef" | "theme" | "TransitionComponent" | "TransitionProps" | "action" | "message" | "onClose" | "onEnter" | "onEntering" | "onEntered" | "onExit" | "onExiting" | "onExited" | "open" | "transitionDuration" | "container" | "as" | "autoHideDuration" | "ClickAwayListenerProps" | "ContentProps" | "disableWindowBlurListener" | "resumeHideDuration" | "getWindow" | "dismissButton"> & React.RefAttributes<any>, import("../../foundation").RcTheme, Pick<Pick<RcToastProps, "key" | "className" | "color" | "id" | "lang" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "innerRef" | "theme" | "TransitionComponent" | "TransitionProps" | "action" | "message" | "onClose" | "onEnter" | "onEntering" | "onEntered" | "onExit" | "onExiting" | "onExited" | "open" | "transitionDuration" | "container" | "as" | "autoHideDuration" | "ClickAwayListenerProps" | "ContentProps" | "disableWindowBlurListener" | "resumeHideDuration" | "getWindow" | "dismissButton"> & React.RefAttributes<any>, "ref" | "key" | "className" | "color" | "id" | "lang" | "style" | "type" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "slot" | "title" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "innerRef" | "TransitionComponent" | "TransitionProps" | "action" | "message" | "onClose" | "onEnter" | "onEntering" | "onEntered" | "onExit" | "onExiting" | "onExited" | "open" | "transitionDuration" | "container" | "as" | "autoHideDuration" | "ClickAwayListenerProps" | "ContentProps" | "disableWindowBlurListener" | "resumeHideDuration" | "getWindow" | "dismissButton"> & {
|
|
28
|
-
theme?: import("../../foundation").RcTheme | undefined;
|
|
29
|
-
}>;
|
|
30
|
-
export { RcToast, RcToastProps, ToastCloseReason };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
-
var foundation_1 = require("../../foundation");
|
|
6
|
-
var icon_1 = require("../../icon");
|
|
7
|
-
var Portal_1 = require("../Portal");
|
|
8
|
-
var Snackbar_1 = require("../Snackbar");
|
|
9
|
-
var styles_1 = require("./styles");
|
|
10
|
-
var utils_1 = require("./utils");
|
|
11
|
-
var _RcToast = react_1.forwardRef(function (_a, ref) {
|
|
12
|
-
var children = _a.children, _b = _a.container, containerProp = _b === void 0 ? utils_1.RC_TOAST_CONTAINER_ID : _b, getWindow = _a.getWindow, onClose = _a.onClose, _c = _a.ContentProps, ContentPropsInput = _c === void 0 ? {} : _c, _d = _a.dismissButton, dismissButton = _d === void 0 ? false : _d, _e = _a.autoHideDuration, autoHideDuration = _e === void 0 ? 3000 : _e, rest = tslib_1.__rest(_a, ["children", "container", "getWindow", "onClose", "ContentProps", "dismissButton", "autoHideDuration"]);
|
|
13
|
-
var container = (function () {
|
|
14
|
-
var _a;
|
|
15
|
-
// mean containerProp is id
|
|
16
|
-
if (typeof containerProp === 'string') {
|
|
17
|
-
var targetWindow = (_a = getWindow === null || getWindow === void 0 ? void 0 : getWindow()) !== null && _a !== void 0 ? _a : window;
|
|
18
|
-
return targetWindow.document.getElementById(containerProp);
|
|
19
|
-
}
|
|
20
|
-
return containerProp;
|
|
21
|
-
})();
|
|
22
|
-
var action = (function () {
|
|
23
|
-
var originActions = react_1.default.Children.toArray(ContentPropsInput.action);
|
|
24
|
-
if (dismissButton) {
|
|
25
|
-
var closeAction = (react_1.default.createElement(Snackbar_1.RcSnackbarAction, { key: "dismiss-action", variant: "icon", "aria-label": "Dismiss", symbol: icon_1.Close, onClick: function (e) { return handleClose(e, 'dismissButton'); } }));
|
|
26
|
-
return tslib_1.__spread(originActions, [closeAction]);
|
|
27
|
-
}
|
|
28
|
-
return originActions.length === 0 ? null : originActions;
|
|
29
|
-
})();
|
|
30
|
-
var messageAlign = (function () {
|
|
31
|
-
if (action === null || action === void 0 ? void 0 : action.length) {
|
|
32
|
-
return 'left';
|
|
33
|
-
}
|
|
34
|
-
return 'center';
|
|
35
|
-
})();
|
|
36
|
-
var ContentProps = tslib_1.__assign(tslib_1.__assign({}, ContentPropsInput), { action: action,
|
|
37
|
-
messageAlign: messageAlign });
|
|
38
|
-
var handleClose = function (e, reason) {
|
|
39
|
-
if (reason === 'clickaway')
|
|
40
|
-
return;
|
|
41
|
-
onClose(e, reason);
|
|
42
|
-
};
|
|
43
|
-
return (react_1.default.createElement(Portal_1.RcPortal, { container: container },
|
|
44
|
-
react_1.default.createElement(Snackbar_1.RcSnackbar, tslib_1.__assign({}, rest, { autoHideDuration: autoHideDuration, onClose: handleClose, ref: ref, ContentProps: ContentProps }), children)));
|
|
45
|
-
});
|
|
46
|
-
var RcToast = foundation_1.styled(_RcToast)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.ToastStyle);
|
|
47
|
-
exports.RcToast = RcToast;
|
|
48
|
-
RcToast.displayName = 'RcToast';
|
|
49
|
-
var templateObject_1;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { RcPortalProps } from '../Portal';
|
|
3
|
-
declare type RcToastContainerProps = {
|
|
4
|
-
container?: RcPortalProps['container'];
|
|
5
|
-
className?: string;
|
|
6
|
-
/** container id, RcToast can render by this id */
|
|
7
|
-
id?: string;
|
|
8
|
-
};
|
|
9
|
-
declare const RcToastContainer: import("styled-components").StyledComponentClass<RcToastContainerProps & React.RefAttributes<any>, import("../../foundation").RcTheme, Pick<RcToastContainerProps & React.RefAttributes<any>, "ref" | "key" | "className" | "id" | "container"> & {
|
|
10
|
-
theme?: import("../../foundation").RcTheme | undefined;
|
|
11
|
-
}>;
|
|
12
|
-
export { RcToastContainer, RcToastContainerProps };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
-
var foundation_1 = require("../../foundation");
|
|
6
|
-
var Portal_1 = require("../Portal");
|
|
7
|
-
var styles_1 = require("./styles");
|
|
8
|
-
var utils_1 = require("./utils");
|
|
9
|
-
var _RcToastContainer = react_1.forwardRef(function (props, ref) {
|
|
10
|
-
var _a = props.container, container = _a === void 0 ? document.body : _a, _b = props.id, id = _b === void 0 ? utils_1.RC_TOAST_CONTAINER_ID : _b, rest = tslib_1.__rest(props, ["container", "id"]);
|
|
11
|
-
return (react_1.default.createElement(Portal_1.RcPortal, { container: container },
|
|
12
|
-
react_1.default.createElement("div", tslib_1.__assign({}, rest, { id: id, ref: ref }))));
|
|
13
|
-
});
|
|
14
|
-
var RcToastContainer = foundation_1.styled(_RcToastContainer)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.ToastContainerStyle);
|
|
15
|
-
exports.RcToastContainer = RcToastContainer;
|
|
16
|
-
RcToastContainer.displayName = 'RcToastContainer';
|
|
17
|
-
var templateObject_1;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./Toast"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ToastContainer"), exports);
|
|
6
|
-
var styles_1 = require("./styles");
|
|
7
|
-
exports.ToastContainerStyle = styles_1.ToastContainerStyle;
|