@mrktg-common/internal-ui 1.10.0 → 1.12.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.
@@ -5,12 +5,20 @@ export type TComboboxOption = {
5
5
  /** Серым справа: язык, количество. */
6
6
  trailing?: ReactNode;
7
7
  };
8
+ export type TComboboxGroup = {
9
+ /** Заголовок группы, не выбирается; null — без заголовка. */
10
+ label: string | null;
11
+ options: TComboboxOption[];
12
+ };
8
13
  export interface IComboboxProps {
9
14
  id?: string;
10
15
  value: string;
11
16
  /** Любой набранный текст: список подсказывает, а не ограничивает. */
12
17
  onChange: (text: string) => void;
13
- options: TComboboxOption[];
18
+ /** Плоский список: то же, что одна группа без заголовка. */
19
+ options?: TComboboxOption[];
20
+ /** Подсказки группами; вместо options. Одно значение — только в одной группе. */
21
+ groups?: TComboboxGroup[];
14
22
  /** Список ещё грузится: вместо строк — спиннер, набирать можно. */
15
23
  loading?: boolean;
16
24
  /** Список не загрузился: поле работает как обычное, кнопки списка нет. */
@@ -32,4 +40,4 @@ export interface IComboboxProps {
32
40
  * Поле с подсказками из списка; набранное значение сохраняется, даже если его в списке нет.
33
41
  * Для закрытого списка — SelectMenu. Список в портале, position fixed над модалками.
34
42
  */
35
- export declare function Combobox({ id, value, onChange, options, loading, failed, size, mono, invalid, placeholder, disabled, emptyText, onCommit, className, ...aria }: IComboboxProps): import("react").JSX.Element;
43
+ export declare function Combobox({ id, value, onChange, options, groups, loading, failed, size, mono, invalid, placeholder, disabled, emptyText, onCommit, className, ...aria }: IComboboxProps): import("react").JSX.Element;
package/dist/Combobox.js CHANGED
@@ -1,11 +1,13 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId, useLayoutEffect, useRef, useState } from 'react';
3
+ import { Fragment, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
4
4
  import { Check, ChevronDown } from 'lucide-react';
5
5
  import { controlClass } from './Field.js';
6
6
  import { FixedPortal } from './portal.js';
7
7
  import { Spinner } from './Spinner.js';
8
8
  import { cx } from './cx.js';
9
+ import { devError } from './devWarn.js';
10
+ import { openingActive, stepActive } from './activeOption.js';
9
11
  const GAP = 4;
10
12
  const EDGE = 12;
11
13
  const defaultEmptyText = (query) => `No options match “${query}”`;
@@ -13,11 +15,12 @@ const defaultEmptyText = (query) => `No options match “${query}”`;
13
15
  * Поле с подсказками из списка; набранное значение сохраняется, даже если его в списке нет.
14
16
  * Для закрытого списка — SelectMenu. Список в портале, position fixed над модалками.
15
17
  */
16
- export function Combobox({ id, value, onChange, options, loading = false, failed = false, size = 'md', mono, invalid, placeholder, disabled, emptyText = defaultEmptyText, onCommit, className, ...aria }) {
18
+ export function Combobox({ id, value, onChange, options, groups, loading = false, failed = false, size = 'md', mono, invalid, placeholder, disabled, emptyText = defaultEmptyText, onCommit, className, ...aria }) {
17
19
  const [open, setOpen] = useState(false);
18
20
  // Кнопка открывает весь список, ввод — отфильтрованный
19
21
  const [filtering, setFiltering] = useState(false);
20
22
  const [active, setActive] = useState(0);
23
+ const [activeSource, setActiveSource] = useState('none');
21
24
  const [listStyle, setListStyle] = useState({ visibility: 'hidden' });
22
25
  const rootRef = useRef(null);
23
26
  const inputRef = useRef(null);
@@ -25,10 +28,29 @@ export function Combobox({ id, value, onChange, options, loading = false, failed
25
28
  // Выбор строки и следующий за ним blur не должны проверять одно значение дважды
26
29
  const committed = useRef(null);
27
30
  const listId = useId();
31
+ const source = groups ?? [{ label: null, options: options ?? [] }];
32
+ const all = source.flatMap((group) => group.options);
28
33
  const query = value.trim();
29
34
  const normalized = query.toLowerCase();
30
- const shown = filtering && normalized !== '' ? options.filter((option) => option.value.toLowerCase().includes(normalized)) : options;
35
+ const shownGroups = source
36
+ .map((group) => ({
37
+ ...group,
38
+ options: filtering && normalized !== '' ? group.options.filter((option) => option.value.toLowerCase().includes(normalized)) : group.options,
39
+ }))
40
+ .filter((group) => group.options.length > 0);
41
+ const shown = shownGroups.flatMap((group) => group.options);
31
42
  const visible = open && !failed;
43
+ useEffect(() => {
44
+ if (groups !== undefined && options !== undefined)
45
+ devError('Combobox: pass either options or groups; groups are used.');
46
+ }, [groups, options]);
47
+ const values = all.map((option) => option.value).join('\u0000');
48
+ useEffect(() => {
49
+ const list = values === '' ? [] : values.split('\u0000');
50
+ const repeated = list.filter((item, index) => list.indexOf(item) !== index);
51
+ if (repeated.length > 0)
52
+ devError(`Combobox: an option belongs to one group only; repeated: ${[...new Set(repeated)].join(', ')}.`);
53
+ }, [values]);
32
54
  const optionId = (index) => `${listId}-${index}`;
33
55
  useLayoutEffect(() => {
34
56
  if (!visible)
@@ -63,14 +85,18 @@ export function Combobox({ id, value, onChange, options, loading = false, failed
63
85
  // В jsdom прокрутки нет: тесты потребителей не должны падать на ней
64
86
  document.getElementById(optionId(active))?.scrollIntoView?.({ block: 'nearest' });
65
87
  });
66
- const show = ({ filter }) => {
88
+ const show = ({ filter, byKeys }) => {
67
89
  if (failed)
68
90
  return;
69
91
  if (!open)
70
92
  setListStyle({ visibility: 'hidden' });
71
93
  setFiltering(filter);
72
- const current = options.findIndex((option) => option.value === value);
73
- setActive(filter ? 0 : Math.max(0, current));
94
+ const current = all.findIndex((option) => option.value === value);
95
+ if (filter)
96
+ setActive(0);
97
+ else
98
+ setActive(byKeys ? openingActive(current) : current);
99
+ setActiveSource(filter || byKeys ? 'keys' : 'none');
74
100
  setOpen(true);
75
101
  };
76
102
  const commit = (next) => {
@@ -88,16 +114,18 @@ export function Combobox({ id, value, onChange, options, loading = false, failed
88
114
  if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
89
115
  event.preventDefault();
90
116
  if (!visible) {
91
- show({ filter: false });
117
+ show({ filter: false, byKeys: true });
92
118
  return;
93
119
  }
94
120
  if (shown.length === 0)
95
121
  return;
96
- const step = event.key === 'ArrowDown' ? 1 : -1;
97
- setActive((current) => (current + step + shown.length) % shown.length);
122
+ const checked = shown.findIndex((option) => option.value === value);
123
+ setActive(stepActive({ active, source: activeSource, checked, step: event.key === 'ArrowDown' ? 1 : -1, count: shown.length }));
124
+ setActiveSource('keys');
98
125
  }
99
126
  else if (event.key === 'Enter') {
100
- const option = visible && !loading ? shown[active] : undefined;
127
+ // Список, открытый кликом, без активного пункта: Enter оставляет текст как есть
128
+ const option = visible && !loading && activeSource !== 'none' ? shown[active] : undefined;
101
129
  if (visible)
102
130
  event.preventDefault();
103
131
  if (option === undefined) {
@@ -117,11 +145,11 @@ export function Combobox({ id, value, onChange, options, loading = false, failed
117
145
  setOpen(false);
118
146
  }
119
147
  };
120
- const activeOption = visible && !loading && shown[active] !== undefined ? optionId(active) : undefined;
148
+ const activeOption = visible && !loading && activeSource !== 'none' && shown[active] !== undefined ? optionId(active) : undefined;
121
149
  return (_jsxs("div", { className: cx('combo', className), ref: rootRef, children: [_jsx("input", { ref: inputRef, id: id, type: "text", className: controlClass({ size, invalid, mono }), role: "combobox", "aria-autocomplete": "list", "aria-expanded": visible, "aria-controls": visible ? listId : undefined, "aria-activedescendant": activeOption, "aria-invalid": invalid || undefined, autoComplete: "off", value: value, placeholder: placeholder, disabled: disabled, onChange: (event) => {
122
150
  committed.current = null;
123
151
  onChange(event.target.value);
124
- show({ filter: true });
152
+ show({ filter: true, byKeys: true });
125
153
  }, onKeyDown: handleKeyDown, onBlur: () => {
126
154
  setOpen(false);
127
155
  commit(value);
@@ -132,10 +160,24 @@ export function Combobox({ id, value, onChange, options, loading = false, failed
132
160
  if (visible)
133
161
  setOpen(false);
134
162
  else
135
- show({ filter: false });
136
- }, children: _jsx(ChevronDown, { className: "ic", "aria-hidden": true }) })), visible && (_jsx(FixedPortal, { children: _jsx("div", { ref: listRef, className: "pop pop-scroll", style: listStyle, role: "listbox", id: listId, "aria-labelledby": id, children: loading ? (_jsx("div", { className: "menu-empty", role: "status", children: _jsxs("span", { className: "row", style: { justifyContent: 'center' }, children: [_jsx(Spinner, { size: "sm" }), "Loading\u2026"] }) })) : shown.length === 0 ? (_jsxs("div", { className: "menu-empty", children: [_jsx("span", { className: "strong", children: emptyText(query) }), _jsx("span", { className: "hint", children: "You can keep it as typed." })] })) : (shown.map((option, index) => {
137
- const isCurrent = option.value === value;
138
- return (_jsxs("div", { id: optionId(index), role: "option", "aria-selected": isCurrent, className: cx('menu-item', index === active && 'is-hover'), onMouseDown: (event) => event.preventDefault(), onMouseEnter: () => setActive(index), onClick: () => pick(option), children: [_jsx("span", { className: "trunc", children: filtering ? _jsx(Highlight, { text: option.value, query: query }) : option.value }), option.trailing !== undefined && _jsx("span", { className: "trail", children: option.trailing }), isCurrent && _jsx(Check, { className: "ic check", "aria-hidden": true })] }, option.value));
163
+ show({ filter: false, byKeys: false });
164
+ }, children: _jsx(ChevronDown, { className: "ic", "aria-hidden": true }) })), visible && (_jsx(FixedPortal, { children: _jsx("div", { ref: listRef, className: "pop pop-scroll", style: listStyle, role: "listbox", id: listId, "aria-labelledby": id, children: loading ? (_jsx("div", { className: "menu-empty", role: "status", children: _jsxs("span", { className: "row", style: { justifyContent: 'center' }, children: [_jsx(Spinner, { size: "sm" }), "Loading\u2026"] }) })) : shown.length === 0 ? (_jsxs("div", { className: "menu-empty", children: [_jsx("span", { className: "strong", children: emptyText(query) }), _jsx("span", { className: "hint", children: "You can keep it as typed." })] })) : (shownGroups.map((group, groupIndex) => {
165
+ const rows = group.options.map((option) => {
166
+ const index = shown.indexOf(option);
167
+ const isCurrent = option.value === value;
168
+ return (_jsxs("div", { id: optionId(index), role: "option", "aria-selected": isCurrent, className: cx('menu-item', index === active && activeSource === 'keys' && 'is-active'), onMouseDown: (event) => event.preventDefault(),
169
+ // Только настоящее движение мыши: список, открытый или прокрученный под курсором, пункт не меняет
170
+ onMouseMove: () => {
171
+ if (index === active && activeSource === 'pointer')
172
+ return;
173
+ setActive(index);
174
+ setActiveSource('pointer');
175
+ }, onClick: () => pick(option), children: [_jsx("span", { className: "trunc", children: filtering ? _jsx(Highlight, { text: option.value, query: query }) : option.value }), option.trailing !== undefined && _jsx("span", { className: "trail", children: option.trailing }), isCurrent && _jsx(Check, { className: "ic check", "aria-hidden": true })] }, option.value));
176
+ });
177
+ if (group.label === null)
178
+ return _jsx(Fragment, { children: rows }, `group-${groupIndex}`);
179
+ const labelId = `${listId}-group-${groupIndex}`;
180
+ return (_jsxs("div", { role: "group", "aria-labelledby": labelId, children: [_jsx("div", { className: "menu-label", id: labelId, role: "presentation", children: group.label }), rows] }, `group-${groupIndex}`));
139
181
  })) }) }))] }));
140
182
  }
141
183
  /** Набранная часть строки — жирным. */
@@ -6,6 +6,7 @@ import { cx } from './cx.js';
6
6
  import { buttonClass } from './buttonClass.js';
7
7
  import { controlClass } from './Field.js';
8
8
  import { FixedPortal } from './portal.js';
9
+ import { openingActive, stepActive } from './activeOption.js';
9
10
  const GAP = 4;
10
11
  const EDGE = 12;
11
12
  /**
@@ -24,6 +25,7 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
24
25
  ];
25
26
  const items = shownGroups.flatMap((group) => group.items);
26
27
  const [active, setActive] = useState(0);
28
+ const [activeSource, setActiveSource] = useState('none');
27
29
  const rootRef = useRef(null);
28
30
  const buttonRef = useRef(null);
29
31
  const menuRef = useRef(null);
@@ -84,10 +86,12 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
84
86
  // В jsdom прокрутки нет: тесты потребителей не должны падать на ней
85
87
  menuRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView?.({ block: 'nearest' });
86
88
  }, [open, active]);
87
- const openMenu = () => {
89
+ const openMenu = ({ byKeys }) => {
88
90
  setMenuStyle({ visibility: 'hidden' });
89
91
  setQuery('');
90
- setActive(Math.max(0, items.findIndex((item) => item.value === value)));
92
+ const checked = items.findIndex((item) => item.value === value);
93
+ setActive(byKeys ? openingActive(checked) : checked);
94
+ setActiveSource(byKeys ? 'keys' : 'none');
91
95
  setOpen(true);
92
96
  };
93
97
  const close = () => {
@@ -104,7 +108,7 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
104
108
  if (!open) {
105
109
  if (event.target === buttonRef.current && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
106
110
  event.preventDefault();
107
- openMenu();
111
+ openMenu({ byKeys: true });
108
112
  }
109
113
  return;
110
114
  }
@@ -115,13 +119,17 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
115
119
  }
116
120
  else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
117
121
  event.preventDefault();
118
- const step = event.key === 'ArrowDown' ? 1 : -1;
119
- setActive((current) => (current + step + items.length) % Math.max(items.length, 1));
122
+ const checked = items.findIndex((item) => item.value === value);
123
+ setActive(stepActive({ active, source: activeSource, checked, step: event.key === 'ArrowDown' ? 1 : -1, count: items.length }));
124
+ setActiveSource('keys');
120
125
  }
121
126
  else if (event.key === 'Enter') {
122
127
  event.preventDefault();
123
- const item = items[active];
124
- if (item !== undefined)
128
+ // Список, открытый кликом, без активного пункта: Enter закрывает без изменений
129
+ const item = activeSource === 'none' ? undefined : items[active];
130
+ if (item === undefined)
131
+ close();
132
+ else
125
133
  choose(item);
126
134
  }
127
135
  else if (event.key === 'Tab') {
@@ -129,22 +137,37 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
129
137
  }
130
138
  else if (search === undefined && event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {
131
139
  const letter = event.key.toLowerCase();
132
- const order = [...items.slice(active + 1), ...items.slice(0, active + 1)];
140
+ const from = activeSource === 'none' ? items.findIndex((item) => item.value === value) : active;
141
+ const order = [...items.slice(from + 1), ...items.slice(0, from + 1)];
133
142
  const match = order.find((item) => item.label.toLowerCase().startsWith(letter));
134
- if (match !== undefined)
143
+ if (match !== undefined) {
135
144
  setActive(items.indexOf(match));
145
+ setActiveSource('keys');
146
+ }
136
147
  }
137
148
  };
149
+ const optionId = (index) => `${listId}-option-${index}`;
150
+ // Только когда активный пункт есть: у списка, открытого кликом, его нет
151
+ const activeOption = open && activeSource !== 'none' && items[active] !== undefined ? optionId(active) : undefined;
138
152
  const triggerClass = filter === undefined
139
153
  ? controlClass({ size, invalid }, 'select-btn')
140
154
  : buttonClass({ variant: 'secondary', size, active: filter.active });
141
- return (_jsxs("div", { className: cx('anchor', className), style: filter === undefined ? { display: 'flex' } : undefined, ref: rootRef, onKeyDown: handleKeyDown, children: [_jsxs("button", { ref: buttonRef, id: id, type: "button", className: triggerClass, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listId : undefined, "aria-invalid": invalid || undefined, disabled: disabled, onClick: () => (open ? setOpen(false) : openMenu()), ...aria, children: [filter !== undefined ? filter.label : selected === undefined ? _jsx("span", { className: "muted trunc", children: placeholder ?? value }) : _jsx(ItemContent, { item: selected }), _jsx(ChevronDown, { className: cx('ic', 'chev', filter !== undefined && 'ic-sm'), "aria-hidden": true })] }), open && (_jsx(FixedPortal, { children: _jsxs("div", { ref: menuRef, className: "pop pop-scroll", style: menuStyle, role: "listbox", id: listId, "aria-labelledby": id, children: [search !== undefined && (_jsx("div", { className: "menu-search", children: _jsxs("label", { className: "with-icon", children: [_jsx(SearchIcon, { className: "ic", "aria-hidden": true }), _jsx("span", { className: "sr-only", children: search.label }), _jsx("input", { ref: searchRef, className: "control control-sm", value: query, placeholder: search.placeholder, onChange: (event) => {
155
+ return (_jsxs("div", { className: cx('anchor', className), style: filter === undefined ? { display: 'flex' } : undefined, ref: rootRef, onKeyDown: handleKeyDown, children: [_jsxs("button", { ref: buttonRef, id: id, type: "button", className: triggerClass, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listId : undefined, "aria-activedescendant": search === undefined ? activeOption : undefined, "aria-invalid": invalid || undefined, disabled: disabled, onClick: () => (open ? setOpen(false) : openMenu({ byKeys: false })), ...aria, children: [filter !== undefined ? filter.label : selected === undefined ? _jsx("span", { className: "muted trunc", children: placeholder ?? value }) : _jsx(ItemContent, { item: selected }), _jsx(ChevronDown, { className: cx('ic', 'chev', filter !== undefined && 'ic-sm'), "aria-hidden": true })] }), open && (_jsx(FixedPortal, { children: _jsxs("div", { ref: menuRef, className: "pop pop-scroll", style: menuStyle, role: "listbox", id: listId, "aria-labelledby": id, children: [search !== undefined && (_jsx("div", { className: "menu-search", children: _jsxs("label", { className: "with-icon", children: [_jsx(SearchIcon, { className: "ic", "aria-hidden": true }), _jsx("span", { className: "sr-only", children: search.label }), _jsx("input", { ref: searchRef, className: "control control-sm", value: query, placeholder: search.placeholder, "aria-controls": listId, "aria-activedescendant": activeOption, onChange: (event) => {
142
156
  setQuery(event.target.value);
143
157
  setActive(0);
158
+ setActiveSource('keys');
144
159
  } })] }) })), items.length === 0 && (_jsxs("div", { className: "menu-empty", children: [_jsxs("span", { className: "strong", children: ["Nothing matches \u201C", query.trim(), "\u201D"] }), _jsx("span", { className: "hint", children: "Try a shorter name." })] })), shownGroups.map((group, groupIndex) => (_jsxs("div", { role: "group", "aria-label": group.label ?? undefined, children: [group.label !== null && _jsx("div", { className: "menu-label", children: group.label }), group.note !== undefined && (_jsxs("div", { className: "menu-note", children: [_jsx(TriangleAlert, { className: "ic ic-sm", "aria-hidden": true }), _jsx("span", { children: group.note })] })), group.items.map((item) => {
145
160
  const index = items.indexOf(item);
146
161
  const isSelected = item.value === value;
147
- return (_jsxs("button", { type: "button", role: "option", "data-index": index, tabIndex: -1, "aria-selected": isSelected, "aria-disabled": item.disabled || undefined, className: cx('menu-item', index === active && 'is-hover'), onMouseEnter: () => setActive(index), onClick: () => choose(item), children: [_jsx(ItemContent, { item: item }), item.trailing !== undefined && _jsx("span", { className: "trail", children: item.trailing }), isSelected && _jsx(Check, { className: "ic check", "aria-hidden": true })] }, item.value));
162
+ return (_jsxs("button", { type: "button", role: "option", id: optionId(index), "data-index": index, tabIndex: -1, "aria-selected": isSelected, "aria-disabled": item.disabled || undefined, className: cx('menu-item', index === active && activeSource === 'keys' && 'is-active'),
163
+ // Только настоящее движение мыши: список, открытый или прокрученный под курсором, пункт не меняет.
164
+ // Выключенный пункт под мышью не меняется
165
+ onMouseMove: () => {
166
+ if (item.disabled || (index === active && activeSource === 'pointer'))
167
+ return;
168
+ setActive(index);
169
+ setActiveSource('pointer');
170
+ }, onClick: () => choose(item), children: [_jsx(ItemContent, { item: item }), item.trailing !== undefined && _jsx("span", { className: "trail", children: item.trailing }), isSelected && _jsx(Check, { className: "ic check", "aria-hidden": true })] }, item.value));
148
171
  })] }, group.label ?? `group-${groupIndex}`)))] }) }))] }));
149
172
  }
150
173
  function ItemContent({ item }) {
@@ -0,0 +1,14 @@
1
+ /** Откуда активный пункт: с клавиатуры — полоса is-active, от мыши — только :hover, нет — список открыт кликом */
2
+ export type TActiveSource = 'keys' | 'pointer' | 'none';
3
+ interface IStepActiveArgs {
4
+ active: number;
5
+ source: TActiveSource;
6
+ checked: number;
7
+ step: 1 | -1;
8
+ count: number;
9
+ }
10
+ /** Пункт после ↓ / ↑: от активного, а если его нет — от отмеченного галочкой; без галочки ↓ берёт первый, ↑ последний */
11
+ export declare function stepActive({ active, source, checked, step, count }: IStepActiveArgs): number;
12
+ /** Пункт при открытии стрелкой: текущее значение, иначе первый */
13
+ export declare function openingActive(checked: number): number;
14
+ export {};
@@ -0,0 +1,14 @@
1
+ // Активный пункт Select menu и Combobox: тот, что возьмёт Enter (карточки, раздел «Active option»)
2
+ /** Пункт после ↓ / ↑: от активного, а если его нет — от отмеченного галочкой; без галочки ↓ берёт первый, ↑ последний */
3
+ export function stepActive({ active, source, checked, step, count }) {
4
+ if (count === 0)
5
+ return 0;
6
+ const from = source === 'none' ? checked : active;
7
+ if (from < 0 || from >= count)
8
+ return step === 1 ? 0 : count - 1;
9
+ return (from + step + count) % count;
10
+ }
11
+ /** Пункт при открытии стрелкой: текущее значение, иначе первый */
12
+ export function openingActive(checked) {
13
+ return Math.max(0, checked);
14
+ }
@@ -223,8 +223,13 @@
223
223
  .menu-item > .ic { color: var(--text-muted); }
224
224
  .menu-item:hover, .menu-item.is-hover, .menu-item:focus-visible, .menu-item.is-focus { outline: none; background: var(--bg-subtle); }
225
225
  .menu-item:focus-visible, .menu-item.is-focus { box-shadow: inset 0 0 0 2px var(--accent); }
226
+ /* Active option of Select menu and Combobox (aria-activedescendant): focus stays in the field or the trigger,
227
+ so the keyboard position is a bar on the left edge, not a second focus ring. */
228
+ .menu-item.is-active { background: var(--bg-subtle); box-shadow: inset 3px 0 0 var(--accent); }
226
229
  .menu-item.is-danger, .menu-item.is-danger > .ic { color: var(--danger-text); }
227
230
  .menu-item:disabled, .menu-item[aria-disabled='true'] { color: var(--text-muted); opacity: 0.55; cursor: not-allowed; background: none; }
231
+ /* The keyboard mark on an off item keeps its 3:1: the row isn't dimmed while the keyboard is on it. */
232
+ .menu-item[aria-disabled='true']:focus-visible, .menu-item.is-focus[aria-disabled='true'], .menu-item.is-active[aria-disabled='true'] { opacity: 1; }
228
233
  /* Selected option: check on the right, as on the agreed Publish window. */
229
234
  .menu-item > .check { margin-left: auto; color: var(--accent-text); }
230
235
  .menu-item[aria-selected='true'] { font-weight: 500; }
@@ -0,0 +1,2 @@
1
+ /** Ошибка использования компонента: в консоль только при разработке, в продуктовой сборке молчит. */
2
+ export declare function devError(message: string): void;
@@ -0,0 +1,6 @@
1
+ /** Ошибка использования компонента: в консоль только при разработке, в продуктовой сборке молчит. */
2
+ export function devError(message) {
3
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production')
4
+ return;
5
+ console.error(`[internal-ui] ${message}`);
6
+ }
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export type { IMenuProps, IMenuItemProps } from './Menu.tsx';
28
28
  export { SelectMenu } from './SelectMenu.tsx';
29
29
  export type { ISelectMenuProps, TSelectMenuItem, TSelectMenuGroup } from './SelectMenu.tsx';
30
30
  export { Combobox } from './Combobox.tsx';
31
- export type { IComboboxProps, TComboboxOption } from './Combobox.tsx';
31
+ export type { IComboboxProps, TComboboxOption, TComboboxGroup } from './Combobox.tsx';
32
32
  export { MultiSelectMenu } from './MultiSelectMenu.tsx';
33
33
  export type { IMultiSelectMenuProps, TMultiSelectOption, TMultiSelectGroup } from './MultiSelectMenu.tsx';
34
34
  export { Badge, StatusBadge } from './Badge.tsx';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrktg-common/internal-ui",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Общий интерфейс внутренних инструментов маркетинга (Landings Admin, LP Constructor): токены, классы компонентов и тонкие React-обёртки над ними.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@
2
2
  "name": "Internal ui",
3
3
  "version": 1,
4
4
  "meta": {
5
- "release": "1.10.0",
5
+ "release": "1.12.0",
6
6
  "source": "lp-constructor src/styles/tokens.css + Landings Admin admin.css, merged 2026-10-12"
7
7
  },
8
8
  "color": {
@@ -103,7 +103,7 @@
103
103
  "light": "#2f6fed",
104
104
  "dark": "#5b8dff"
105
105
  },
106
- "usage": "Primary button, solid badge, count pill, focus border, active tab line, selection outline, progress. A UI mark: 4.6:1 on surface light, 5.0:1 dark."
106
+ "usage": "Primary button, solid badge, count pill, focus border, active tab line, active option bar in Select menu and Combobox, selection outline, progress. A UI mark: 4.6:1 on surface light, 5.0:1 dark."
107
107
  },
108
108
  {
109
109
  "name": "accent-hover",