@mrktg-common/internal-ui 1.17.0 → 1.17.1

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/Combobox.js CHANGED
@@ -3,11 +3,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
3
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
- import { FixedPortal } from './portal.js';
6
+ import { FixedPortal, HIDDEN_OVERLAY } from './portal.js';
7
7
  import { Spinner } from './Spinner.js';
8
8
  import { cx } from './cx.js';
9
9
  import { devError } from './devWarn.js';
10
- import { isKeysActive, openingActive, stepActive } from './activeOption.js';
10
+ import { isKeysActive, openingActive, revealInList, stepActive } from './activeOption.js';
11
11
  const GAP = 4;
12
12
  const EDGE = 12;
13
13
  const defaultEmptyText = (query) => `No options match “${query}”`;
@@ -23,7 +23,7 @@ export function Combobox({ id, value, onChange, options, groups, loading = false
23
23
  const [keysIndex, setKeysIndex] = useState(null);
24
24
  const [pointerIndex, setPointerIndex] = useState(null);
25
25
  const active = pointerIndex ?? keysIndex;
26
- const [listStyle, setListStyle] = useState({ visibility: 'hidden' });
26
+ const [listStyle, setListStyle] = useState(HIDDEN_OVERLAY);
27
27
  const rootRef = useRef(null);
28
28
  const inputRef = useRef(null);
29
29
  const listRef = useRef(null);
@@ -84,15 +84,14 @@ export function Combobox({ id, value, onChange, options, groups, loading = false
84
84
  useLayoutEffect(() => {
85
85
  if (!visible)
86
86
  return;
87
- // В jsdom прокрутки нет: тесты потребителей не должны падать на ней
88
87
  if (active !== null)
89
- document.getElementById(optionId(active))?.scrollIntoView?.({ block: 'nearest' });
88
+ revealInList(listRef.current, document.getElementById(optionId(active)));
90
89
  });
91
90
  const show = ({ filter, byKeys }) => {
92
91
  if (failed)
93
92
  return;
94
93
  if (!open)
95
- setListStyle({ visibility: 'hidden' });
94
+ setListStyle(HIDDEN_OVERLAY);
96
95
  setFiltering(filter);
97
96
  const current = all.findIndex((option) => option.value === value);
98
97
  if (filter)
@@ -5,8 +5,8 @@ import { Check, ChevronDown, Search as SearchIcon, TriangleAlert } from 'lucide-
5
5
  import { cx } from './cx.js';
6
6
  import { buttonClass } from './buttonClass.js';
7
7
  import { controlClass } from './Field.js';
8
- import { FixedPortal } from './portal.js';
9
- import { isKeysActive, openingActive, stepActive } from './activeOption.js';
8
+ import { FixedPortal, HIDDEN_OVERLAY } from './portal.js';
9
+ import { isKeysActive, openingActive, revealInList, stepActive } from './activeOption.js';
10
10
  const GAP = 4;
11
11
  const EDGE = 12;
12
12
  /**
@@ -32,7 +32,7 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
32
32
  const buttonRef = useRef(null);
33
33
  const menuRef = useRef(null);
34
34
  const searchRef = useRef(null);
35
- const [menuStyle, setMenuStyle] = useState({ visibility: 'hidden' });
35
+ const [menuStyle, setMenuStyle] = useState(HIDDEN_OVERLAY);
36
36
  const listId = useId();
37
37
  const selected = pinned?.value === value ? pinned : groups.flatMap((group) => group.items).find((item) => item.value === value);
38
38
  useEffect(() => {
@@ -85,12 +85,11 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
85
85
  useEffect(() => {
86
86
  if (!open)
87
87
  return;
88
- // В jsdom прокрутки нет: тесты потребителей не должны падать на ней
89
88
  if (active !== null)
90
- menuRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView?.({ block: 'nearest' });
89
+ revealInList(menuRef.current, menuRef.current?.querySelector(`[data-index="${active}"]`) ?? null);
91
90
  }, [open, active]);
92
91
  const openMenu = ({ byKeys }) => {
93
- setMenuStyle({ visibility: 'hidden' });
92
+ setMenuStyle(HIDDEN_OVERLAY);
94
93
  setQuery('');
95
94
  const checked = items.findIndex((item) => item.value === value);
96
95
  setKeysIndex(byKeys ? openingActive(checked) : null);
@@ -126,6 +125,14 @@ export function SelectMenu({ id, value, groups, onChange, placeholder, autoFocus
126
125
  setKeysIndex(stepActive({ active, checked, step: event.key === 'ArrowDown' ? 1 : -1, count: items.length }));
127
126
  setPointerIndex(null);
128
127
  }
128
+ else if ((event.key === 'Home' || event.key === 'End') && event.target !== searchRef.current) {
129
+ // Иначе End прокручивает модалку под открытым списком; в поле поиска Home и End двигают курсор
130
+ event.preventDefault();
131
+ if (items.length === 0)
132
+ return;
133
+ setKeysIndex(event.key === 'Home' ? 0 : items.length - 1);
134
+ setPointerIndex(null);
135
+ }
129
136
  else if (event.key === 'Enter') {
130
137
  event.preventDefault();
131
138
  // Без активного пункта (открыт кликом, мышь ушла) Enter закрывает без изменений
package/dist/Tooltip.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { cloneElement, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
4
- import { FixedPortal } from './portal.js';
4
+ import { FixedPortal, HIDDEN_OVERLAY } from './portal.js';
5
5
  export const TOOLTIP_DELAY_MS = 400;
6
6
  const GAP = 6;
7
7
  const EDGE = 8;
@@ -12,13 +12,13 @@ const EDGE = 8;
12
12
  export function Tooltip({ content, children, instant = false }) {
13
13
  const id = useId();
14
14
  const [anchor, setAnchor] = useState(null);
15
- const [style, setStyle] = useState({ visibility: 'hidden' });
15
+ const [style, setStyle] = useState(HIDDEN_OVERLAY);
16
16
  const timer = useRef(undefined);
17
17
  const tipRef = useRef(null);
18
18
  const hide = () => {
19
19
  window.clearTimeout(timer.current);
20
20
  setAnchor(null);
21
- setStyle({ visibility: 'hidden' });
21
+ setStyle(HIDDEN_OVERLAY);
22
22
  };
23
23
  const show = (element, delay) => {
24
24
  window.clearTimeout(timer.current);
@@ -10,4 +10,6 @@ export declare function stepActive({ active, checked, step, count }: IStepActive
10
10
  export declare function openingActive(checked: number): number;
11
11
  /** Пункт, у которого полоса: тот, что выбрала клавиатура, пока под мышью ничего нет */
12
12
  export declare function isKeysActive(index: number, keysIndex: number | null, pointerIndex: number | null): boolean;
13
+ /** Прокрутка списка к пункту: двигает только сам список, а не модалку и страницу, как scrollIntoView */
14
+ export declare function revealInList(list: HTMLElement | null, option: Element | null): void;
13
15
  export {};
@@ -18,3 +18,16 @@ export function openingActive(checked) {
18
18
  export function isKeysActive(index, keysIndex, pointerIndex) {
19
19
  return pointerIndex === null && keysIndex === index;
20
20
  }
21
+ /** Прокрутка списка к пункту: двигает только сам список, а не модалку и страницу, как scrollIntoView */
22
+ export function revealInList(list, option) {
23
+ if (list === null || option === null)
24
+ return;
25
+ const view = list.getBoundingClientRect();
26
+ const item = option.getBoundingClientRect();
27
+ const top = view.top + list.clientTop;
28
+ const bottom = top + list.clientHeight;
29
+ if (item.top < top)
30
+ list.scrollTop -= top - item.top;
31
+ else if (item.bottom > bottom)
32
+ list.scrollTop += item.bottom - bottom;
33
+ }
package/dist/portal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { CSSProperties, ReactNode } from 'react';
2
2
  /**
3
3
  * Оверлеи и стопка тостов живут в портале в body. Базовые правила системы (box-sizing, ссылки, шрифт)
4
4
  * заданы внутри .app, поэтому портал оборачивается в .app без собственного бокса.
@@ -6,3 +6,9 @@ import type { ReactNode } from 'react';
6
6
  export declare function FixedPortal({ children }: {
7
7
  children: ReactNode;
8
8
  }): import("react").ReactPortal | null;
9
+ /**
10
+ * Оверлей до первого замера: уже fixed, поэтому не попадает в прокрутку страницы. Классы .pop и .tip
11
+ * дают position: absolute, и в body без него невидимый список ниже экрана добавлял странице полосу
12
+ * прокрутки: центрированная модалка сдвигалась, а прокрутка к активному пункту листала страницу.
13
+ */
14
+ export declare const HIDDEN_OVERLAY: CSSProperties;
package/dist/portal.js CHANGED
@@ -10,3 +10,9 @@ export function FixedPortal({ children }) {
10
10
  return null;
11
11
  return createPortal(_jsx("div", { className: "app", style: { display: 'contents' }, children: children }), document.body);
12
12
  }
13
+ /**
14
+ * Оверлей до первого замера: уже fixed, поэтому не попадает в прокрутку страницы. Классы .pop и .tip
15
+ * дают position: absolute, и в body без него невидимый список ниже экрана добавлял странице полосу
16
+ * прокрутки: центрированная модалка сдвигалась, а прокрутка к активному пункту листала страницу.
17
+ */
18
+ export const HIDDEN_OVERLAY = { position: 'fixed', top: 0, left: 0, visibility: 'hidden' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrktg-common/internal-ui",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
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.17.0",
5
+ "release": "1.17.1",
6
6
  "source": "lp-constructor src/styles/tokens.css + Landings Admin admin.css, merged 2026-10-12"
7
7
  },
8
8
  "color": {