@alfalab/core-components-select 9.5.0 → 9.6.0

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/Component.d.ts +1 -1
  3. package/dist/Component.js +1 -1
  4. package/dist/components/arrow/Component.js +1 -1
  5. package/dist/components/arrow/index.css +3 -3
  6. package/dist/components/base-select/Component.js +22 -7
  7. package/dist/components/base-select/index.css +7 -7
  8. package/dist/components/base-select/index.js +1 -1
  9. package/dist/components/checkmark/Component.js +1 -1
  10. package/dist/components/checkmark/index.css +3 -3
  11. package/dist/components/field/Component.js +2 -2
  12. package/dist/components/field/index.css +9 -9
  13. package/dist/components/field/index.js +1 -1
  14. package/dist/components/index.js +1 -1
  15. package/dist/components/native-select/Component.js +1 -1
  16. package/dist/components/native-select/index.js +1 -1
  17. package/dist/components/optgroup/Component.js +1 -1
  18. package/dist/components/optgroup/index.css +6 -6
  19. package/dist/components/option/Component.js +2 -2
  20. package/dist/components/option/index.css +20 -20
  21. package/dist/components/option/index.js +1 -1
  22. package/dist/components/options-list/Component.js +1 -1
  23. package/dist/components/options-list/index.css +5 -5
  24. package/dist/components/virtual-options-list/Component.js +1 -1
  25. package/dist/components/virtual-options-list/index.css +11 -11
  26. package/dist/cssm/Component.d.ts +1 -1
  27. package/dist/cssm/components/base-select/Component.js +20 -5
  28. package/dist/cssm/typings.d.ts +4 -0
  29. package/dist/esm/Component.d.ts +1 -1
  30. package/dist/esm/Component.js +1 -1
  31. package/dist/esm/components/arrow/Component.js +1 -1
  32. package/dist/esm/components/arrow/index.css +3 -3
  33. package/dist/esm/components/base-select/Component.js +22 -7
  34. package/dist/esm/components/base-select/index.css +7 -7
  35. package/dist/esm/components/base-select/index.js +1 -1
  36. package/dist/esm/components/checkmark/Component.js +1 -1
  37. package/dist/esm/components/checkmark/index.css +3 -3
  38. package/dist/esm/components/field/Component.js +2 -2
  39. package/dist/esm/components/field/index.css +9 -9
  40. package/dist/esm/components/field/index.js +1 -1
  41. package/dist/esm/components/index.js +1 -1
  42. package/dist/esm/components/native-select/Component.js +1 -1
  43. package/dist/esm/components/native-select/index.js +1 -1
  44. package/dist/esm/components/optgroup/Component.js +1 -1
  45. package/dist/esm/components/optgroup/index.css +6 -6
  46. package/dist/esm/components/option/Component.js +2 -2
  47. package/dist/esm/components/option/index.css +20 -20
  48. package/dist/esm/components/option/index.js +1 -1
  49. package/dist/esm/components/options-list/Component.js +1 -1
  50. package/dist/esm/components/options-list/index.css +5 -5
  51. package/dist/esm/components/virtual-options-list/Component.js +1 -1
  52. package/dist/esm/components/virtual-options-list/index.css +11 -11
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/presets/index.js +1 -1
  55. package/dist/esm/presets/useLazyLoading/hook.js +2 -2
  56. package/dist/esm/presets/useLazyLoading/index.css +2 -2
  57. package/dist/esm/presets/useSelectWithLoading/hook.js +2 -2
  58. package/dist/esm/presets/useSelectWithLoading/index.css +2 -2
  59. package/dist/esm/{tslib.es6-8b45cf3d.d.ts → tslib.es6-569ca735.d.ts} +0 -0
  60. package/dist/esm/{tslib.es6-8b45cf3d.js → tslib.es6-569ca735.js} +0 -0
  61. package/dist/esm/typings.d.ts +4 -0
  62. package/dist/index.js +1 -1
  63. package/dist/modern/Component.d.ts +1 -1
  64. package/dist/modern/components/arrow/Component.js +1 -1
  65. package/dist/modern/components/arrow/index.css +3 -3
  66. package/dist/modern/components/base-select/Component.js +21 -6
  67. package/dist/modern/components/base-select/index.css +7 -7
  68. package/dist/modern/components/checkmark/Component.js +1 -1
  69. package/dist/modern/components/checkmark/index.css +3 -3
  70. package/dist/modern/components/field/Component.js +1 -1
  71. package/dist/modern/components/field/index.css +9 -9
  72. package/dist/modern/components/optgroup/Component.js +1 -1
  73. package/dist/modern/components/optgroup/index.css +6 -6
  74. package/dist/modern/components/option/Component.js +1 -1
  75. package/dist/modern/components/option/index.css +20 -20
  76. package/dist/modern/components/options-list/Component.js +1 -1
  77. package/dist/modern/components/options-list/index.css +5 -5
  78. package/dist/modern/components/virtual-options-list/Component.js +1 -1
  79. package/dist/modern/components/virtual-options-list/index.css +11 -11
  80. package/dist/modern/presets/useLazyLoading/hook.js +1 -1
  81. package/dist/modern/presets/useLazyLoading/index.css +2 -2
  82. package/dist/modern/presets/useSelectWithLoading/hook.js +1 -1
  83. package/dist/modern/presets/useSelectWithLoading/index.css +2 -2
  84. package/dist/modern/typings.d.ts +4 -0
  85. package/dist/presets/index.js +1 -1
  86. package/dist/presets/useLazyLoading/hook.js +2 -2
  87. package/dist/presets/useLazyLoading/index.css +2 -2
  88. package/dist/presets/useSelectWithLoading/hook.js +2 -2
  89. package/dist/presets/useSelectWithLoading/index.css +2 -2
  90. package/dist/{tslib.es6-eca95c76.d.ts → tslib.es6-f19a86c5.d.ts} +0 -0
  91. package/dist/{tslib.es6-eca95c76.js → tslib.es6-f19a86c5.js} +0 -0
  92. package/dist/typings.d.ts +4 -0
  93. package/package.json +2 -2
