@vkontakte/vkui 6.5.3 → 6.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CustomSelect/CustomSelect.d.ts +12 -2
- package/dist/cjs/components/CustomSelect/CustomSelect.d.ts.map +1 -1
- package/dist/cjs/components/CustomSelect/CustomSelect.js +72 -52
- package/dist/cjs/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/cjs/components/CustomSelect/CustomSelectInput.d.ts +1 -3
- package/dist/cjs/components/CustomSelect/CustomSelectInput.d.ts.map +1 -1
- package/dist/cjs/components/CustomSelect/CustomSelectInput.js +24 -19
- package/dist/cjs/components/CustomSelect/CustomSelectInput.js.map +1 -1
- package/dist/components/CustomSelect/CustomSelect.d.ts +12 -2
- package/dist/components/CustomSelect/CustomSelect.d.ts.map +1 -1
- package/dist/components/CustomSelect/CustomSelect.js +64 -44
- package/dist/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/components/CustomSelect/CustomSelectInput.d.ts +1 -3
- package/dist/components/CustomSelect/CustomSelectInput.d.ts.map +1 -1
- package/dist/components/CustomSelect/CustomSelectInput.js +24 -19
- package/dist/components/CustomSelect/CustomSelectInput.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.css.map +1 -1
- package/dist/components.js.tmp +101 -156
- package/dist/cssm/components/CustomSelect/CustomSelect.d.ts +12 -2
- package/dist/cssm/components/CustomSelect/CustomSelect.d.ts.map +1 -1
- package/dist/cssm/components/CustomSelect/CustomSelect.js +60 -41
- package/dist/cssm/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/cssm/components/CustomSelect/CustomSelectInput.d.ts +1 -3
- package/dist/cssm/components/CustomSelect/CustomSelectInput.d.ts.map +1 -1
- package/dist/cssm/components/CustomSelect/CustomSelectInput.js +21 -16
- package/dist/cssm/components/CustomSelect/CustomSelectInput.js.map +1 -1
- package/dist/cssm/components/CustomSelect/CustomSelectInput.module.css +40 -74
- package/dist/vkui.css +1 -1
- package/dist/vkui.css.map +1 -1
- package/dist/vkui.js.tmp +101 -156
- package/package.json +1 -1
- package/src/components/CustomSelect/CustomSelect.tsx +101 -53
- package/src/components/CustomSelect/CustomSelectInput.module.css +35 -55
- package/src/components/CustomSelect/CustomSelectInput.tsx +35 -24
- package/dist/cjs/components/CustomSelect/helpers.d.ts +0 -8
- package/dist/cjs/components/CustomSelect/helpers.d.ts.map +0 -1
- package/dist/cjs/components/CustomSelect/helpers.js +0 -76
- package/dist/cjs/components/CustomSelect/helpers.js.map +0 -1
- package/dist/cjs/components/CustomSelect/types.d.ts +0 -12
- package/dist/cjs/components/CustomSelect/types.d.ts.map +0 -1
- package/dist/cjs/components/CustomSelect/types.js +0 -6
- package/dist/cjs/components/CustomSelect/types.js.map +0 -1
- package/dist/components/CustomSelect/helpers.d.ts +0 -8
- package/dist/components/CustomSelect/helpers.d.ts.map +0 -1
- package/dist/components/CustomSelect/helpers.js +0 -48
- package/dist/components/CustomSelect/helpers.js.map +0 -1
- package/dist/components/CustomSelect/types.d.ts +0 -12
- package/dist/components/CustomSelect/types.d.ts.map +0 -1
- package/dist/components/CustomSelect/types.js +0 -3
- package/dist/components/CustomSelect/types.js.map +0 -1
- package/dist/cssm/components/CustomSelect/helpers.d.ts +0 -8
- package/dist/cssm/components/CustomSelect/helpers.d.ts.map +0 -1
- package/dist/cssm/components/CustomSelect/helpers.js +0 -44
- package/dist/cssm/components/CustomSelect/helpers.js.map +0 -1
- package/dist/cssm/components/CustomSelect/types.d.ts +0 -12
- package/dist/cssm/components/CustomSelect/types.d.ts.map +0 -1
- package/dist/cssm/components/CustomSelect/types.js +0 -3
- package/dist/cssm/components/CustomSelect/types.js.map +0 -1
- package/src/components/CustomSelect/helpers.tsx +0 -61
- package/src/components/CustomSelect/types.ts +0 -15
package/dist/vkui.js.tmp
CHANGED
|
@@ -38505,7 +38505,7 @@ function ChipsSelect_unsupported_iterable_to_array(o, minLen) {
|
|
|
38505
38505
|
|
|
38506
38506
|
|
|
38507
38507
|
|
|
38508
|
-
var
|
|
38508
|
+
var findIndexAfter = function() {
|
|
38509
38509
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1;
|
|
38510
38510
|
if (startIndex >= options.length - 1) {
|
|
38511
38511
|
return -1;
|
|
@@ -38514,7 +38514,7 @@ var ChipsSelect_findIndexAfter = function() {
|
|
|
38514
38514
|
return i > startIndex && (!isNotServicePreset(option) || !option.disabled);
|
|
38515
38515
|
});
|
|
38516
38516
|
};
|
|
38517
|
-
var
|
|
38517
|
+
var findIndexBefore = function() {
|
|
38518
38518
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], endIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : options.length;
|
|
38519
38519
|
var result = -1;
|
|
38520
38520
|
if (endIndex <= 0) {
|
|
@@ -38672,11 +38672,11 @@ var ChipsSelect_findIndexBefore = function() {
|
|
|
38672
38672
|
var focusOption = function(nextIndex, type) {
|
|
38673
38673
|
var index = nextIndex === null ? -1 : nextIndex;
|
|
38674
38674
|
if (type === FOCUS_ACTION_NEXT) {
|
|
38675
|
-
var _$nextIndex =
|
|
38676
|
-
index = _$nextIndex === -1 ?
|
|
38675
|
+
var _$nextIndex = findIndexAfter(options, index);
|
|
38676
|
+
index = _$nextIndex === -1 ? findIndexAfter(options) : _$nextIndex; // Следующий за index или первый валидный до index
|
|
38677
38677
|
} else if (type === FOCUS_ACTION_PREV) {
|
|
38678
|
-
var beforeIndex =
|
|
38679
|
-
index = beforeIndex === -1 ?
|
|
38678
|
+
var beforeIndex = findIndexBefore(options, index);
|
|
38679
|
+
index = beforeIndex === -1 ? findIndexBefore(options) : beforeIndex; // Предшествующий index или последний валидный после index
|
|
38680
38680
|
}
|
|
38681
38681
|
focusOptionByIndex(index, focusedOptionIndex);
|
|
38682
38682
|
};
|
|
@@ -40916,6 +40916,8 @@ function CustomSelectInput_object_without_properties_loose(source, excluded) {
|
|
|
40916
40916
|
|
|
40917
40917
|
|
|
40918
40918
|
|
|
40919
|
+
|
|
40920
|
+
|
|
40919
40921
|
var CustomSelectInput_sizeYClassNames = {
|
|
40920
40922
|
none: "vkuiCustomSelectInput--sizeY-none",
|
|
40921
40923
|
compact: "vkuiCustomSelectInput--sizeY-compact"
|
|
@@ -40924,7 +40926,7 @@ var CustomSelectInput_sizeYClassNames = {
|
|
|
40924
40926
|
* @since 5.10.0
|
|
40925
40927
|
* @private
|
|
40926
40928
|
*/ var CustomSelectInput_CustomSelectInput = function(_param) {
|
|
40927
|
-
var _param_align = _param.align, align = _param_align === void 0 ? 'left' : _param_align, getRef = _param.getRef, className = _param.className, getRootRef = _param.getRootRef, style = _param.style, before = _param.before, after = _param.after, status = _param.status,
|
|
40929
|
+
var _param_align = _param.align, align = _param_align === void 0 ? 'left' : _param_align, getRef = _param.getRef, className = _param.className, getRootRef = _param.getRootRef, style = _param.style, before = _param.before, after = _param.after, status = _param.status, children = _param.children, placeholder = _param.placeholder, _param_selectType = _param.selectType, selectType = _param_selectType === void 0 ? 'default' : _param_selectType, multiline = _param.multiline, disabled = _param.disabled, fetching = _param.fetching, labelTextTestId = _param.labelTextTestId, restProps = CustomSelectInput_object_without_properties(_param, [
|
|
40928
40930
|
"align",
|
|
40929
40931
|
"getRef",
|
|
40930
40932
|
"className",
|
|
@@ -40933,32 +40935,35 @@ var CustomSelectInput_sizeYClassNames = {
|
|
|
40933
40935
|
"before",
|
|
40934
40936
|
"after",
|
|
40935
40937
|
"status",
|
|
40936
|
-
"
|
|
40938
|
+
"children",
|
|
40939
|
+
"placeholder",
|
|
40937
40940
|
"selectType",
|
|
40938
40941
|
"multiline",
|
|
40939
40942
|
"disabled",
|
|
40940
40943
|
"fetching",
|
|
40941
|
-
"labelTextTestId"
|
|
40942
|
-
"searchable"
|
|
40944
|
+
"labelTextTestId"
|
|
40943
40945
|
]);
|
|
40944
40946
|
var _useAdaptivity = useAdaptivity(), _useAdaptivity_sizeY = _useAdaptivity.sizeY, sizeY = _useAdaptivity_sizeY === void 0 ? 'none' : _useAdaptivity_sizeY;
|
|
40947
|
+
var title = children || placeholder;
|
|
40948
|
+
var showLabelOrPlaceholder = !Boolean(restProps.value);
|
|
40945
40949
|
var handleRootRef = useExternRef(getRootRef);
|
|
40946
|
-
var
|
|
40947
|
-
var input = /*#__PURE__*/ React.createElement(
|
|
40948
|
-
selectType: selectType,
|
|
40950
|
+
var focusWithin = useFocusWithin(handleRootRef);
|
|
40951
|
+
var input = /*#__PURE__*/ React.createElement(Text, CustomSelectInput_object_spread_props(CustomSelectInput_object_spread({
|
|
40949
40952
|
type: "text"
|
|
40950
|
-
},
|
|
40953
|
+
}, restProps), {
|
|
40951
40954
|
disabled: disabled && !fetching,
|
|
40952
|
-
readOnly:
|
|
40955
|
+
readOnly: restProps.readOnly || disabled && fetching,
|
|
40953
40956
|
Component: "input",
|
|
40954
40957
|
normalize: false,
|
|
40955
|
-
className: "
|
|
40956
|
-
getRootRef: getRef
|
|
40958
|
+
className: classNames("vkuiCustomSelectInput__el", (restProps.readOnly || showLabelOrPlaceholder && !focusWithin) && "vkuiCustomSelectInput__el--cursor-pointer"),
|
|
40959
|
+
getRootRef: getRef,
|
|
40960
|
+
placeholder: children ? '' : placeholder
|
|
40957
40961
|
}));
|
|
40962
|
+
var platform = usePlatform();
|
|
40958
40963
|
return /*#__PURE__*/ React.createElement(FormField, {
|
|
40959
40964
|
Component: "div",
|
|
40960
40965
|
style: style,
|
|
40961
|
-
className: classNames("vkuiCustomSelectInput", align === 'right' && "vkuiCustomSelectInput--align-right", align === 'center' && "vkuiCustomSelectInput--align-center", !
|
|
40966
|
+
className: classNames("vkuiCustomSelectInput", align === 'right' && "vkuiCustomSelectInput--align-right", align === 'center' && "vkuiCustomSelectInput--align-center", !children && "vkuiCustomSelectInput--empty", multiline && "vkuiCustomSelectInput--multiline", sizeY !== 'regular' && CustomSelectInput_sizeYClassNames[sizeY], before && "vkuiCustomSelectInput--hasBefore", after && "vkuiCustomSelectInput--hasAfter", className),
|
|
40962
40967
|
getRootRef: handleRootRef,
|
|
40963
40968
|
before: before,
|
|
40964
40969
|
after: after,
|
|
@@ -40967,97 +40972,17 @@ var CustomSelectInput_sizeYClassNames = {
|
|
|
40967
40972
|
status: status
|
|
40968
40973
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
40969
40974
|
className: "vkuiCustomSelectInput__input-group"
|
|
40970
|
-
},
|
|
40971
|
-
className: classNames("
|
|
40975
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
40976
|
+
className: classNames("vkuiCustomSelectInput__container", className),
|
|
40972
40977
|
tabIndex: -1,
|
|
40973
40978
|
"aria-hidden": true,
|
|
40974
40979
|
"data-testid": labelTextTestId
|
|
40975
40980
|
}, /*#__PURE__*/ React.createElement(SelectTypography, {
|
|
40976
40981
|
selectType: selectType,
|
|
40977
|
-
className: "
|
|
40978
|
-
},
|
|
40982
|
+
className: "vkuiCustomSelectInput__title"
|
|
40983
|
+
}, showLabelOrPlaceholder && title)), restProps.readOnly && platform === 'ios' ? /*#__PURE__*/ React.createElement(VisuallyHidden, null, input) : input));
|
|
40979
40984
|
};
|
|
40980
40985
|
|
|
40981
|
-
;// CONCATENATED MODULE: ./src/components/CustomSelect/helpers.tsx
|
|
40982
|
-
function helpers_object_without_properties(source, excluded) {
|
|
40983
|
-
if (source == null) return {};
|
|
40984
|
-
var target = helpers_object_without_properties_loose(source, excluded);
|
|
40985
|
-
var key, i;
|
|
40986
|
-
if (Object.getOwnPropertySymbols) {
|
|
40987
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
40988
|
-
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
40989
|
-
key = sourceSymbolKeys[i];
|
|
40990
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
40991
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
40992
|
-
target[key] = source[key];
|
|
40993
|
-
}
|
|
40994
|
-
}
|
|
40995
|
-
return target;
|
|
40996
|
-
}
|
|
40997
|
-
function helpers_object_without_properties_loose(source, excluded) {
|
|
40998
|
-
if (source == null) return {};
|
|
40999
|
-
var target = {};
|
|
41000
|
-
var sourceKeys = Object.keys(source);
|
|
41001
|
-
var key, i;
|
|
41002
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
41003
|
-
key = sourceKeys[i];
|
|
41004
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
41005
|
-
target[key] = source[key];
|
|
41006
|
-
}
|
|
41007
|
-
return target;
|
|
41008
|
-
}
|
|
41009
|
-
|
|
41010
|
-
|
|
41011
|
-
|
|
41012
|
-
var helpers_findIndexAfter = function() {
|
|
41013
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1;
|
|
41014
|
-
if (startIndex >= options.length - 1) {
|
|
41015
|
-
return -1;
|
|
41016
|
-
}
|
|
41017
|
-
return options.findIndex(function(option, i) {
|
|
41018
|
-
return i > startIndex && !option.disabled;
|
|
41019
|
-
});
|
|
41020
|
-
};
|
|
41021
|
-
var helpers_findIndexBefore = function() {
|
|
41022
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], endIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : options.length;
|
|
41023
|
-
var result = -1;
|
|
41024
|
-
if (endIndex <= 0) {
|
|
41025
|
-
return result;
|
|
41026
|
-
}
|
|
41027
|
-
for(var i = endIndex - 1; i >= 0; i--){
|
|
41028
|
-
var option = options[i];
|
|
41029
|
-
if (!option.disabled) {
|
|
41030
|
-
result = i;
|
|
41031
|
-
break;
|
|
41032
|
-
}
|
|
41033
|
-
}
|
|
41034
|
-
return result;
|
|
41035
|
-
};
|
|
41036
|
-
function helpers_findSelectedIndex() {
|
|
41037
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], value = arguments.length > 1 ? arguments[1] : void 0, withClear = arguments.length > 2 ? arguments[2] : void 0;
|
|
41038
|
-
if (withClear && value === '') {
|
|
41039
|
-
return -1;
|
|
41040
|
-
}
|
|
41041
|
-
var _options_findIndex;
|
|
41042
|
-
return (_options_findIndex = options.findIndex(function(item) {
|
|
41043
|
-
value = typeof item.value === 'number' ? Number(value) : value;
|
|
41044
|
-
return item.value === value;
|
|
41045
|
-
})) !== null && _options_findIndex !== void 0 ? _options_findIndex : -1;
|
|
41046
|
-
}
|
|
41047
|
-
function helpers_calculateInputValueFromOptions() {
|
|
41048
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], selectValue = arguments.length > 1 ? arguments[1] : void 0;
|
|
41049
|
-
var selectedOption = options.find(function(option) {
|
|
41050
|
-
return option.value === selectValue;
|
|
41051
|
-
});
|
|
41052
|
-
return selectedOption ? getTextFromChildren(selectedOption.label) : '';
|
|
41053
|
-
}
|
|
41054
|
-
function helpers_defaultRenderOptionFn(_param) {
|
|
41055
|
-
var option = _param.option, props = helpers_object_without_properties(_param, [
|
|
41056
|
-
"option"
|
|
41057
|
-
]);
|
|
41058
|
-
return /*#__PURE__*/ React.createElement(CustomSelectOption, props);
|
|
41059
|
-
}
|
|
41060
|
-
|
|
41061
40986
|
;// CONCATENATED MODULE: ./src/components/CustomSelect/CustomSelect.module.css
|
|
41062
40987
|
// extracted by mini-css-extract-plugin
|
|
41063
40988
|
|
|
@@ -41206,9 +41131,35 @@ function CustomSelect_unsupported_iterable_to_array(o, minLen) {
|
|
|
41206
41131
|
|
|
41207
41132
|
|
|
41208
41133
|
|
|
41134
|
+
|
|
41135
|
+
|
|
41209
41136
|
var CustomSelect_sizeYClassNames = CustomSelect_define_property({
|
|
41210
41137
|
none: "vkuiCustomSelect--sizeY-none"
|
|
41211
41138
|
}, 'compact', "vkuiCustomSelect--sizeY-compact");
|
|
41139
|
+
var CustomSelect_findIndexAfter = function() {
|
|
41140
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1;
|
|
41141
|
+
if (startIndex >= options.length - 1) {
|
|
41142
|
+
return -1;
|
|
41143
|
+
}
|
|
41144
|
+
return options.findIndex(function(option, i) {
|
|
41145
|
+
return i > startIndex && !option.disabled;
|
|
41146
|
+
});
|
|
41147
|
+
};
|
|
41148
|
+
var CustomSelect_findIndexBefore = function() {
|
|
41149
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], endIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : options.length;
|
|
41150
|
+
var result = -1;
|
|
41151
|
+
if (endIndex <= 0) {
|
|
41152
|
+
return result;
|
|
41153
|
+
}
|
|
41154
|
+
for(var i = endIndex - 1; i >= 0; i--){
|
|
41155
|
+
var option = options[i];
|
|
41156
|
+
if (!option.disabled) {
|
|
41157
|
+
result = i;
|
|
41158
|
+
break;
|
|
41159
|
+
}
|
|
41160
|
+
}
|
|
41161
|
+
return result;
|
|
41162
|
+
};
|
|
41212
41163
|
var CustomSelect_warn = warnOnce('CustomSelect');
|
|
41213
41164
|
var checkOptionsValueType = function(options) {
|
|
41214
41165
|
if (new Set(options.map(function(item) {
|
|
@@ -41217,9 +41168,26 @@ var checkOptionsValueType = function(options) {
|
|
|
41217
41168
|
CustomSelect_warn('Некоторые значения ваших опций имеют разные типы. onChange всегда возвращает строковый тип.', 'error');
|
|
41218
41169
|
}
|
|
41219
41170
|
};
|
|
41171
|
+
function defaultRenderOptionFn(_param) {
|
|
41172
|
+
var option = _param.option, props = CustomSelect_object_without_properties(_param, [
|
|
41173
|
+
"option"
|
|
41174
|
+
]);
|
|
41175
|
+
return /*#__PURE__*/ React.createElement(CustomSelectOption, props);
|
|
41176
|
+
}
|
|
41220
41177
|
var handleOptionDown = function(e) {
|
|
41221
41178
|
e.preventDefault();
|
|
41222
41179
|
};
|
|
41180
|
+
function findSelectedIndex() {
|
|
41181
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], value = arguments.length > 1 ? arguments[1] : void 0, withClear = arguments.length > 2 ? arguments[2] : void 0;
|
|
41182
|
+
if (withClear && value === '') {
|
|
41183
|
+
return -1;
|
|
41184
|
+
}
|
|
41185
|
+
var _options_findIndex;
|
|
41186
|
+
return (_options_findIndex = options.findIndex(function(item) {
|
|
41187
|
+
value = typeof item.value === 'number' ? Number(value) : value;
|
|
41188
|
+
return item.value === value;
|
|
41189
|
+
})) !== null && _options_findIndex !== void 0 ? _options_findIndex : -1;
|
|
41190
|
+
}
|
|
41223
41191
|
var filter = function(options, inputValue, filterFn) {
|
|
41224
41192
|
return typeof filterFn === 'function' ? options.filter(function(option) {
|
|
41225
41193
|
return filterFn(inputValue, option);
|
|
@@ -41274,16 +41242,13 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41274
41242
|
var scrollBoxRef = React.useRef(null);
|
|
41275
41243
|
var selectElRef = useExternRef(getRef);
|
|
41276
41244
|
var optionsWrapperRef = React.useRef(null);
|
|
41277
|
-
var selectInputRef = useExternRef(getSelectInputRef);
|
|
41278
41245
|
var _React_useState1 = CustomSelect_sliced_to_array(React.useState(-1), 2), focusedOptionIndex = _React_useState1[0], setFocusedOptionIndex = _React_useState1[1];
|
|
41279
41246
|
var _React_useState2 = CustomSelect_sliced_to_array(React.useState(props.value !== undefined), 2), isControlledOutside = _React_useState2[0], setIsControlledOutside = _React_useState2[1];
|
|
41280
|
-
var _React_useState3 = CustomSelect_sliced_to_array(React.useState(
|
|
41247
|
+
var _React_useState3 = CustomSelect_sliced_to_array(React.useState(''), 2), inputValue = _React_useState3[0], setInputValue = _React_useState3[1];
|
|
41248
|
+
var _React_useState4 = CustomSelect_sliced_to_array(React.useState(function() {
|
|
41281
41249
|
var _props_value, _ref;
|
|
41282
41250
|
return (_ref = (_props_value = props.value) !== null && _props_value !== void 0 ? _props_value : defaultValue) !== null && _ref !== void 0 ? _ref : allowClearButton ? '' : undefined;
|
|
41283
|
-
}), 2), nativeSelectValue =
|
|
41284
|
-
var _React_useState4 = CustomSelect_sliced_to_array(React.useState(function() {
|
|
41285
|
-
return calculateInputValueFromOptions(optionsProp, nativeSelectValue);
|
|
41286
|
-
}), 2), inputValue = _React_useState4[0], setInputValue = _React_useState4[1];
|
|
41251
|
+
}), 2), nativeSelectValue = _React_useState4[0], setNativeSelectValue = _React_useState4[1];
|
|
41287
41252
|
var _React_useState5 = CustomSelect_sliced_to_array(React.useState(popupDirection), 2), popperPlacement = _React_useState5[0], setPopperPlacement = _React_useState5[1];
|
|
41288
41253
|
var _React_useState6 = CustomSelect_sliced_to_array(React.useState(optionsProp), 2), options = _React_useState6[0], setOptions = _React_useState6[1];
|
|
41289
41254
|
var _props_value;
|
|
@@ -41410,6 +41375,7 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41410
41375
|
* Сброс происходит в одном из эффекте `updateOptionsAndSelectedOptionIndex()`.
|
|
41411
41376
|
*/ var close = React.useCallback(function() {
|
|
41412
41377
|
resetKeyboardInput();
|
|
41378
|
+
setInputValue('');
|
|
41413
41379
|
setOpened(false);
|
|
41414
41380
|
resetFocusedOption();
|
|
41415
41381
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
@@ -41420,8 +41386,8 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41420
41386
|
]);
|
|
41421
41387
|
var selectOption = React.useCallback(function(index) {
|
|
41422
41388
|
var item = options[index];
|
|
41423
|
-
close();
|
|
41424
41389
|
setNativeSelectValue(item === null || item === void 0 ? void 0 : item.value);
|
|
41390
|
+
close();
|
|
41425
41391
|
var shouldTriggerOnChangeWhenControlledAndInnerValueIsOutOfSync = isControlledOutside && props.value !== nativeSelectValue && nativeSelectValue === (item === null || item === void 0 ? void 0 : item.value);
|
|
41426
41392
|
if (shouldTriggerOnChangeWhenControlledAndInnerValueIsOutOfSync) {
|
|
41427
41393
|
var _selectElRef_current;
|
|
@@ -41465,23 +41431,18 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41465
41431
|
bubbles: true
|
|
41466
41432
|
});
|
|
41467
41433
|
(_selectElRef_current = selectElRef.current) === null || _selectElRef_current === void 0 ? void 0 : _selectElRef_current.dispatchEvent(event);
|
|
41468
|
-
setInputValue(calculateInputValueFromOptions(optionsProp, nativeSelectValue));
|
|
41469
41434
|
}, [
|
|
41470
41435
|
close,
|
|
41471
|
-
selectElRef
|
|
41472
|
-
optionsProp,
|
|
41473
|
-
nativeSelectValue
|
|
41436
|
+
selectElRef
|
|
41474
41437
|
]);
|
|
41475
41438
|
var onFocus = React.useCallback(function() {
|
|
41476
|
-
var _selectElRef_current
|
|
41439
|
+
var _selectElRef_current;
|
|
41477
41440
|
var event = new Event('focusin', {
|
|
41478
41441
|
bubbles: true
|
|
41479
41442
|
});
|
|
41480
41443
|
(_selectElRef_current = selectElRef.current) === null || _selectElRef_current === void 0 ? void 0 : _selectElRef_current.dispatchEvent(event);
|
|
41481
|
-
(_selectInputRef_current = selectInputRef.current) === null || _selectInputRef_current === void 0 ? void 0 : _selectInputRef_current.select();
|
|
41482
41444
|
}, [
|
|
41483
|
-
selectElRef
|
|
41484
|
-
selectInputRef
|
|
41445
|
+
selectElRef
|
|
41485
41446
|
]);
|
|
41486
41447
|
var onClick = React.useCallback(function() {
|
|
41487
41448
|
if (opened) {
|
|
@@ -41502,11 +41463,11 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41502
41463
|
var focusOption = React.useCallback(function(type) {
|
|
41503
41464
|
var index = focusedOptionIndex;
|
|
41504
41465
|
if (type === 'next') {
|
|
41505
|
-
var nextIndex =
|
|
41506
|
-
index = nextIndex === -1 ?
|
|
41466
|
+
var nextIndex = CustomSelect_findIndexAfter(options, index);
|
|
41467
|
+
index = nextIndex === -1 ? CustomSelect_findIndexAfter(options) : nextIndex; // Следующий за index или первый валидный до index
|
|
41507
41468
|
} else if (type === 'prev') {
|
|
41508
|
-
var beforeIndex =
|
|
41509
|
-
index = beforeIndex === -1 ?
|
|
41469
|
+
var beforeIndex = CustomSelect_findIndexBefore(options, index);
|
|
41470
|
+
index = beforeIndex === -1 ? CustomSelect_findIndexBefore(options) : beforeIndex; // Предшествующий index или последний валидный после index
|
|
41510
41471
|
}
|
|
41511
41472
|
focusOptionByIndex(index);
|
|
41512
41473
|
}, [
|
|
@@ -41514,38 +41475,21 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41514
41475
|
focusedOptionIndex,
|
|
41515
41476
|
options
|
|
41516
41477
|
]);
|
|
41517
|
-
React.useEffect(function
|
|
41478
|
+
React.useEffect(function updateOptionsAndSelectedOptionIndex() {
|
|
41479
|
+
var _props_value, _ref;
|
|
41480
|
+
var value = (_ref = (_props_value = props.value) !== null && _props_value !== void 0 ? _props_value : nativeSelectValue) !== null && _ref !== void 0 ? _ref : defaultValue;
|
|
41518
41481
|
var options = searchable && inputValue !== undefined ? filter(optionsProp, inputValue, filterFn) : optionsProp;
|
|
41519
41482
|
setOptions(options);
|
|
41483
|
+
setSelectedOptionIndex(findSelectedIndex(options, value, allowClearButton));
|
|
41520
41484
|
}, [
|
|
41521
41485
|
filterFn,
|
|
41522
41486
|
inputValue,
|
|
41487
|
+
nativeSelectValue,
|
|
41523
41488
|
optionsProp,
|
|
41524
|
-
|
|
41525
|
-
|
|
41526
|
-
|
|
41527
|
-
|
|
41528
|
-
React.useEffect(function updateSelectedOptionIndexOnValueChange() {
|
|
41529
|
-
setSelectedOptionIndex(findSelectedIndex(options, selectValue, allowClearButton));
|
|
41530
|
-
}, [
|
|
41531
|
-
selectValue,
|
|
41532
|
-
allowClearButton,
|
|
41533
|
-
options
|
|
41534
|
-
]);
|
|
41535
|
-
var prevSelectValueRef = React.useRef(selectValue);
|
|
41536
|
-
React.useEffect(function updateInputValueOnSelectValueChange() {
|
|
41537
|
-
if (prevSelectValueRef.current === selectValue) {
|
|
41538
|
-
return;
|
|
41539
|
-
}
|
|
41540
|
-
setInputValue(calculateInputValueFromOptions(optionsProp, selectValue));
|
|
41541
|
-
}, [
|
|
41542
|
-
selectValue,
|
|
41543
|
-
optionsProp
|
|
41544
|
-
]);
|
|
41545
|
-
React.useEffect(function updatePrevSelectValue() {
|
|
41546
|
-
prevSelectValueRef.current = selectValue;
|
|
41547
|
-
}, [
|
|
41548
|
-
selectValue
|
|
41489
|
+
defaultValue,
|
|
41490
|
+
props.value,
|
|
41491
|
+
searchable,
|
|
41492
|
+
allowClearButton
|
|
41549
41493
|
]);
|
|
41550
41494
|
var onNativeSelectChange = function(e) {
|
|
41551
41495
|
var newSelectedOptionIndex = findSelectedIndex(options, e.currentTarget.value, allowClearButton);
|
|
@@ -41710,6 +41654,7 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41710
41654
|
renderDropdown,
|
|
41711
41655
|
renderOption
|
|
41712
41656
|
]);
|
|
41657
|
+
var selectInputRef = useExternRef(getSelectInputRef);
|
|
41713
41658
|
var focusOnInputTimerRef = React.useRef();
|
|
41714
41659
|
var focusOnInput = React.useCallback(function() {
|
|
41715
41660
|
clearTimeout(focusOnInputTimerRef.current);
|
|
@@ -41790,14 +41735,11 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41790
41735
|
selectInputRef
|
|
41791
41736
|
]);
|
|
41792
41737
|
var preventInputBlurWhenClickInsideFocusedSelectArea = function(e) {
|
|
41793
|
-
var _selectInputRef_current;
|
|
41794
41738
|
// Так как инпут больше не оборачивается пустым лэйблом, то клик внутри обертки,
|
|
41795
41739
|
// но вне инпута (например по иконке дропдауна), будет убирать фокус с инпута.
|
|
41796
41740
|
// Чтобы в такой ситуации отключить blur инпута мы превентим mousedown событие обёртки
|
|
41797
41741
|
var isInputFocused = document && document.activeElement === selectInputRef.current;
|
|
41798
|
-
|
|
41799
|
-
var inputClicked = (_selectInputRef_current = selectInputRef.current) === null || _selectInputRef_current === void 0 ? void 0 : _selectInputRef_current.contains(clickTarget);
|
|
41800
|
-
if (isInputFocused && !inputClicked) {
|
|
41742
|
+
if (isInputFocused) {
|
|
41801
41743
|
e.preventDefault();
|
|
41802
41744
|
}
|
|
41803
41745
|
};
|
|
@@ -41807,15 +41749,19 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41807
41749
|
var selectInputAriaProps = (_obj = {
|
|
41808
41750
|
'role': 'combobox',
|
|
41809
41751
|
'aria-controls': popupAriaId,
|
|
41752
|
+
'aria-owns': popupAriaId,
|
|
41810
41753
|
'aria-expanded': opened
|
|
41811
41754
|
}, CustomSelect_define_property(_obj, 'aria-activedescendant', ariaActiveDescendantId && opened ? "".concat(popupAriaId, "-").concat(ariaActiveDescendantId) : undefined), CustomSelect_define_property(_obj, 'aria-labelledby', ariaLabelledBy), CustomSelect_define_property(_obj, 'aria-haspopup', 'listbox'), CustomSelect_define_property(_obj, 'aria-autocomplete', 'none'), _obj);
|
|
41755
|
+
var focusWithin = useFocusWithin(handleRootRef);
|
|
41812
41756
|
return /*#__PURE__*/ React.createElement("div", {
|
|
41813
41757
|
className: classNames("vkuiCustomSelect", sizeY !== 'regular' && CustomSelect_sizeYClassNames[sizeY], className),
|
|
41814
41758
|
style: style,
|
|
41815
41759
|
ref: handleRootRef,
|
|
41816
41760
|
onClick: passClickAndFocusToInputOnClick,
|
|
41817
41761
|
onMouseDown: preventInputBlurWhenClickInsideFocusedSelectArea
|
|
41818
|
-
}, /*#__PURE__*/ React.createElement(
|
|
41762
|
+
}, focusWithin && selected && !opened && /*#__PURE__*/ React.createElement(VisuallyHidden, {
|
|
41763
|
+
"aria-live": "polite"
|
|
41764
|
+
}, selected.label), /*#__PURE__*/ React.createElement(CustomSelectInput, CustomSelect_object_spread_props(CustomSelect_object_spread({
|
|
41819
41765
|
autoComplete: "off",
|
|
41820
41766
|
autoCapitalize: "none",
|
|
41821
41767
|
autoCorrect: "off",
|
|
@@ -41825,7 +41771,7 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41825
41771
|
onFocus: onFocus,
|
|
41826
41772
|
onBlur: onBlur,
|
|
41827
41773
|
className: openedClassNames,
|
|
41828
|
-
|
|
41774
|
+
readOnly: !searchable,
|
|
41829
41775
|
fetching: fetching,
|
|
41830
41776
|
value: inputValue,
|
|
41831
41777
|
onKeyUp: handleKeyUp,
|
|
@@ -41834,9 +41780,8 @@ var filter = function(options, inputValue, filterFn) {
|
|
|
41834
41780
|
onClick: onClick,
|
|
41835
41781
|
before: before,
|
|
41836
41782
|
after: afterIcons,
|
|
41837
|
-
selectType: selectType
|
|
41838
|
-
|
|
41839
|
-
})), /*#__PURE__*/ React.createElement("select", {
|
|
41783
|
+
selectType: selectType
|
|
41784
|
+
}), selected === null || selected === void 0 ? void 0 : selected.label), /*#__PURE__*/ React.createElement("select", {
|
|
41840
41785
|
ref: selectElRef,
|
|
41841
41786
|
name: name,
|
|
41842
41787
|
onChange: onNativeSelectChange,
|
package/package.json
CHANGED