@ringcentral/juno 1.12.3-beta.5791-ea7a35ca → 1.12.4-beta.5841-601f173e
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/Button/Button.d.ts +2 -2
- package/components/Buttons/Button/styles/StyledButton.js +4 -2
- package/components/Card/Card/Card.d.ts +2 -2
- package/components/Chip/Chip.d.ts +10 -3
- package/components/Chip/Chip.js +5 -3
- package/components/Chip/styles/ChipStyle.js +5 -4
- package/components/Chip/utils/ChipUtils.d.ts +1 -1
- package/components/Chip/utils/ChipUtils.js +1 -1
- package/components/Dialer/DialTextField/DialTextField.d.ts +1 -1
- package/components/Downshift/Downshift.d.ts +20 -9
- package/components/Downshift/Downshift.js +15 -5
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +2 -2
- package/components/Downshift/SuggestionList/SuggestionList.js +12 -6
- package/components/Downshift/SuggestionList/utils/index.d.ts +1 -0
- package/components/Downshift/SuggestionList/utils/index.js +1 -0
- package/components/Downshift/SuggestionList/utils/useSuggestionList.d.ts +298 -0
- package/components/Downshift/SuggestionList/utils/useSuggestionList.js +239 -0
- package/components/Downshift/styles/StyledTextField.d.ts +1 -1
- package/components/Downshift/utils/DownshiftUtils.d.ts +12 -0
- package/components/Downshift/utils/DownshiftUtils.js +19 -1
- package/components/Downshift/utils/SelectItem.d.ts +19 -0
- package/components/Downshift/utils/useDownshift.d.ts +5 -2
- package/components/Downshift/utils/useDownshift.interface.d.ts +5 -0
- package/components/Downshift/utils/useDownshift.js +31 -13
- package/components/Downshift/utils/useDownshiftGroup.d.ts +7 -7
- package/components/Downshift/utils/useDownshiftGroup.js +45 -19
- package/components/Forms/Picker/TimePicker/NumberPicker.js +1 -3
- package/components/Forms/Picker/TimePicker/TimePicker.d.ts +13 -58
- package/components/Forms/Picker/TimePicker/TimePicker.js +15 -21
- package/components/Forms/Picker/TimePicker/index.d.ts +1 -0
- package/components/Forms/Picker/TimePicker/index.js +1 -0
- package/components/Forms/Picker/TimePicker/styles/StyledPickerPopperWrap.d.ts +8 -8
- package/components/Forms/Picker/TimePicker/utils/TimePickerHelper.d.ts +24 -0
- package/components/Forms/Picker/TimePicker/utils/TimePickerHelper.js +25 -1
- package/components/Forms/Picker/styles/StyledPickerTextField.d.ts +1 -1
- package/components/Forms/Select/PlainSelect/PlainSelect.d.ts +1 -1
- package/components/Forms/Select/PlainSelect/PlainSelect.js +5 -4
- package/components/Forms/Select/PlainSelect/styles/StyledSelect.js +4 -3
- package/components/Forms/Select/Select.d.ts +2 -2
- package/components/Forms/Select/Select.js +2 -2
- package/components/Forms/Select/styles/StyledSelect.js +22 -18
- package/components/Forms/TextField/TextField.d.ts +4 -2
- package/components/Forms/TextField/TextField.js +2 -2
- package/components/Forms/TextField/styles/OutlineTextFieldStyle.js +4 -2
- package/components/Forms/TextField/styles/TextFieldStyle.js +8 -4
- package/components/Forms/Textarea/Textarea.d.ts +1 -1
- package/components/Menu/SubMenu/SubMenu.js +1 -1
- package/components/Toast/Toast.d.ts +30 -0
- package/components/Toast/Toast.js +49 -0
- package/components/Toast/ToastContainer.d.ts +12 -0
- package/components/Toast/ToastContainer.js +17 -0
- package/components/Toast/index.d.ts +3 -0
- package/components/Toast/index.js +7 -0
- package/components/Toast/styles/ToastStyle.d.ts +4 -0
- package/components/Toast/styles/ToastStyle.js +12 -0
- package/components/Toast/styles/index.d.ts +1 -0
- package/components/Toast/styles/index.js +4 -0
- package/components/Toast/utils/ToastUtils.d.ts +1 -0
- package/components/Toast/utils/ToastUtils.js +3 -0
- package/components/Toast/utils/index.d.ts +1 -0
- package/components/Toast/utils/index.js +4 -0
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +1 -1
- package/es6/components/Buttons/Button/styles/StyledButton.js +4 -2
- package/es6/components/Chip/Chip.js +6 -4
- package/es6/components/Chip/styles/ChipStyle.js +6 -5
- package/es6/components/Chip/utils/ChipUtils.js +1 -1
- package/es6/components/Downshift/Downshift.js +16 -7
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +13 -7
- package/es6/components/Downshift/SuggestionList/utils/index.js +1 -0
- package/es6/components/Downshift/SuggestionList/utils/useSuggestionList.js +237 -0
- package/es6/components/Downshift/utils/DownshiftUtils.js +19 -1
- package/es6/components/Downshift/utils/useDownshift.js +31 -13
- package/es6/components/Downshift/utils/useDownshiftGroup.js +46 -20
- package/es6/components/Forms/Picker/TimePicker/NumberPicker.js +1 -3
- package/es6/components/Forms/Picker/TimePicker/TimePicker.js +15 -21
- package/es6/components/Forms/Picker/TimePicker/index.js +1 -0
- package/es6/components/Forms/Picker/TimePicker/utils/TimePickerHelper.js +25 -1
- package/es6/components/Forms/Select/PlainSelect/PlainSelect.js +5 -4
- package/es6/components/Forms/Select/PlainSelect/styles/StyledSelect.js +4 -3
- package/es6/components/Forms/Select/Select.js +2 -2
- package/es6/components/Forms/Select/styles/StyledSelect.js +24 -20
- package/es6/components/Forms/TextField/TextField.js +2 -2
- package/es6/components/Forms/TextField/styles/OutlineTextFieldStyle.js +5 -3
- package/es6/components/Forms/TextField/styles/TextFieldStyle.js +9 -5
- package/es6/components/Menu/SubMenu/SubMenu.js +1 -1
- package/es6/components/Toast/Toast.js +47 -0
- package/es6/components/Toast/ToastContainer.js +15 -0
- package/es6/components/Toast/index.js +3 -0
- package/es6/components/Toast/styles/ToastStyle.js +10 -0
- package/es6/components/Toast/styles/index.js +1 -0
- package/es6/components/Toast/utils/ToastUtils.js +1 -0
- package/es6/components/Toast/utils/index.js +1 -0
- package/es6/foundation/config.js +8 -5
- package/es6/foundation/contexts/PortalWindowContext.js +3 -1
- package/es6/foundation/hooks/useAnnouncer/useAnnouncer.js +7 -0
- package/es6/foundation/hooks/useKeyboardMoveFocus/useKeyboardMoveFocus.js +2 -1
- package/es6/foundation/theme/ThemeProvider.js +17 -4
- package/es6/foundation/theme/assets/zIndex.json +2 -1
- package/foundation/config.js +8 -5
- package/foundation/contexts/PortalWindowContext.js +3 -1
- package/foundation/hooks/useAnnouncer/useAnnouncer.d.ts +7 -0
- package/foundation/hooks/useAnnouncer/useAnnouncer.js +7 -0
- package/foundation/hooks/useKeyboardMoveFocus/useKeyboardMoveFocus.js +2 -1
- package/foundation/theme/ThemeProvider.d.ts +2 -0
- package/foundation/theme/ThemeProvider.js +15 -2
- package/foundation/theme/assets/zIndex.json +2 -1
- package/package.json +3 -3
|
@@ -15,32 +15,38 @@ function stringArrToRegExp(keyToTags) {
|
|
|
15
15
|
}
|
|
16
16
|
var componentName = 'RcDownshift';
|
|
17
17
|
export var useDownshift = function (_a) {
|
|
18
|
-
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DEFAULT_KEY_TO_CHIPS : _c, filterOptions = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose;
|
|
18
|
+
var multipleProp = _a.multiple, variant = _a.variant, labelProp = _a.label, inputValueProp = _a.inputValue, _b = _a.getOptionLabel, getOptionLabel = _b === void 0 ? DEFAULT_GET_OPTION_LABEL : _b, _c = _a.keyToTags, keyToTags = _c === void 0 ? DEFAULT_KEY_TO_CHIPS : _c, filterOptions = _a.filterOptions, disabledItemsHighlightable = _a.disabledItemsHighlightable, options = _a.options, freeSolo = _a.freeSolo, onInputChangeProp = _a.onInputChange, maxFreeSolo = _a.maxFreeSolo, onMaxFreeSolo = _a.onMaxFreeSolo, openOnFocus = _a.openOnFocus, disableCloseOnSelect = _a.disableCloseOnSelect, initialIsOpen = _a.initialIsOpen, autoSelect = _a.autoSelect, inputContainerRef = _a.inputContainerRef, inputRef = _a.inputRef, wrapperRef = _a.wrapperRef, onKeyDownProp = _a.onKeyDown, onSelectChange = _a.onChange, _d = _a.value, selectedItemsProp = _d === void 0 ? [] : _d, disabled = _a.disabled, renderNoOptions = _a.renderNoOptions, onClear = _a.onClear, autoHighlight = _a.autoHighlight, getOptionDisabled = _a.getOptionDisabled, addNoOptionItem = _a.addNoOptionItem, groupBy = _a.groupBy, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, getExpandIconProps = _a.getExpandIconProps, required = _a.required, openProp = _a.open, onOpen = _a.onOpen, onClose = _a.onClose, focusedProp = _a.focused;
|
|
19
19
|
var isAutocomplete = variant === 'autocomplete';
|
|
20
20
|
// * when that is autocomplete, that will never be multiple
|
|
21
21
|
var multiple = isAutocomplete ? false : multipleProp;
|
|
22
22
|
var isSelectedFromAutocompleteRef = useRef(false);
|
|
23
|
+
var isInputValueChangedRef = useRef(false);
|
|
23
24
|
var _e = __read(useControlled({
|
|
25
|
+
controlled: focusedProp,
|
|
26
|
+
default: false,
|
|
27
|
+
name: componentName,
|
|
28
|
+
}), 2), isFocused = _e[0], setIsFocused = _e[1];
|
|
29
|
+
var _f = __read(useControlled({
|
|
24
30
|
controlled: openProp,
|
|
25
31
|
default: initialIsOpen || false,
|
|
26
32
|
name: componentName,
|
|
27
|
-
}), 2), isOpen =
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
33
|
+
}), 2), isOpen = _f[0], setIsOpen = _f[1];
|
|
34
|
+
var _g = __read(useState(false), 2), isTagsFocus = _g[0], setIsTagsFocus = _g[1];
|
|
35
|
+
var _h = __read(useState(0), 2), activeIndex = _h[0], setActiveIndex = _h[1];
|
|
36
|
+
var _j = __read(useControlled({
|
|
31
37
|
controlled: inputValueProp,
|
|
32
38
|
default: '',
|
|
33
39
|
name: componentName,
|
|
34
|
-
}), 2), inputValue =
|
|
40
|
+
}), 2), inputValue = _j[0], setInputValue = _j[1];
|
|
35
41
|
var updateInputValue = function (newValue) {
|
|
36
42
|
onInputChangeProp === null || onInputChangeProp === void 0 ? void 0 : onInputChangeProp(newValue);
|
|
37
43
|
setInputValue(newValue);
|
|
38
44
|
};
|
|
39
|
-
var
|
|
45
|
+
var _k = __read(useControlled({
|
|
40
46
|
controlled: selectedItemsProp,
|
|
41
47
|
default: [],
|
|
42
48
|
name: componentName,
|
|
43
|
-
}), 2), selectedItems =
|
|
49
|
+
}), 2), selectedItems = _k[0], setSelectedItems = _k[1];
|
|
44
50
|
var focusInput = function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
45
51
|
var downshiftId = useResultRef(function () { return uniqueId("downshift-"); }).current;
|
|
46
52
|
// * use -2 for us know that is init state, for recalculate defaultHighlightedIndex
|
|
@@ -55,7 +61,7 @@ export var useDownshift = function (_a) {
|
|
|
55
61
|
? true
|
|
56
62
|
: undefined;
|
|
57
63
|
var forceUpdate = useForceUpdate();
|
|
58
|
-
var
|
|
64
|
+
var _l = useSleep(), sleep = _l.sleep, getSleeping = _l.getSleeping;
|
|
59
65
|
var filteredResult = useMemo(function () {
|
|
60
66
|
var getInputValueAsItem = function () {
|
|
61
67
|
var label = inputValue.trim() || '';
|
|
@@ -74,6 +80,7 @@ export var useDownshift = function (_a) {
|
|
|
74
80
|
if (filterOptions) {
|
|
75
81
|
return filterOptions(items, {
|
|
76
82
|
inputValue: inputValue,
|
|
83
|
+
inputChanged: isInputValueChangedRef.current,
|
|
77
84
|
getOptionLabel: getOptionLabel,
|
|
78
85
|
selectedItems: selectedItems,
|
|
79
86
|
});
|
|
@@ -117,16 +124,19 @@ export var useDownshift = function (_a) {
|
|
|
117
124
|
renderNoOptions,
|
|
118
125
|
selectedItems,
|
|
119
126
|
]);
|
|
120
|
-
var
|
|
127
|
+
var _m = useDownshiftGroup({
|
|
121
128
|
groupBy: groupBy,
|
|
122
129
|
options: options,
|
|
123
130
|
filteredResult: filteredResult,
|
|
124
131
|
getExpandIconProps: getExpandIconProps,
|
|
125
132
|
groupExpanded: groupExpanded,
|
|
133
|
+
groupDefaultExpanded: groupDefaultExpanded,
|
|
126
134
|
onGroupExpanded: onGroupExpanded,
|
|
135
|
+
// TODO: single release for that breaking change
|
|
136
|
+
// getOptionDisabled,
|
|
127
137
|
groupVariant: groupVariant,
|
|
128
138
|
id: downshiftId,
|
|
129
|
-
}), groupedResult =
|
|
139
|
+
}), groupedResult = _m.groupedResult, handleGroupExpandedChange = _m.handleGroupExpandedChange, optionsGroupList = _m.optionsGroupList;
|
|
130
140
|
var optionItems = groupBy ? groupedResult : filteredResult;
|
|
131
141
|
var freeSoloCount = useMemo(function () { return selectedItems.filter(function (x) { return x.freeSolo; }).length; }, [selectedItems]);
|
|
132
142
|
var handleSelectedItems = function (_selectedItems) {
|
|
@@ -168,6 +178,7 @@ export var useDownshift = function (_a) {
|
|
|
168
178
|
});
|
|
169
179
|
var closeMenu = function (e, reason) {
|
|
170
180
|
keepHighlightedIndexRef.current = false;
|
|
181
|
+
isInputValueChangedRef.current = false;
|
|
171
182
|
// * set to default highlighted
|
|
172
183
|
setHighlightedIndex(DEFAULT_HIGHLIGHTED_INDEX, { reason: 'auto' });
|
|
173
184
|
if (isOpen) {
|
|
@@ -318,6 +329,7 @@ export var useDownshift = function (_a) {
|
|
|
318
329
|
updateInputValue('');
|
|
319
330
|
}
|
|
320
331
|
isSelectedFromAutocompleteRef.current = false;
|
|
332
|
+
isInputValueChangedRef.current = false;
|
|
321
333
|
setActiveIndex(-1);
|
|
322
334
|
if (!disableCloseOnSelect) {
|
|
323
335
|
closeMenu(e, 'select-option');
|
|
@@ -342,7 +354,7 @@ export var useDownshift = function (_a) {
|
|
|
342
354
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
343
355
|
},
|
|
344
356
|
}).onKeyFocusedIndexHandle;
|
|
345
|
-
var
|
|
357
|
+
var _o = useKeyboardMoveFocus({
|
|
346
358
|
options: optionItems,
|
|
347
359
|
focusedIndexRef: highlightedIndexRef,
|
|
348
360
|
infinite: true,
|
|
@@ -355,7 +367,7 @@ export var useDownshift = function (_a) {
|
|
|
355
367
|
: function (child) {
|
|
356
368
|
return !getIsItemCanSelected(child);
|
|
357
369
|
},
|
|
358
|
-
}), onKeyFocusedIndexHandle =
|
|
370
|
+
}), onKeyFocusedIndexHandle = _o.onKeyFocusedIndexHandle, getNextFocusableOption = _o.getNextFocusableOption;
|
|
359
371
|
var keepHighlightedIndex = function () {
|
|
360
372
|
keepHighlightedIndexRef.current = true;
|
|
361
373
|
};
|
|
@@ -530,9 +542,11 @@ export var useDownshift = function (_a) {
|
|
|
530
542
|
handleSelectedItems([]);
|
|
531
543
|
}
|
|
532
544
|
fromPasteString.current = '';
|
|
545
|
+
isInputValueChangedRef.current = true;
|
|
533
546
|
},
|
|
534
547
|
onFocus: function (e) {
|
|
535
548
|
var _a;
|
|
549
|
+
setIsFocused(true);
|
|
536
550
|
if (openOnFocus)
|
|
537
551
|
openMenu(e);
|
|
538
552
|
// * when autocomplete mode, always select all text when focus
|
|
@@ -546,6 +560,7 @@ export var useDownshift = function (_a) {
|
|
|
546
560
|
}
|
|
547
561
|
},
|
|
548
562
|
onBlur: function (e) {
|
|
563
|
+
setIsFocused(false);
|
|
549
564
|
if (autoSelect && !stopAutoSelectRef.current) {
|
|
550
565
|
if (!freeSolo)
|
|
551
566
|
selectItemFn(optionItems[highlightedIndexRef.current], e);
|
|
@@ -796,6 +811,9 @@ export var useDownshift = function (_a) {
|
|
|
796
811
|
reset: reset,
|
|
797
812
|
forceUpdate: forceUpdate,
|
|
798
813
|
optionsGroupList: optionsGroupList,
|
|
814
|
+
isFocused: isFocused,
|
|
815
|
+
id: downshiftId,
|
|
816
|
+
inputChanged: isInputValueChangedRef.current,
|
|
799
817
|
};
|
|
800
818
|
changeHighlightedIndexReason.current = undefined;
|
|
801
819
|
return resultObj;
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
import { __assign, __read, __spread } from "tslib";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { combineProps, logInDev, omit,
|
|
3
|
+
import { combineProps, logInDev, omit, useDepsChange, useEventCallback, useRefState, } from '../../../foundation';
|
|
4
4
|
export var useDownshiftGroup = function (_a) {
|
|
5
|
-
var groupBy = _a.groupBy, options = _a.options, filteredResult = _a.filteredResult, getExpandIconProps = _a.getExpandIconProps, groupExpanded = _a.groupExpanded, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, id = _a.id;
|
|
5
|
+
var groupBy = _a.groupBy, options = _a.options, filteredResult = _a.filteredResult, getExpandIconProps = _a.getExpandIconProps, groupExpanded = _a.groupExpanded, groupDefaultExpanded = _a.groupDefaultExpanded, onGroupExpanded = _a.onGroupExpanded, groupVariant = _a.groupVariant, getOptionDisabled = _a.getOptionDisabled, id = _a.id;
|
|
6
6
|
var _b = __read(useRefState({}), 2), groupExpandedMapRef = _b[0], setGroupExpandedMap = _b[1];
|
|
7
7
|
var isTitleGroup = groupVariant === 'normal';
|
|
8
|
-
|
|
9
|
-
if (typeof groupExpanded === 'object') {
|
|
10
|
-
setGroupExpandedMap(groupExpanded, false);
|
|
11
|
-
}
|
|
12
|
-
}, function () { return groupExpanded; });
|
|
13
|
-
var handleGroupExpandedChange = function (key) {
|
|
8
|
+
var handleGroupExpandedChange = function (groupName) {
|
|
14
9
|
var _a;
|
|
15
10
|
var groupExpandedMap = groupExpandedMapRef.current;
|
|
16
11
|
if (typeof groupExpanded === 'boolean') {
|
|
17
12
|
return;
|
|
18
13
|
}
|
|
19
|
-
var toExpandedState = !groupExpandedMap[
|
|
20
|
-
var newExpandedMap = __assign(__assign({}, groupExpandedMap), (_a = {}, _a[
|
|
14
|
+
var toExpandedState = !groupExpandedMap[groupName];
|
|
15
|
+
var newExpandedMap = __assign(__assign({}, groupExpandedMap), (_a = {}, _a[groupName] = toExpandedState, _a));
|
|
21
16
|
setGroupExpandedMap(newExpandedMap);
|
|
22
17
|
if (onGroupExpanded) {
|
|
23
|
-
var group = optionsGroupList.find(function (x) { return x.group ===
|
|
18
|
+
var group = optionsGroupList.find(function (x) { return x.group === groupName; });
|
|
24
19
|
if (group) {
|
|
25
20
|
onGroupExpanded(__assign(__assign({}, omit(group, ['getExpandIconProps'])), { expanded: toExpandedState }), newExpandedMap);
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
};
|
|
29
|
-
var handleExpandIconClick = useEventCallback(function (e,
|
|
30
|
-
handleGroupExpandedChange(
|
|
24
|
+
var handleExpandIconClick = useEventCallback(function (e, groupName) {
|
|
25
|
+
handleGroupExpandedChange(groupName);
|
|
31
26
|
e.preventDefault();
|
|
32
27
|
e.stopPropagation();
|
|
33
28
|
});
|
|
@@ -37,7 +32,8 @@ export var useDownshiftGroup = function (_a) {
|
|
|
37
32
|
// used to keep track of key and indexes in the result array
|
|
38
33
|
var indexBy_1 = new Map();
|
|
39
34
|
var warn_1 = false;
|
|
40
|
-
|
|
35
|
+
var afterGroupFn_1 = [];
|
|
36
|
+
var result = filteredResult.reduce(function (acc, option, index) {
|
|
41
37
|
var group = groupBy(option);
|
|
42
38
|
if (acc.length > 0 && acc[acc.length - 1].group === group) {
|
|
43
39
|
acc[acc.length - 1].options.push(__assign(__assign({}, option), { group: acc[acc.length - 1] }));
|
|
@@ -76,41 +72,71 @@ export var useDownshiftGroup = function (_a) {
|
|
|
76
72
|
};
|
|
77
73
|
newGroup_1.options[0].group = newGroup_1;
|
|
78
74
|
if (isTitleGroup) {
|
|
79
|
-
|
|
75
|
+
var groupTitleOption_1 = {
|
|
80
76
|
id: id + "-" + group,
|
|
81
77
|
label: group,
|
|
82
78
|
disabled: true,
|
|
79
|
+
// * here cause by self Type reference
|
|
83
80
|
group: newGroup_1,
|
|
84
|
-
}
|
|
81
|
+
};
|
|
82
|
+
// push fn to array, do that after all options be add into group
|
|
83
|
+
if (getOptionDisabled) {
|
|
84
|
+
afterGroupFn_1.push(function () {
|
|
85
|
+
groupTitleOption_1.disabled =
|
|
86
|
+
getOptionDisabled(groupTitleOption_1);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
newGroup_1.options.unshift(groupTitleOption_1);
|
|
85
90
|
}
|
|
86
91
|
acc.push(newGroup_1);
|
|
87
92
|
}
|
|
88
93
|
return acc;
|
|
89
94
|
}, []);
|
|
95
|
+
afterGroupFn_1.forEach(function (fn) {
|
|
96
|
+
fn();
|
|
97
|
+
});
|
|
98
|
+
return result;
|
|
90
99
|
}
|
|
91
100
|
return [];
|
|
92
101
|
}, [
|
|
93
102
|
filteredResult,
|
|
94
103
|
getExpandIconProps,
|
|
104
|
+
getOptionDisabled,
|
|
95
105
|
groupBy,
|
|
96
106
|
handleExpandIconClick,
|
|
97
107
|
id,
|
|
98
108
|
isTitleGroup,
|
|
99
109
|
options,
|
|
100
110
|
]);
|
|
111
|
+
var initGroupExpandedState = function (expandedState) {
|
|
112
|
+
if (typeof expandedState === 'object') {
|
|
113
|
+
setGroupExpandedMap(expandedState, false);
|
|
114
|
+
}
|
|
115
|
+
else if (typeof expandedState === 'boolean') {
|
|
116
|
+
setGroupExpandedMap(optionsGroupList.reduce(function (prev, curr) {
|
|
117
|
+
prev[curr.group] = expandedState;
|
|
118
|
+
return prev;
|
|
119
|
+
}, {}), false);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
useDepsChange(function () {
|
|
123
|
+
initGroupExpandedState(groupDefaultExpanded);
|
|
124
|
+
}, []);
|
|
125
|
+
useDepsChange(function () {
|
|
126
|
+
initGroupExpandedState(groupExpanded);
|
|
127
|
+
}, [groupExpanded]);
|
|
101
128
|
var groupExpandedMap = groupExpandedMapRef.current;
|
|
102
129
|
// * speared logic with group, prevent calculate every time.
|
|
103
130
|
var groupedResult = useMemo(function () {
|
|
104
131
|
var addExpandedResult = Object.entries(groupExpandedMap).reduce(function (prev, _a) {
|
|
105
132
|
var _b = __read(_a, 2), key = _b[0], expended = _b[1];
|
|
106
133
|
var group = prev.find(function (x) { return x.group === key; });
|
|
107
|
-
if (group)
|
|
134
|
+
if (group)
|
|
108
135
|
group.expanded = expended;
|
|
109
|
-
}
|
|
110
136
|
return prev;
|
|
111
137
|
}, __spread(optionsGroupList));
|
|
112
138
|
return addExpandedResult.reduce(function (prev, curr) {
|
|
113
|
-
if (
|
|
139
|
+
if (curr.expanded) {
|
|
114
140
|
prev.push.apply(prev, __spread(curr.options));
|
|
115
141
|
}
|
|
116
142
|
else {
|
|
@@ -118,7 +144,7 @@ export var useDownshiftGroup = function (_a) {
|
|
|
118
144
|
}
|
|
119
145
|
return prev;
|
|
120
146
|
}, []);
|
|
121
|
-
}, [groupExpandedMap, optionsGroupList
|
|
147
|
+
}, [groupExpandedMap, optionsGroupList]);
|
|
122
148
|
return {
|
|
123
149
|
optionsGroupList: optionsGroupList,
|
|
124
150
|
groupedResult: groupedResult,
|
|
@@ -105,9 +105,7 @@ var _NumberPicker = forwardRef(function (props, ref) {
|
|
|
105
105
|
React.createElement(StyledTimeIconButton, { tabIndex: -1, size: iconSize, color: "neutral.f04", wrapperSize: size, disabled: increaseDisabled, onClick: function () {
|
|
106
106
|
onUpdateValue(increaseValue);
|
|
107
107
|
}, symbol: ArrowUpIcon, "data-test-automation-id": automationId && automationId + "-prev-pagination", "aria-label": "Arrow Up" }),
|
|
108
|
-
React.createElement(StyledTimeIconButton, { wrapperSize: size, tabIndex: -1, onClick: onClick,
|
|
109
|
-
// * when both disabled that icon can't click into selection view
|
|
110
|
-
disabled: increaseDisabled && decreaseDisabled, "data-test-automation-id": automationId && automationId + "-text" },
|
|
108
|
+
React.createElement(StyledTimeIconButton, { wrapperSize: size, tabIndex: -1, onClick: onClick, "data-test-automation-id": automationId && automationId + "-text" },
|
|
111
109
|
React.createElement(React.Fragment, null,
|
|
112
110
|
// TODO: that <></> will fix when `RcIconButton` ready
|
|
113
111
|
showValue)),
|
|
@@ -12,6 +12,7 @@ import { StyledPickerPopperWrap } from './styles';
|
|
|
12
12
|
import { ToggleText } from './ToggleText';
|
|
13
13
|
import { getFormattedTime, getHourAndMinute, getNumberPickerBoundary, getPeriod, getRangeBoundary, getTimestamp, getTimestampFromDate, HALF_DAY_HOURS, minuteSource, parseNumberToString, RcTimePickerClasses, TIME_GAP, timestampToDate, twelveHourSystemSource, twentyFourHourSystemSource, } from './utils';
|
|
14
14
|
var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
15
|
+
var _a;
|
|
15
16
|
var props = useThemeProps({ props: inProps, name: 'RcTimePicker' });
|
|
16
17
|
var isTwelveHourSystem = props.isTwelveHourSystem, value = props.value, times = props.times, onChange = props.onChange, disabled = props.disabled, dateMode = props.dateMode, min = props.min, max = props.max, size = props.size, onKeyDown = props.onKeyDown, onClear = props.onClear, HourPickerProps = props.HourPickerProps, MinutePickerProps = props.MinutePickerProps, PeriodToggleProps = props.PeriodToggleProps, PopoverPropsProp = props.PopoverProps, InputPropsProp = props.InputProps, classes = props.classes, rest = __rest(props, ["isTwelveHourSystem", "value", "times", "onChange", "disabled", "dateMode", "min", "max", "size", "onKeyDown", "onClear", "HourPickerProps", "MinutePickerProps", "PeriodToggleProps", "PopoverProps", "InputProps", "classes"]);
|
|
17
18
|
// TODO: when props remove clear that code, not use forwardRef for Jupiter test issue
|
|
@@ -28,8 +29,8 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
28
29
|
var minuteRef = useRef(null);
|
|
29
30
|
var periodRef = useRef(null);
|
|
30
31
|
var textFiledValueRef = useRef('');
|
|
31
|
-
var
|
|
32
|
-
var nowTime = value
|
|
32
|
+
var _b = __read(useState('none'), 2), selectionShowType = _b[0], setSelectionType = _b[1];
|
|
33
|
+
var nowTime = (_a = value) !== null && _a !== void 0 ? _a : times;
|
|
33
34
|
var isHaveValue = nowTime !== undefined;
|
|
34
35
|
var isDateMode = nowTime instanceof Date || dateMode;
|
|
35
36
|
var currentTimestamp = getTimestamp(nowTime);
|
|
@@ -63,8 +64,8 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
63
64
|
onChange(toValue);
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
|
-
// * when time is zero emit
|
|
67
|
-
onChange(toValue ? getTimestampFromDate(toValue) :
|
|
67
|
+
// * when time is zero emit null
|
|
68
|
+
onChange(toValue ? getTimestampFromDate(toValue) : null);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
}, [isDateMode, onChange]);
|
|
@@ -110,22 +111,8 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
110
111
|
return updateTime({ period: period });
|
|
111
112
|
});
|
|
112
113
|
var handleClear = useEventCallback(function (e) {
|
|
113
|
-
var time;
|
|
114
|
-
// if that is date format, we couldn't reset to undefined, that will miss that date information.
|
|
115
|
-
if (isDateMode) {
|
|
116
|
-
if (range.min.date) {
|
|
117
|
-
time = getEmitInitDate();
|
|
118
|
-
time.setHours(range.min.hour);
|
|
119
|
-
time.setMinutes(range.min.minute);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
time = new Date(nowTime);
|
|
123
|
-
time.setHours(0);
|
|
124
|
-
time.setMinutes(0);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
114
|
onClear === null || onClear === void 0 ? void 0 : onClear(e);
|
|
128
|
-
handleChange(
|
|
115
|
+
handleChange(null);
|
|
129
116
|
});
|
|
130
117
|
var handleSelectionViewClick = useEventCallback(function (toValue) {
|
|
131
118
|
updateTime(isHourView ? { hour: toValue } : { minute: toValue });
|
|
@@ -135,7 +122,9 @@ var _RcTimePicker = forwardRef(function (inProps, ref) {
|
|
|
135
122
|
var _a;
|
|
136
123
|
(_a = actionRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
137
124
|
});
|
|
138
|
-
var setHourSelectionShow = useEventCallback(function () {
|
|
125
|
+
var setHourSelectionShow = useEventCallback(function () {
|
|
126
|
+
return setSelectionType('hour');
|
|
127
|
+
});
|
|
139
128
|
var setMinuteSelectionShow = useEventCallback(function () {
|
|
140
129
|
return setSelectionType('minute');
|
|
141
130
|
});
|
|
@@ -318,5 +307,10 @@ RcTimePicker.defaultProps = {
|
|
|
318
307
|
},
|
|
319
308
|
};
|
|
320
309
|
RcTimePicker.displayName = 'RcTimePicker';
|
|
321
|
-
|
|
310
|
+
/**
|
|
311
|
+
* when `dateMode={true}` that onChange will return `Date` object,
|
|
312
|
+
* otherwise return timestamp `number`
|
|
313
|
+
*/
|
|
314
|
+
var ExportType = RcTimePicker;
|
|
315
|
+
export { ExportType as RcTimePicker };
|
|
322
316
|
var templateObject_1;
|
|
@@ -18,6 +18,12 @@ var pad = function (num, size) {
|
|
|
18
18
|
}
|
|
19
19
|
return s;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* get formatted time hh:mm
|
|
23
|
+
* @param option `{hour, min, period}`
|
|
24
|
+
* @param isTwelveHourSystem boolean
|
|
25
|
+
* @returns `hh:mm AM` or `hh:mm PM` or `hh:mm`
|
|
26
|
+
*/
|
|
21
27
|
var getFormattedTime = function (_a, isTwelveHourSystem) {
|
|
22
28
|
var hour = _a.hour, minute = _a.minute, period = _a.period;
|
|
23
29
|
var formattedHour = parseNumberToString(hour, isTwelveHourSystem);
|
|
@@ -45,9 +51,15 @@ var twelveHourSystemSource = buildConsecutiveNumberToArray(0, 11);
|
|
|
45
51
|
var twentyFourHourSystemSource = buildConsecutiveNumberToArray(0, 23);
|
|
46
52
|
var minuteSource = [0, 15, 30, 45];
|
|
47
53
|
var lastMinute = 45;
|
|
54
|
+
/**
|
|
55
|
+
* hour and minute timestamp
|
|
56
|
+
*/
|
|
48
57
|
var getTimestampFromDate = function (date) {
|
|
49
58
|
return date.getHours() * ONE_HOUR + date.getMinutes() * ONE_MINUTE;
|
|
50
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* hour and minute number
|
|
62
|
+
*/
|
|
51
63
|
var getHourAndMinute = function (times) {
|
|
52
64
|
if (!times) {
|
|
53
65
|
return {
|
|
@@ -59,21 +71,33 @@ var getHourAndMinute = function (times) {
|
|
|
59
71
|
var hour = (times - minute) / ONE_HOUR;
|
|
60
72
|
return {
|
|
61
73
|
hour: hour,
|
|
62
|
-
minute: minute / ONE_MINUTE,
|
|
74
|
+
minute: Math.floor(minute / ONE_MINUTE),
|
|
63
75
|
};
|
|
64
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* timestamp to date
|
|
79
|
+
*/
|
|
65
80
|
var timestampToDate = function (times) {
|
|
66
81
|
var _a = getHourAndMinute(times), hour = _a.hour, minute = _a.minute;
|
|
67
82
|
var date = new Date();
|
|
68
83
|
date.setHours(hour, minute, 0, 0);
|
|
69
84
|
return date;
|
|
70
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* get timestamp from date or timestamp
|
|
88
|
+
*/
|
|
71
89
|
function getTimestamp(nowTime) {
|
|
72
90
|
return nowTime instanceof Date ? getTimestampFromDate(nowTime) : nowTime;
|
|
73
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* hour and min object to timestamp
|
|
94
|
+
*/
|
|
74
95
|
var getTimestampFromHourAndMin = function (option) {
|
|
75
96
|
return option.hour * ONE_HOUR + option.minute * ONE_MINUTE;
|
|
76
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* get period, `PM` or `AM`
|
|
100
|
+
*/
|
|
77
101
|
function getPeriod(currHour) {
|
|
78
102
|
return currHour >= HALF_DAY_HOURS ? TIME_SYSTEM_TEXT.PM : TIME_SYSTEM_TEXT.AM;
|
|
79
103
|
}
|
|
@@ -17,9 +17,9 @@ var plainAnchorOrigin = {
|
|
|
17
17
|
vertical: 'bottom',
|
|
18
18
|
};
|
|
19
19
|
var _RcPlainSelect = forwardRef(function (_a, ref) {
|
|
20
|
-
var children = _a.children, className = _a.className, classes = _a.classes, value = _a.value, renderValue = _a.renderValue, variant = _a.variant, ButtonProps = _a.ButtonProps, innerRef = _a.innerRef, SelectInputProps = _a.SelectInputProps, InputProps = _a.InputProps, disabled = _a.disabled, autoFocus = _a.autoFocus, size = _a.size, virtualize = _a.virtualize, fullWidth = _a.fullWidth,
|
|
20
|
+
var children = _a.children, className = _a.className, classes = _a.classes, value = _a.value, renderValue = _a.renderValue, variant = _a.variant, ButtonProps = _a.ButtonProps, innerRef = _a.innerRef, SelectInputProps = _a.SelectInputProps, InputProps = _a.InputProps, disabled = _a.disabled, autoFocus = _a.autoFocus, size = _a.size, virtualize = _a.virtualize, fullWidth = _a.fullWidth, color = _a.color,
|
|
21
21
|
//
|
|
22
|
-
IconComponent = _a.IconComponent, onOpenProp = _a.onOpen, onCloseProp = _a.onClose, rest = __rest(_a, ["children", "className", "classes", "value", "renderValue", "variant", "ButtonProps", "innerRef", "SelectInputProps", "InputProps", "disabled", "autoFocus", "size", "virtualize", "fullWidth", "IconComponent", "onOpen", "onClose"]);
|
|
22
|
+
IconComponent = _a.IconComponent, onOpenProp = _a.onOpen, onCloseProp = _a.onClose, rest = __rest(_a, ["children", "className", "classes", "value", "renderValue", "variant", "ButtonProps", "innerRef", "SelectInputProps", "InputProps", "disabled", "autoFocus", "size", "virtualize", "fullWidth", "color", "IconComponent", "onOpen", "onClose"]);
|
|
23
23
|
var _b = __read(useState(false), 2), open = _b[0], setOpen = _b[1];
|
|
24
24
|
var display = useMemo(function () {
|
|
25
25
|
var item = children.find(function (child) {
|
|
@@ -29,7 +29,7 @@ var _RcPlainSelect = forwardRef(function (_a, ref) {
|
|
|
29
29
|
}, [children, value]);
|
|
30
30
|
var _renderValue = useCallback(function (value) {
|
|
31
31
|
var _variant = switchVariantToButtonVariant(variant);
|
|
32
|
-
return (React.createElement(RcButton, __assign({ ref: ref, innerRef: innerRef, disabled: disabled, size: size, fullWidth: fullWidth, autoFocus: autoFocus, variant: _variant, "aria-label": "open menu", "aria-haspopup": "listbox" }, combineProps(defaultButtonProps, ButtonProps)),
|
|
32
|
+
return (React.createElement(RcButton, __assign({ ref: ref, innerRef: innerRef, disabled: disabled, size: size, color: color, fullWidth: fullWidth, autoFocus: autoFocus, variant: _variant, "aria-label": "open menu", "aria-haspopup": "listbox" }, combineProps(defaultButtonProps, ButtonProps)),
|
|
33
33
|
renderValue ? renderValue(value) : display,
|
|
34
34
|
(IconComponent && React.createElement(IconComponent, { open: open })) || (React.createElement(SelectArrowDownIcon
|
|
35
35
|
// * reset default color
|
|
@@ -42,6 +42,7 @@ var _RcPlainSelect = forwardRef(function (_a, ref) {
|
|
|
42
42
|
ButtonProps,
|
|
43
43
|
IconComponent,
|
|
44
44
|
autoFocus,
|
|
45
|
+
color,
|
|
45
46
|
disabled,
|
|
46
47
|
display,
|
|
47
48
|
fullWidth,
|
|
@@ -81,7 +82,7 @@ var _RcPlainSelect = forwardRef(function (_a, ref) {
|
|
|
81
82
|
}, onClose: function (e) {
|
|
82
83
|
setOpen(false);
|
|
83
84
|
onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp(e);
|
|
84
|
-
}, SelectInputProps: _SelectInputProps, InputProps: _InputProps, renderValue: _renderValue, fullWidth: fullWidth }, rest), children));
|
|
85
|
+
}, SelectInputProps: _SelectInputProps, InputProps: _InputProps, renderValue: _renderValue, fullWidth: fullWidth, color: color }, rest), children));
|
|
85
86
|
});
|
|
86
87
|
/** @release */
|
|
87
88
|
var RcPlainSelect = styled(_RcPlainSelect)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), plainSelectStyle);
|
|
@@ -11,9 +11,10 @@ export var plainSelectStyle = function (_a) {
|
|
|
11
11
|
var variant = _a.variant, disabled = _a.disabled;
|
|
12
12
|
var isText = variant === 'text';
|
|
13
13
|
var isRound = roundVariant.includes(variant);
|
|
14
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: auto;\n\n ", " {\n ", " {\n margin-right: 0;\n }\n }\n\n ", " {\n margin-right: 0;\n }\n\n .", " {\n margin-bottom: 0;\n }\n\n .", " {\n width: auto;\n pointer-events: none;\n }\n\n .", " {\n padding: 0;\n height: auto;\n }\n\n ", " {\n pointer-events: ", ";\n min-width: unset;\n padding-left: ", ";\n padding-right: ", ";\n border-radius: ", ";\n\n ", " {\n margin: ", ";\n }\n\n ", "\n }\n "], ["\n width: auto;\n\n ",
|
|
15
|
+
" {\n ", " {\n margin-right: 0;\n }\n }\n\n ", " {\n margin-right: 0;\n }\n\n .", " {\n margin-bottom: 0;\n }\n\n .", " {\n width: auto;\n pointer-events: none;\n }\n\n .", " {\n padding: 0;\n height: auto;\n }\n\n ", " {\n pointer-events: ", ";\n min-width: unset;\n padding-left: ", ";\n padding-right: ", ";\n border-radius: ", ";\n\n ", " {\n margin: ", ";\n }\n\n ",
|
|
16
|
+
"\n }\n "])), RcButton /**
|
|
14
17
|
// TODO: cancel button bellow icon margin issue,
|
|
15
|
-
|
|
16
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", " {\n ", " {\n margin-right: 0;\n }\n }\n\n ", " {\n margin-right: 0;\n }\n\n .", " {\n margin-bottom: 0;\n }\n\n .", " {\n width: auto;\n pointer-events: none;\n }\n\n .", " {\n padding: 0;\n height: auto;\n }\n\n ", " {\n pointer-events: ", ";\n min-width: unset;\n padding-left: ", ";\n padding-right: ", ";\n border-radius: ", ";\n\n ", " {\n margin: ", ";\n }\n\n ", "\n }\n "], ["\n ", " {\n ", " {\n margin-right: 0;\n }\n }\n\n ", " {\n margin-right: 0;\n }\n\n .", " {\n margin-bottom: 0;\n }\n\n .", " {\n width: auto;\n pointer-events: none;\n }\n\n .", " {\n padding: 0;\n height: auto;\n }\n\n ", " {\n pointer-events: ", ";\n min-width: unset;\n padding-left: ", ";\n padding-right: ", ";\n border-radius: ", ";\n\n ", " {\n margin: ", ";\n }\n\n ",
|
|
17
|
-
"\n }\n "])), RcButton, RcIcon, RcListItemText, RcTextFieldClasses.root, RcPlainSelectInputClasses.root, RcPlainSelectInputClasses.input, RcButton, !disabled && 'auto', spacing(isText ? 4 : 1), spacing(isText ? 1 : 0), isRound && radius('xxl'), SelectArrowDownIcon, spacing(0, 0, 0, isRound ? 0 : 1), isRound && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n\n ", ", &.Mui-focusVisible {\n .", " {\n background-color: currentColor;\n opacity: ", ";\n }\n .", " {\n display: none;\n }\n }\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n\n ", ", &.Mui-focusVisible {\n .", " {\n background-color: currentColor;\n opacity: ", ";\n }\n .", " {\n display: none;\n }\n }\n "])), spacing(1.5), spacing(1.5), focusVisible, RcPlainSelectTouchRippleClasses.root, opacity('32'), RcPlainSelectTouchRippleClasses.child));
|
|
18
|
+
*/, RcIcon, RcListItemText, RcTextFieldClasses.root, RcPlainSelectInputClasses.root, RcPlainSelectInputClasses.input, RcButton, !disabled && 'auto', spacing(isText ? 4 : 1), spacing(isText ? 1 : 0), isRound && radius('xxl'), SelectArrowDownIcon, spacing(0, 0, 0, isRound ? 0 : 1), isRound && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n\n ", ", &.Mui-focusVisible {\n .", " {\n background-color: currentColor;\n opacity: ", ";\n }\n .", " {\n display: none;\n }\n }\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n\n ", ", &.Mui-focusVisible {\n .", " {\n background-color: currentColor;\n opacity: ", ";\n }\n .", " {\n display: none;\n }\n }\n "])), spacing(1.5), spacing(1.5), focusVisible, RcPlainSelectTouchRippleClasses.root, opacity('32'), RcPlainSelectTouchRippleClasses.child));
|
|
18
19
|
};
|
|
19
20
|
var templateObject_1, templateObject_2;
|
|
@@ -14,7 +14,7 @@ var _RcSelect = forwardRef(function (inProps, ref) {
|
|
|
14
14
|
var props = useThemeProps({ props: inProps, name: 'RcSelect' });
|
|
15
15
|
var children = props.children, onChange = props.onChange, SelectInputPropsProp = props.SelectInputProps, textVariant = props.textVariant, placeholder = props.placeholder, renderValue = props.renderValue, displayEmpty = props.displayEmpty, variant = props.variant, size = props.size, value = props.value, virtualize = props.virtualize,
|
|
16
16
|
// * below is should pick into TextField props
|
|
17
|
-
focused = props.focused, gutterBottom = props.gutterBottom, helperText = props.helperText, label = props.label, id = props.id, className = props.className, validate = props.validate, InputProps = props.InputProps, required = props.required, fullWidth = props.fullWidth, disabled = props.disabled, error = props.error, rest = __rest(props, ["children", "onChange", "SelectInputProps", "textVariant", "placeholder", "renderValue", "displayEmpty", "variant", "size", "value", "virtualize", "focused", "gutterBottom", "helperText", "label", "id", "className", "validate", "InputProps", "required", "fullWidth", "disabled", "error"]);
|
|
17
|
+
focused = props.focused, gutterBottom = props.gutterBottom, helperText = props.helperText, color = props.color, label = props.label, id = props.id, className = props.className, validate = props.validate, InputProps = props.InputProps, required = props.required, fullWidth = props.fullWidth, disabled = props.disabled, error = props.error, rest = __rest(props, ["children", "onChange", "SelectInputProps", "textVariant", "placeholder", "renderValue", "displayEmpty", "variant", "size", "value", "virtualize", "focused", "gutterBottom", "helperText", "color", "label", "id", "className", "validate", "InputProps", "required", "fullWidth", "disabled", "error"]);
|
|
18
18
|
var nonValue = value === undefined ||
|
|
19
19
|
value === null ||
|
|
20
20
|
// * if that can't displayEmpty, and that value === '', same as no value
|
|
@@ -62,7 +62,7 @@ var _RcSelect = forwardRef(function (inProps, ref) {
|
|
|
62
62
|
var valueIsNumber = typeof value === 'number';
|
|
63
63
|
return (React.createElement(RcSelectTextField, { ref: ref, id: id, className: className,
|
|
64
64
|
// for when that is select type that type will be select onChange, just any for ignore that
|
|
65
|
-
onChange: onChange, select: true, focused: focused, gutterBottom: gutterBottom, helperText: helperText, label: label, value: valueIsNumber ? value : value || '', validate: validate, required: required, fullWidth: fullWidth, disabled: disabled, error: error, InputProps: _InputProps, clearBtn: false, placeholder: placeholder, SelectProps: _SelectProps }, children));
|
|
65
|
+
onChange: onChange, color: color, select: true, focused: focused, gutterBottom: gutterBottom, helperText: helperText, label: label, value: valueIsNumber ? value : value || '', validate: validate, required: required, fullWidth: fullWidth, disabled: disabled, error: error, InputProps: _InputProps, clearBtn: false, placeholder: placeholder, SelectProps: _SelectProps }, children));
|
|
66
66
|
});
|
|
67
67
|
var RcSelect = styled(_RcSelect)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), selectStyle);
|
|
68
68
|
RcSelect.displayName = 'RcSelect';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
2
|
-
import { css, fakeBorder, palette2, px, radius, setOpacity, spacing, typography, } from '../../../../foundation';
|
|
1
|
+
import { __assign, __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, fakeBorder, getParsePaletteColor, palette2, px, radius, setOpacity, spacing, typography, } from '../../../../foundation';
|
|
3
3
|
import { disabledColor, placeholderColor } from '../../TextField/styles';
|
|
4
4
|
import { RcBoxSelectInputClasses, RcBoxSelectInputHeights, RcLineSelectInputClasses, RcSelectClasses, RcSelectInputClasses, RcSelectInputWhenPlaceholderClasses, } from '../utils';
|
|
5
5
|
var boxBackgroundColor = palette2('neutral', 'b03');
|
|
@@ -8,23 +8,27 @@ var lineSelectStyle = css(templateObject_1 || (templateObject_1 = __makeTemplate
|
|
|
8
8
|
var textVariant = _a.textVariant;
|
|
9
9
|
return typography(textVariant || 'subheading1');
|
|
10
10
|
}, setOpacity(palette2('action', 'grayDark'), '08'));
|
|
11
|
-
var boxSelectStyle =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
var boxSelectStyle = function (_a) {
|
|
12
|
+
var color = _a.color;
|
|
13
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n > .", " {\n margin-top: ", ";\n box-sizing: border-box;\n height: ", ";\n border-radius: ", ";\n background-color: ", ";\n\n &:not(.", "):hover {\n background-color: ", ";\n }\n\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n border-radius: ", ";\n\n transition: none;\n border-bottom: none !important;\n pointer-events: none;\n ", ";\n }\n\n &:after {\n display: none;\n }\n }\n\n > .", " {\n background-color: ", ";\n\n &:before {\n ", ";\n }\n }\n\n > .", " {\n &:before {\n ", ";\n }\n }\n\n > .", " {\n background-color: ", ";\n &:before {\n ", ";\n }\n }\n\n .", " {\n padding: ", ";\n ", ";\n line-height: ", ";\n\n &:focus {\n background: transparent;\n }\n }\n"], ["\n > .", " {\n margin-top: ", ";\n box-sizing: border-box;\n height: ", ";\n border-radius: ", ";\n background-color: ", ";\n\n &:not(.", "):hover {\n background-color: ", ";\n }\n\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n border-radius: ", ";\n\n transition: none;\n border-bottom: none !important;\n pointer-events: none;\n ", ";\n }\n\n &:after {\n display: none;\n }\n }\n\n > .", " {\n background-color: ", ";\n\n &:before {\n ", ";\n }\n }\n\n > .", " {\n &:before {\n ", ";\n }\n }\n\n > .", " {\n background-color: ", ";\n &:before {\n ", ";\n }\n }\n\n .", " {\n padding: ", ";\n ", ";\n line-height: ",
|
|
14
|
+
";\n\n &:focus {\n background: transparent;\n }\n }\n"])), RcBoxSelectInputClasses.root, function (_a) {
|
|
15
|
+
var label = _a.label;
|
|
16
|
+
return label && spacing(5);
|
|
17
|
+
}, function (_a) {
|
|
18
|
+
var size = _a.size;
|
|
19
|
+
return px(RcBoxSelectInputHeights[size]);
|
|
20
|
+
}, radius('lg'), boxBackgroundColor, RcBoxSelectInputClasses.disabled, setOpacity(boxActionBackgroundColor, '12'), radius('lg'), fakeBorder({ color: palette2('highContrast') }), RcBoxSelectInputClasses.focused, setOpacity(boxActionBackgroundColor, '16'), fakeBorder({ color: color }), RcBoxSelectInputClasses.error, fakeBorder({ color: palette2('danger', 'f02') }), RcBoxSelectInputClasses.disabled, setOpacity(palette2('action', 'grayLight'), '12'), fakeBorder({ color: 'transparent', allowTransparent: true }), RcBoxSelectInputClasses.input, spacing(1.5, 6, 1.5, 2), function (_a) {
|
|
21
|
+
var textVariant = _a.textVariant;
|
|
22
|
+
return typography(textVariant || 'body1');
|
|
23
|
+
}, function (_a) {
|
|
24
|
+
var size = _a.size;
|
|
25
|
+
// here -12 for make this input height same as container
|
|
26
|
+
return px(RcBoxSelectInputHeights[size] - 12);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export var selectStyle = function (props) {
|
|
30
|
+
var variant = props.variant, placeholder = props.placeholder, colorProp = props.color;
|
|
31
|
+
var color = getParsePaletteColor(colorProp, palette2('interactive', 'f01'));
|
|
32
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n .", " {\n color: ", ";\n }\n\n .", " {\n .", " {\n color: ", ";\n }\n }\n\n .", " {\n .", " {\n color: ", ";\n }\n }\n\n .", " {\n color: ", ";\n &:before {\n content: ", ";\n border: none;\n }\n }\n\n .", " {\n color: ", ";\n .", " {\n color: ", ";\n }\n }\n\n ", ";\n ", ";\n "], ["\n .", " {\n color: ", ";\n }\n\n .", " {\n .", " {\n color: ", ";\n }\n }\n\n .", " {\n .", " {\n color: ", ";\n }\n }\n\n .", " {\n color: ", ";\n &:before {\n content: ", ";\n border: none;\n }\n }\n\n .", " {\n color: ", ";\n .", " {\n color: ", ";\n }\n }\n\n ", ";\n ", ";\n "])), RcSelectClasses.icon, palette2('neutral', 'f04'), RcSelectInputClasses.focused, RcSelectClasses.icon, color, RcSelectInputClasses.error, RcSelectClasses.icon, palette2('danger', 'f02'), RcSelectInputWhenPlaceholderClasses.input, placeholderColor, "'" + placeholder + "'", RcSelectInputClasses.disabled, disabledColor, RcSelectClasses.icon, disabledColor, variant === 'line' && lineSelectStyle, variant === 'box' && boxSelectStyle(__assign(__assign({}, props), { color: color })));
|
|
29
33
|
};
|
|
30
34
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -15,9 +15,9 @@ var _RcTextField = forwardRef(function (inProps, ref) {
|
|
|
15
15
|
// TODO: remove when remove focusOnMount
|
|
16
16
|
autoFocusProp = _a === void 0 ? focusOnMount : _a, InputPropsProp = props.InputProps, error = props.error, helperText = props.helperText, defaultValue = props.defaultValue, inputRefProp = props.inputRef, _b = props.autoSelect, autoSelect = _b === void 0 ? selectOnMount : _b, autoFocusDelay = props.autoFocusDelay, clearLabel = props.clearLabel, clearButtonProps = props.clearButtonProps, clearBtn = props.clearBtn, validate = props.validate, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onClear = props.onClear, id = props.id,
|
|
17
17
|
// #region outline pick props
|
|
18
|
-
variant = props.variant, radius = props.radius, size = props.size, align = props.align, textVariant = props.textVariant, gutterBottom = props.gutterBottom,
|
|
18
|
+
variant = props.variant, radius = props.radius, size = props.size, align = props.align, textVariant = props.textVariant, gutterBottom = props.gutterBottom, color = props.color,
|
|
19
19
|
// #endregion
|
|
20
|
-
rest = __rest(props, ["classes", "InputLabelProps", "FormHelperTextProps", "value", "focusOnMount", "selectOnMount", "clearAriaLabel", "autoFocus", "InputProps", "error", "helperText", "defaultValue", "inputRef", "autoSelect", "autoFocusDelay", "clearLabel", "clearButtonProps", "clearBtn", "validate", "onChange", "onBlur", "onFocus", "onClear", "id", "variant", "radius", "size", "align", "textVariant", "gutterBottom"]);
|
|
20
|
+
rest = __rest(props, ["classes", "InputLabelProps", "FormHelperTextProps", "value", "focusOnMount", "selectOnMount", "clearAriaLabel", "autoFocus", "InputProps", "error", "helperText", "defaultValue", "inputRef", "autoSelect", "autoFocusDelay", "clearLabel", "clearButtonProps", "clearBtn", "validate", "onChange", "onBlur", "onFocus", "onClear", "id", "variant", "radius", "size", "align", "textVariant", "gutterBottom", "color"]);
|
|
21
21
|
var formContext = useRcFormContext();
|
|
22
22
|
var innerRef = useRef();
|
|
23
23
|
var inputRef = useForkRef(inputRefProp, innerRef);
|