@@ -82,7 +82,7 @@ type SelectProps = Omit<BaseSelectProps, 'fieldProps'> & {
82
82
  */
83
83
  fieldProps?: FormControlProps & Record<string, unknown>;
84
84
  };
85
- declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "showEmptyOptionsList"> & {
85
+ declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "open" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "showEmptyOptionsList"> & {
86
86
  /**
87
87
  * Пропсы, которые будут прокинуты в компонент поля
88
88
  */
@@ -27,7 +27,7 @@ var getDataTestId = function (dataTestId, element) {
27
27
 
28
28
  var BaseSelect = React.forwardRef(function (_a, ref) {
29
29
  var _b;
30
- var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, options = _a.options, _c = _a.autocomplete, autocomplete = _c === void 0 ? false : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.allowUnselect, allowUnselect = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.closeOnSelect, closeOnSelect = _g === void 0 ? !multiple : _g, _h = _a.circularNavigation, circularNavigation = _h === void 0 ? false : _h, _j = _a.nativeSelect, nativeSelect = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, _l = _a.popoverPosition, popoverPosition = _l === void 0 ? 'bottom-start' : _l, _m = _a.preventFlip, preventFlip = _m === void 0 ? true : _m, _o = _a.optionsListWidth, optionsListWidth = _o === void 0 ? 'content' : _o, name = _a.name, id = _a.id, selected = _a.selected, _p = _a.size, size = _p === void 0 ? 's' : _p, _q = _a.optionsSize, optionsSize = _q === void 0 ? size : _q, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, placeholder = _a.placeholder, _r = _a.fieldProps, fieldProps = _r === void 0 ? {} : _r, _s = _a.optionsListProps, optionsListProps = _s === void 0 ? {} : _s, _t = _a.optionProps, optionProps = _t === void 0 ? {} : _t, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur, onScroll = _a.onScroll, Arrow = _a.Arrow, _u = _a.Field, Field = _u === void 0 ? function () { return null; } : _u, _v = _a.OptionsList, OptionsList = _v === void 0 ? function () { return null; } : _v, _w = _a.Optgroup, Optgroup = _w === void 0 ? function () { return null; } : _w, _x = _a.Option, Option = _x === void 0 ? function () { return null; } : _x, updatePopover = _a.updatePopover, _y = _a.showEmptyOptionsList, showEmptyOptionsList = _y === void 0 ? false : _y, visibleOptions = _a.visibleOptions;
30
+ var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, options = _a.options, _c = _a.autocomplete, autocomplete = _c === void 0 ? false : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.allowUnselect, allowUnselect = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.closeOnSelect, closeOnSelect = _g === void 0 ? !multiple : _g, _h = _a.circularNavigation, circularNavigation = _h === void 0 ? false : _h, _j = _a.nativeSelect, nativeSelect = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, openProp = _a.open, _l = _a.popoverPosition, popoverPosition = _l === void 0 ? 'bottom-start' : _l, _m = _a.preventFlip, preventFlip = _m === void 0 ? true : _m, _o = _a.optionsListWidth, optionsListWidth = _o === void 0 ? 'content' : _o, name = _a.name, id = _a.id, selected = _a.selected, _p = _a.size, size = _p === void 0 ? 's' : _p, _q = _a.optionsSize, optionsSize = _q === void 0 ? size : _q, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, placeholder = _a.placeholder, _r = _a.fieldProps, fieldProps = _r === void 0 ? {} : _r, _s = _a.optionsListProps, optionsListProps = _s === void 0 ? {} : _s, _t = _a.optionProps, optionProps = _t === void 0 ? {} : _t, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur, onScroll = _a.onScroll, Arrow = _a.Arrow, _u = _a.Field, Field = _u === void 0 ? function () { return null; } : _u, _v = _a.OptionsList, OptionsList = _v === void 0 ? function () { return null; } : _v, _w = _a.Optgroup, Optgroup = _w === void 0 ? function () { return null; } : _w, _x = _a.Option, Option = _x === void 0 ? function () { return null; } : _x, updatePopover = _a.updatePopover, _y = _a.showEmptyOptionsList, showEmptyOptionsList = _y === void 0 ? false : _y, visibleOptions = _a.visibleOptions;
31
31
  var rootRef = React.useRef(null);
32
32
  var fieldRef = React.useRef(null);
33
33
  var listRef = React.useRef(null);
@@ -63,16 +63,25 @@ var BaseSelect = React.forwardRef(function (_a, ref) {
63
63
  var _0 = downshift.useMultipleSelection(useMultipleSelectionProps), selectedItems = _0.selectedItems, addSelectedItem = _0.addSelectedItem, setSelectedItems = _0.setSelectedItems, removeSelectedItem = _0.removeSelectedItem, getDropdownProps = _0.getDropdownProps;
64
64
  var _1 = downshift.useCombobox({
65
65
  id: id,
66
+ isOpen: openProp,
66
67
  circularNavigation: circularNavigation,
67
68
  items: flatOptions,
68
69
  itemToString: itemToString,
69
70
  defaultHighlightedIndex: selectedItems.length === 0 ? -1 : undefined,
70
71
  onIsOpenChange: function (changes) {
71
72
  if (onOpen) {
72
- onOpen({
73
- open: changes.isOpen,
74
- name: name,
75
- });
73
+ /**
74
+ * Вызываем обработчик асинхронно.
75
+ *
76
+ * Иначе при клике вне открытого селекта сначала сработает onOpen, который закроет селект,
77
+ * А затем сработает onClick кнопки открытия\закрытия с open=false и в итоге селект откроется снова.
78
+ */
79
+ setTimeout(function () {
80
+ onOpen({
81
+ open: changes.isOpen,
82
+ name: name,
83
+ });
84
+ }, 0);
76
85
  }
77
86
  },
78
87
  stateReducer: function (state, actionAndChanges) {
@@ -176,6 +185,12 @@ var BaseSelect = React.forwardRef(function (_a, ref) {
176
185
  if (defaultOpen)
177
186
  openMenu();
178
187
  }, [defaultOpen, openMenu]);
188
+ React.useEffect(function () {
189
+ if (openProp) {
190
+ openMenu();
191
+ }
192
+ // eslint-disable-next-line react-hooks/exhaustive-deps
193
+ }, []);
179
194
  var calcOptionsListWidth = React.useCallback(function () {
180
195
  if (listRef.current) {
181
196
  var widthAttr = optionsListWidth === 'field' ? 'width' : 'minWidth';
@@ -71,6 +71,10 @@ type BaseSelectProps = {
71
71
  * Начальное состояние селекта
72
72
  */
73
73
  defaultOpen?: boolean;
74
+ /**
75
+ * Управление открытием
76
+ */
77
+ open?: boolean;
74
78
  /**
75
79
  * Возможность выбрать несколько значений
76
80
  */
@@ -82,7 +82,7 @@ type SelectProps = Omit<BaseSelectProps, 'fieldProps'> & {
82
82
  */
83
83
  fieldProps?: FormControlProps & Record<string, unknown>;
84
84
  };
85
- declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "showEmptyOptionsList"> & {
85
+ declare const Select: React.ForwardRefExoticComponent<Pick<BaseSelectProps, "block" | "size" | "className" | "fieldClassName" | "disabled" | "error" | "hint" | "label" | "dataTestId" | "id" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "onScroll" | "preventFlip" | "open" | "name" | "options" | "multiple" | "selected" | "valueRenderer" | "Optgroup" | "visibleOptions" | "Arrow" | "Option" | "optionsListClassName" | "optionClassName" | "autocomplete" | "allowUnselect" | "closeOnSelect" | "circularNavigation" | "nativeSelect" | "defaultOpen" | "popoverPosition" | "optionsListWidth" | "optionsSize" | "optionsListProps" | "optionProps" | "onOpen" | "Field" | "OptionsList" | "updatePopover" | "showEmptyOptionsList"> & {
86
86
  /**
87
87
  * Пропсы, которые будут прокинуты в компонент поля
88
88
  */
@@ -1,4 +1,4 @@
1
- import { _ as __rest, a as __assign } from './tslib.es6-8b45cf3d.js';
1
+ import { _ as __rest, a as __assign } from './tslib.es6-569ca735.js';
2
2
  import React, { forwardRef } from 'react';
3
3
  import 'classnames';
4
4
  import '@alfalab/hooks';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
- var styles = {"arrow":"select__arrow_17g3x","open":"select__open_17g3x"};
4
+ var styles = {"arrow":"select__arrow_t33nf","open":"select__open_t33nf"};
5
5
  require('./index.css')
6
6
 
7
7
  var Arrow = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: 17g3x */
1
+ /* hash: t33nf */
2
2
  :root {
3
3
 
4
4
  /* Hard */
@@ -21,7 +21,7 @@
21
21
 
22
22
  /* optgroup */
23
23
  }
24
- .select__arrow_17g3x {
24
+ .select__arrow_t33nf {
25
25
  display: block;
26
26
  width: 24px;
27
27
  height: 24px;
@@ -31,6 +31,6 @@
31
31
  background-position: center;
32
32
  transition: transform 0.15s ease-in-out, opacity 0.2s ease;
33
33
  }
34
- .select__open_17g3x {
34
+ .select__open_t33nf {
35
35
  transform: var(--arrow-transform);
36
36
  }
@@ -1,4 +1,4 @@
1
- import { a as __assign, b as __spreadArrays, _ as __rest } from '../../tslib.es6-8b45cf3d.js';
1
+ import { a as __assign, b as __spreadArrays, _ as __rest } from '../../tslib.es6-569ca735.js';
2
2
  import React, { forwardRef, useRef, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { processOptions } from '../../utils.js';
@@ -13,12 +13,12 @@ var getDataTestId = function (dataTestId, element) {
13
13
  return dataTestId ? "" + dataTestId + elementPart : undefined;
14
14
  };
15
15
 
16
- var styles = {"component":"select__component_1440x","popoverInner":"select__popoverInner_1440x","optionsList":"select__optionsList_1440x","nativeSelect":"select__nativeSelect_1440x","block":"select__block_1440x"};
16
+ var styles = {"component":"select__component_1uqsl","popoverInner":"select__popoverInner_1uqsl","optionsList":"select__optionsList_1uqsl","nativeSelect":"select__nativeSelect_1uqsl","block":"select__block_1uqsl"};
17
17
  require('./index.css')
18
18
 
19
19
  var BaseSelect = forwardRef(function (_a, ref) {
20
20
  var _b;
21
- var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, options = _a.options, _c = _a.autocomplete, autocomplete = _c === void 0 ? false : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.allowUnselect, allowUnselect = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.closeOnSelect, closeOnSelect = _g === void 0 ? !multiple : _g, _h = _a.circularNavigation, circularNavigation = _h === void 0 ? false : _h, _j = _a.nativeSelect, nativeSelect = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, _l = _a.popoverPosition, popoverPosition = _l === void 0 ? 'bottom-start' : _l, _m = _a.preventFlip, preventFlip = _m === void 0 ? true : _m, _o = _a.optionsListWidth, optionsListWidth = _o === void 0 ? 'content' : _o, name = _a.name, id = _a.id, selected = _a.selected, _p = _a.size, size = _p === void 0 ? 's' : _p, _q = _a.optionsSize, optionsSize = _q === void 0 ? size : _q, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, placeholder = _a.placeholder, _r = _a.fieldProps, fieldProps = _r === void 0 ? {} : _r, _s = _a.optionsListProps, optionsListProps = _s === void 0 ? {} : _s, _t = _a.optionProps, optionProps = _t === void 0 ? {} : _t, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur, onScroll = _a.onScroll, Arrow = _a.Arrow, _u = _a.Field, Field = _u === void 0 ? function () { return null; } : _u, _v = _a.OptionsList, OptionsList = _v === void 0 ? function () { return null; } : _v, _w = _a.Optgroup, Optgroup = _w === void 0 ? function () { return null; } : _w, _x = _a.Option, Option = _x === void 0 ? function () { return null; } : _x, updatePopover = _a.updatePopover, _y = _a.showEmptyOptionsList, showEmptyOptionsList = _y === void 0 ? false : _y, visibleOptions = _a.visibleOptions;
21
+ var dataTestId = _a.dataTestId, className = _a.className, fieldClassName = _a.fieldClassName, optionsListClassName = _a.optionsListClassName, optionClassName = _a.optionClassName, options = _a.options, _c = _a.autocomplete, autocomplete = _c === void 0 ? false : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.allowUnselect, allowUnselect = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.closeOnSelect, closeOnSelect = _g === void 0 ? !multiple : _g, _h = _a.circularNavigation, circularNavigation = _h === void 0 ? false : _h, _j = _a.nativeSelect, nativeSelect = _j === void 0 ? false : _j, _k = _a.defaultOpen, defaultOpen = _k === void 0 ? false : _k, openProp = _a.open, _l = _a.popoverPosition, popoverPosition = _l === void 0 ? 'bottom-start' : _l, _m = _a.preventFlip, preventFlip = _m === void 0 ? true : _m, _o = _a.optionsListWidth, optionsListWidth = _o === void 0 ? 'content' : _o, name = _a.name, id = _a.id, selected = _a.selected, _p = _a.size, size = _p === void 0 ? 's' : _p, _q = _a.optionsSize, optionsSize = _q === void 0 ? size : _q, error = _a.error, hint = _a.hint, block = _a.block, label = _a.label, placeholder = _a.placeholder, _r = _a.fieldProps, fieldProps = _r === void 0 ? {} : _r, _s = _a.optionsListProps, optionsListProps = _s === void 0 ? {} : _s, _t = _a.optionProps, optionProps = _t === void 0 ? {} : _t, valueRenderer = _a.valueRenderer, onChange = _a.onChange, onOpen = _a.onOpen, onFocus = _a.onFocus, onBlur = _a.onBlur, onScroll = _a.onScroll, Arrow = _a.Arrow, _u = _a.Field, Field = _u === void 0 ? function () { return null; } : _u, _v = _a.OptionsList, OptionsList = _v === void 0 ? function () { return null; } : _v, _w = _a.Optgroup, Optgroup = _w === void 0 ? function () { return null; } : _w, _x = _a.Option, Option = _x === void 0 ? function () { return null; } : _x, updatePopover = _a.updatePopover, _y = _a.showEmptyOptionsList, showEmptyOptionsList = _y === void 0 ? false : _y, visibleOptions = _a.visibleOptions;
22
22
  var rootRef = useRef(null);
23
23
  var fieldRef = useRef(null);
24
24
  var listRef = useRef(null);
@@ -54,16 +54,25 @@ var BaseSelect = forwardRef(function (_a, ref) {
54
54
  var _0 = useMultipleSelection(useMultipleSelectionProps), selectedItems = _0.selectedItems, addSelectedItem = _0.addSelectedItem, setSelectedItems = _0.setSelectedItems, removeSelectedItem = _0.removeSelectedItem, getDropdownProps = _0.getDropdownProps;
55
55
  var _1 = useCombobox({
56
56
  id: id,
57
+ isOpen: openProp,
57
58
  circularNavigation: circularNavigation,
58
59
  items: flatOptions,
59
60
  itemToString: itemToString,
60
61
  defaultHighlightedIndex: selectedItems.length === 0 ? -1 : undefined,
61
62
  onIsOpenChange: function (changes) {
62
63
  if (onOpen) {
63
- onOpen({
64
- open: changes.isOpen,
65
- name: name,
66
- });
64
+ /**
65
+ * Вызываем обработчик асинхронно.
66
+ *
67
+ * Иначе при клике вне открытого селекта сначала сработает onOpen, который закроет селект,
68
+ * А затем сработает onClick кнопки открытия\закрытия с open=false и в итоге селект откроется снова.
69
+ */
70
+ setTimeout(function () {
71
+ onOpen({
72
+ open: changes.isOpen,
73
+ name: name,
74
+ });
75
+ }, 0);
67
76
  }
68
77
  },
69
78
  stateReducer: function (state, actionAndChanges) {
@@ -167,6 +176,12 @@ var BaseSelect = forwardRef(function (_a, ref) {
167
176
  if (defaultOpen)
168
177
  openMenu();
169
178
  }, [defaultOpen, openMenu]);
179
+ useEffect(function () {
180
+ if (openProp) {
181
+ openMenu();
182
+ }
183
+ // eslint-disable-next-line react-hooks/exhaustive-deps
184
+ }, []);
170
185
  var calcOptionsListWidth = useCallback(function () {
171
186
  if (listRef.current) {
172
187
  var widthAttr = optionsListWidth === 'field' ? 'width' : 'minWidth';
@@ -1,4 +1,4 @@
1
- /* hash: 1440x */
1
+ /* hash: 1uqsl */
2
2
  :root {
3
3
  --color-light-bg-primary: #fff;
4
4
  }
@@ -28,12 +28,12 @@
28
28
 
29
29
  /* optgroup */
30
30
  }
31
- .select__component_1440x {
31
+ .select__component_1uqsl {
32
32
  width: max-content;
33
33
  position: relative;
34
34
  outline: 0;
35
35
  }
36
- .select__popoverInner_1440x {
36
+ .select__popoverInner_1uqsl {
37
37
  padding-top: var(--select-options-list-offset);
38
38
  padding-bottom: var(--select-options-list-offset);
39
39
  box-shadow: none;
@@ -42,7 +42,7 @@
42
42
  border-radius: 0;
43
43
  position: relative;
44
44
  }
45
- .select__optionsList_1440x {
45
+ .select__optionsList_1uqsl {
46
46
  padding-top: var(--select-options-list-top-padding);
47
47
  padding-bottom: var(--select-options-list-bottom-padding);
48
48
  box-shadow: var(--select-options-list-box-shadow);
@@ -51,7 +51,7 @@
51
51
  overflow: hidden;
52
52
  will-change: transform;
53
53
  }
54
- .select__nativeSelect_1440x {
54
+ .select__nativeSelect_1uqsl {
55
55
  opacity: 0;
56
56
  overflow: hidden;
57
57
  position: absolute;
@@ -65,12 +65,12 @@
65
65
  cursor: pointer;
66
66
  z-index: 1;
67
67
  }
68
- .select__block_1440x {
68
+ .select__block_1uqsl {
69
69
  width: 100%;
70
70
  }
71
71
  /* width: max-content; fix for IE */
72
72
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
73
- .select__component_1440x {
73
+ .select__component_1uqsl {
74
74
  float: left;
75
75
  clear: left;
76
76
  }
@@ -1,4 +1,4 @@
1
- import '../../tslib.es6-8b45cf3d.js';
1
+ import '../../tslib.es6-569ca735.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '../../utils.js';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
- var styles = {"checkmark":"select__checkmark_1fsd3","selected":"select__selected_1fsd3"};
4
+ var styles = {"checkmark":"select__checkmark_1yq1s","selected":"select__selected_1yq1s"};
5
5
  require('./index.css')
6
6
 
7
7
  var Checkmark = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: 1fsd3 */
1
+ /* hash: 1yq1s */
2
2
  :root {
3
3
  --color-light-graphic-primary: #0b1f35;
4
4
  }
@@ -33,7 +33,7 @@
33
33
 
34
34
  /* optgroup */
35
35
  }
36
- .select__checkmark_1fsd3 {
36
+ .select__checkmark_1yq1s {
37
37
  display: flex;
38
38
  align-items: center;
39
39
  justify-content: center;
@@ -47,6 +47,6 @@
47
47
  width: var(--select-checkmark-size);
48
48
  height: var(--select-checkmark-size);
49
49
  }
50
- .select__selected_1fsd3 {
50
+ .select__selected_1yq1s {
51
51
  opacity: 1;
52
52
  }
@@ -1,11 +1,11 @@
1
- import { _ as __rest, a as __assign } from '../../tslib.es6-8b45cf3d.js';
1
+ import { _ as __rest, a as __assign } from '../../tslib.es6-569ca735.js';
2
2
  import React, { useState, useRef, useCallback } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { useFocus } from '@alfalab/hooks';
5
5
  import { FormControl } from '@alfalab/core-components-form-control/dist/esm';
6
6
  import { joinOptions } from '../../utils.js';
7
7
 
8
- var styles = {"component":"select__component_zeyst","field":"select__field_zeyst","disabled":"select__disabled_zeyst","arrow":"select__arrow_zeyst","placeholder":"select__placeholder_zeyst","contentWrapper":"select__contentWrapper_zeyst","value":"select__value_zeyst","focusVisible":"select__focusVisible_zeyst"};
8
+ var styles = {"component":"select__component_vno7x","field":"select__field_vno7x","disabled":"select__disabled_vno7x","arrow":"select__arrow_vno7x","placeholder":"select__placeholder_vno7x","contentWrapper":"select__contentWrapper_vno7x","value":"select__value_vno7x","focusVisible":"select__focusVisible_vno7x"};
9
9
  require('./index.css')
10
10
 
11
11
  var Field = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: zeyst */
1
+ /* hash: vno7x */
2
2
  :root {
3
3
  --color-light-border-link: #007aff;
4
4
  --color-light-text-secondary: #546272;
@@ -26,24 +26,24 @@
26
26
 
27
27
  /* optgroup */
28
28
  }
29
- .select__component_zeyst {
29
+ .select__component_vno7x {
30
30
  width: 100%;
31
31
  outline: none;
32
32
  }
33
- .select__field_zeyst:not(.select__disabled_zeyst) {
33
+ .select__field_vno7x:not(.select__disabled_vno7x) {
34
34
  cursor: pointer
35
35
  }
36
- .select__field_zeyst:not(.select__disabled_zeyst):hover .select__arrow_zeyst {
36
+ .select__field_vno7x:not(.select__disabled_vno7x):hover .select__arrow_vno7x {
37
37
  opacity: var(--select-arrow-hover-opacity);
38
38
  }
39
- .select__disabled_zeyst {
39
+ .select__disabled_vno7x {
40
40
  cursor: var(--disabled-cursor);
41
41
  }
42
42
  /* TODO: Заюзать переменные из инпута */
43
- .select__placeholder_zeyst {
43
+ .select__placeholder_vno7x {
44
44
  color: var(--color-light-text-secondary);
45
45
  }
46
- .select__contentWrapper_zeyst {
46
+ .select__contentWrapper_vno7x {
47
47
  font-size: 16px;
48
48
  line-height: 20px;
49
49
  font-weight: 400;
@@ -53,12 +53,12 @@
53
53
  overflow: hidden;
54
54
  width: 100%;
55
55
  }
56
- .select__value_zeyst {
56
+ .select__value_vno7x {
57
57
  overflow: hidden;
58
58
  text-overflow: ellipsis;
59
59
  text-align: left;
60
60
  }
61
- .select__focusVisible_zeyst {
61
+ .select__focusVisible_vno7x {
62
62
  outline: 2px solid var(--focus-color);
63
63
  outline-offset: 2px;
64
64
  }
@@ -1,4 +1,4 @@
1
- import '../../tslib.es6-8b45cf3d.js';
1
+ import '../../tslib.es6-569ca735.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '@alfalab/hooks';
@@ -1,4 +1,4 @@
1
- import '../tslib.es6-8b45cf3d.js';
1
+ import '../tslib.es6-569ca735.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '@alfalab/hooks';
@@ -1,4 +1,4 @@
1
- import { _ as __rest, a as __assign } from '../../tslib.es6-8b45cf3d.js';
1
+ import { _ as __rest, a as __assign } from '../../tslib.es6-569ca735.js';
2
2
  import React, { forwardRef, useCallback } from 'react';
3
3
  import { isGroup } from '../../utils.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import '../../tslib.es6-8b45cf3d.js';
1
+ import '../../tslib.es6-569ca735.js';
2
2
  import 'react';
3
3
  import '../../utils.js';
4
4
  export { NativeSelect } from './Component.js';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
- var styles = {"optgroup":"select__optgroup_1d5ga","label":"select__label_1d5ga","l":"select__l_1d5ga","xl":"select__xl_1d5ga"};
4
+ var styles = {"optgroup":"select__optgroup_q5inb","label":"select__label_q5inb","l":"select__l_q5inb","xl":"select__xl_q5inb"};
5
5
  require('./index.css')
6
6
 
7
7
  var Optgroup = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: 1d5ga */
1
+ /* hash: q5inb */
2
2
  :root {
3
3
  --color-light-bg-primary: #fff;
4
4
  --color-light-text-secondary: #546272;
@@ -33,7 +33,7 @@
33
33
  --select-optgroup-l-left-padding: var(--gap-m);
34
34
  --select-optgroup-l-right-padding: var(--gap-m);
35
35
  }
36
- .select__optgroup_1d5ga {
36
+ .select__optgroup_q5inb {
37
37
  position: relative;
38
38
  display: flex;
39
39
  align-items: center;
@@ -43,10 +43,10 @@
43
43
  background: var(--select-optgroup-background);
44
44
  min-height: 40px
45
45
  }
46
- .select__optgroup_1d5ga + *[role='option']:before {
46
+ .select__optgroup_q5inb + *[role='option']:before {
47
47
  display: none;
48
48
  }
49
- .select__label_1d5ga {
49
+ .select__label_q5inb {
50
50
  font-size: 12px;
51
51
  line-height: 16px;
52
52
  font-weight: 500;
@@ -56,8 +56,8 @@
56
56
  display: block;
57
57
  color: var(--select-optgroup-color);
58
58
  }
59
- .select__l_1d5ga,
60
- .select__xl_1d5ga {
59
+ .select__l_q5inb,
60
+ .select__xl_q5inb {
61
61
  padding-left: var(--select-optgroup-l-left-padding);
62
62
  padding-right: var(--select-optgroup-l-right-padding);
63
63
  }
@@ -1,9 +1,9 @@
1
- import { a as __assign } from '../../tslib.es6-8b45cf3d.js';
1
+ import { a as __assign } from '../../tslib.es6-569ca735.js';
2
2
  import React, { isValidElement } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { Checkmark } from '../checkmark/Component.js';
5
5
 
6
- var styles = {"option":"select__option_szlk5","disabled":"select__disabled_szlk5","s":"select__s_szlk5","m":"select__m_szlk5","l":"select__l_szlk5","xl":"select__xl_szlk5","selected":"select__selected_szlk5","highlighted":"select__highlighted_szlk5","content":"select__content_szlk5","textContent":"select__textContent_szlk5"};
6
+ var styles = {"option":"select__option_1g0al","disabled":"select__disabled_1g0al","s":"select__s_1g0al","m":"select__m_1g0al","l":"select__l_1g0al","xl":"select__xl_1g0al","selected":"select__selected_1g0al","highlighted":"select__highlighted_1g0al","content":"select__content_1g0al","textContent":"select__textContent_1g0al"};
7
7
  require('./index.css')
8
8
 
9
9
  var Option = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: szlk5 */
1
+ /* hash: 1g0al */
2
2
  :root {
3
3
  --color-light-bg-primary: #fff;
4
4
  --color-light-bg-secondary: #f3f4f5;
@@ -53,7 +53,7 @@
53
53
 
54
54
  /* optgroup */
55
55
  }
56
- .select__option_szlk5 {
56
+ .select__option_1g0al {
57
57
  font-size: 16px;
58
58
  line-height: 20px;
59
59
  font-weight: 400;
@@ -69,11 +69,11 @@
69
69
  position: relative;
70
70
  cursor: pointer
71
71
  }
72
- .select__option_szlk5:not(.select__disabled_szlk5):active {
72
+ .select__option_1g0al:not(.select__disabled_1g0al):active {
73
73
  background: var(--select-option-active-background);
74
74
  color: var(--select-option-active-color);
75
75
  }
76
- .select__option_szlk5:before {
76
+ .select__option_1g0al:before {
77
77
  content: '';
78
78
  position: absolute;
79
79
  left: var(--select-option-left-padding);
@@ -84,60 +84,60 @@
84
84
  display: var(--select-option-divider-display);
85
85
  transition: opacity 0.2s ease;
86
86
  }
87
- .select__option_szlk5:first-child:before {
87
+ .select__option_1g0al:first-child:before {
88
88
  display: none;
89
89
  }
90
- .select__s_szlk5 {
90
+ .select__s_1g0al {
91
91
  min-height: var(--size-s-height);
92
92
  }
93
- .select__m_szlk5 {
93
+ .select__m_1g0al {
94
94
  min-height: var(--size-m-height);
95
95
  }
96
- .select__l_szlk5 {
96
+ .select__l_1g0al {
97
97
  min-height: var(--size-l-height);
98
98
  }
99
- .select__xl_szlk5 {
99
+ .select__xl_1g0al {
100
100
  min-height: var(--size-xl-height);
101
101
  }
102
- .select__l_szlk5,
103
- .select__xl_szlk5 {
102
+ .select__l_1g0al,
103
+ .select__xl_1g0al {
104
104
  padding-left: var(--select-option-l-left-padding);
105
105
  padding-right: var(--select-option-l-right-padding)
106
106
  }
107
- .select__l_szlk5:before, .select__xl_szlk5:before {
107
+ .select__l_1g0al:before, .select__xl_1g0al:before {
108
108
  left: var(--select-option-l-left-padding);
109
109
  right: var(--select-option-l-right-padding);
110
110
  }
111
- .select__selected_szlk5 {
111
+ .select__selected_1g0al {
112
112
  background: var(--select-option-selected-background);
113
113
  color: var(--select-option-selected-color);
114
114
  cursor: default;
115
115
  }
116
- .select__highlighted_szlk5 {
116
+ .select__highlighted_1g0al {
117
117
  background: var(--select-option-hover-background);
118
118
  color: var(--select-option-hover-color)
119
119
  }
120
- .select__highlighted_szlk5:before,
121
- .select__highlighted_szlk5 + .select__option_szlk5:before {
120
+ .select__highlighted_1g0al:before,
121
+ .select__highlighted_1g0al + .select__option_1g0al:before {
122
122
  opacity: 0;
123
123
  }
124
- .select__disabled_szlk5 {
124
+ .select__disabled_1g0al {
125
125
  cursor: var(--disabled-cursor);
126
126
  background: var(--select-option-disabled-background);
127
127
  color: var(--select-option-disabled-color);
128
128
  }
129
- .select__content_szlk5 {
129
+ .select__content_1g0al {
130
130
  overflow: hidden;
131
131
  text-overflow: ellipsis;
132
132
  flex: 1;
133
133
  }
134
- .select__textContent_szlk5 {
134
+ .select__textContent_1g0al {
135
135
  padding-top: var(--gap-s);
136
136
  padding-bottom: var(--gap-s);
137
137
  }
138
138
  /* IE min-height fix */
139
139
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
140
- .select__option_szlk5:after {
140
+ .select__option_1g0al:after {
141
141
  min-height: inherit;
142
142
  font-size: 0;
143
143
  content: '';
@@ -1,4 +1,4 @@
1
- import '../../tslib.es6-8b45cf3d.js';
1
+ import '../../tslib.es6-569ca735.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '../checkmark/Component.js';
@@ -4,7 +4,7 @@ import { useVisibleOptions, isGroup } from '../../utils.js';
4
4
  import mergeRefs from 'react-merge-refs';
5
5
  import { Optgroup } from '../optgroup/Component.js';
6
6
 
7
- var styles = {"optionsList":"select__optionsList_s1jax","emptyPlaceholder":"select__emptyPlaceholder_s1jax","l":"select__l_s1jax","xl":"select__xl_s1jax"};
7
+ var styles = {"optionsList":"select__optionsList_z26dc","emptyPlaceholder":"select__emptyPlaceholder_z26dc","l":"select__l_z26dc","xl":"select__xl_z26dc"};
8
8
  require('./index.css')
9
9
 
10
10
  var createCounter = function () {
@@ -1,4 +1,4 @@
1
- /* hash: s1jax */
1
+ /* hash: z26dc */
2
2
  :root {
3
3
  --color-light-text-secondary: #546272;
4
4
  }
@@ -26,17 +26,17 @@
26
26
 
27
27
  /* optgroup */
28
28
  }
29
- .select__optionsList_s1jax {
29
+ .select__optionsList_z26dc {
30
30
  overflow: auto;
31
31
  width: 100%;
32
32
  outline: none;
33
33
  box-sizing: border-box;
34
34
  }
35
- .select__emptyPlaceholder_s1jax {
35
+ .select__emptyPlaceholder_z26dc {
36
36
  padding: var(--gap-m) var(--gap-s);
37
37
  color: var(--select-options-list-empty-placeholder-color);
38
38
  }
39
- .select__l_s1jax .select__emptyPlaceholder_s1jax,
40
- .select__xl_s1jax .select__emptyPlaceholder_s1jax {
39
+ .select__l_z26dc .select__emptyPlaceholder_z26dc,
40
+ .select__xl_z26dc .select__emptyPlaceholder_z26dc {
41
41
  padding: var(--gap-xl) var(--gap-m);
42
42
  }
@@ -4,7 +4,7 @@ import { usePrevious, lastIndexOf, useVisibleOptions, isGroup } from '../../util
4
4
  import { Optgroup } from '../optgroup/Component.js';
5
5
  import { useVirtual } from 'react-virtual';
6
6
 
7
- var styles = {"virtualOptionsList":"select__virtualOptionsList_1ih0v","inner":"select__inner_1ih0v","virtualRow":"select__virtualRow_1ih0v","highlighted":"select__highlighted_1ih0v","emptyPlaceholder":"select__emptyPlaceholder_1ih0v","l":"select__l_1ih0v","xl":"select__xl_1ih0v"};
7
+ var styles = {"virtualOptionsList":"select__virtualOptionsList_2dlim","inner":"select__inner_2dlim","virtualRow":"select__virtualRow_2dlim","highlighted":"select__highlighted_2dlim","emptyPlaceholder":"select__emptyPlaceholder_2dlim","l":"select__l_2dlim","xl":"select__xl_2dlim"};
8
8
  require('./index.css')
9
9
 
10
10
  /* eslint-disable react-hooks/exhaustive-deps */