@lt-ui/uikit 0.0.2 → 0.0.3

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 (95) hide show
  1. package/_internal/floating/use-floating.d.ts +1 -1
  2. package/_internal/floating/use-floating.js +6 -2
  3. package/cjs/_internal/floating/use-floating.js +6 -2
  4. package/cjs/image/image-viewer.js +3 -13
  5. package/cjs/image/image.js +4 -27
  6. package/cjs/image/use-image-preview.js +32 -0
  7. package/cjs/image/use-image-viewer.js +21 -0
  8. package/cjs/modal/modal.js +4 -10
  9. package/cjs/modal/styles/_animations.css +2 -2
  10. package/cjs/modal/styles/modal.module.css +7 -2
  11. package/cjs/modal/use-modal.js +15 -1
  12. package/cjs/navigation/navigation-compact.js +2 -30
  13. package/cjs/navigation/navigation-row.js +5 -65
  14. package/cjs/navigation/navigation-views.js +3 -57
  15. package/cjs/navigation/styles/navigation.module.css +2 -0
  16. package/cjs/navigation/use-navigation-flyout.js +39 -0
  17. package/cjs/navigation/use-navigation-panel-stages.js +23 -0
  18. package/cjs/navigation/use-navigation-row.js +39 -0
  19. package/cjs/select/components/select-multiselect-panel.js +9 -67
  20. package/cjs/select/components/select-option-row.js +7 -53
  21. package/cjs/select/hooks/use-select-multiselect-panel-layout.js +53 -0
  22. package/cjs/select/hooks/use-select-option-row.js +23 -0
  23. package/cjs/select/views/select-view.js +2 -2
  24. package/cjs/snackbar/snack-view.js +9 -42
  25. package/cjs/snackbar/use-snack-view.js +16 -0
  26. package/cjs/tabs/tab-list.js +2 -20
  27. package/cjs/tabs/tab-panel.js +4 -39
  28. package/cjs/tabs/use-tab-list-navigation.js +27 -0
  29. package/cjs/tabs/use-tab-panel.js +12 -0
  30. package/cjs/time-picker/time-panel.js +2 -47
  31. package/cjs/time-picker/use-time-column-list.js +48 -0
  32. package/cjs/tooltip/tooltip.js +1 -1
  33. package/cjs/tree/tree-row.js +13 -73
  34. package/cjs/tree/use-tree-row.js +102 -0
  35. package/cjs/utils/class-names.js +3 -1
  36. package/image/image-viewer.js +3 -13
  37. package/image/image.js +5 -28
  38. package/image/use-image-preview.d.ts +10 -0
  39. package/image/use-image-preview.js +29 -0
  40. package/image/use-image-viewer.d.ts +8 -0
  41. package/image/use-image-viewer.js +18 -0
  42. package/input/fields/use-text-field.d.ts +2 -0
  43. package/masked-input/use-mask.d.ts +2 -0
  44. package/modal/modal.d.ts +1 -0
  45. package/modal/modal.js +4 -10
  46. package/modal/styles/_animations.css +2 -2
  47. package/modal/styles/modal.module.css +7 -2
  48. package/modal/types.d.ts +5 -0
  49. package/modal/use-modal.d.ts +3 -1
  50. package/modal/use-modal.js +17 -3
  51. package/navigation/navigation-compact.d.ts +1 -2
  52. package/navigation/navigation-compact.js +3 -31
  53. package/navigation/navigation-row.d.ts +1 -2
  54. package/navigation/navigation-row.js +6 -33
  55. package/navigation/navigation-views.js +3 -24
  56. package/navigation/styles/navigation.module.css +2 -0
  57. package/navigation/types.d.ts +1 -0
  58. package/navigation/use-navigation-flyout.d.ts +9 -0
  59. package/navigation/use-navigation-flyout.js +36 -0
  60. package/navigation/use-navigation-panel-stages.d.ts +5 -0
  61. package/navigation/use-navigation-panel-stages.js +20 -0
  62. package/navigation/use-navigation-row.d.ts +16 -0
  63. package/navigation/use-navigation-row.js +36 -0
  64. package/number-input/use-number-input.d.ts +2 -0
  65. package/package.json +1 -1
  66. package/popover/types.d.ts +2 -2
  67. package/select/components/select-multiselect-panel.d.ts +3 -1
  68. package/select/components/select-multiselect-panel.js +8 -66
  69. package/select/components/select-option-row.js +7 -20
  70. package/select/hooks/use-select-multiselect-panel-layout.d.ts +14 -0
  71. package/select/hooks/use-select-multiselect-panel-layout.js +49 -0
  72. package/select/hooks/use-select-option-row.d.ts +13 -0
  73. package/select/hooks/use-select-option-row.js +20 -0
  74. package/select/hooks/use-select-view-model.d.ts +1 -1
  75. package/select/select.d.ts +1 -1
  76. package/select/types.d.ts +3 -2
  77. package/select/views/select-view.js +2 -2
  78. package/snackbar/snack-view.js +7 -7
  79. package/snackbar/use-snack-view.d.ts +8 -0
  80. package/snackbar/use-snack-view.js +13 -0
  81. package/tabs/tab-list.js +4 -22
  82. package/tabs/tab-panel.js +4 -6
  83. package/tabs/use-tab-list-navigation.d.ts +2 -0
  84. package/tabs/use-tab-list-navigation.js +24 -0
  85. package/tabs/use-tab-panel.d.ts +6 -0
  86. package/tabs/use-tab-panel.js +9 -0
  87. package/time-picker/time-panel.js +2 -47
  88. package/time-picker/use-time-column-list.d.ts +7 -0
  89. package/time-picker/use-time-column-list.js +45 -0
  90. package/tooltip/tooltip.js +1 -1
  91. package/tree/tree-row.js +15 -75
  92. package/tree/use-tree-row.d.ts +331 -0
  93. package/tree/use-tree-row.js +99 -0
  94. package/utils/class-names.d.ts +1 -1
  95. package/utils/class-names.js +3 -1
@@ -101,11 +101,11 @@
101
101
  @media (prefers-reduced-motion: no-preference) and (max-width: 479.98px) {
102
102
  .modalTransitionExitActive .overlay.curtain {
103
103
  opacity: 0;
104
- transition: opacity 4s;
104
+ transition: opacity 0.3s;
105
105
  }
106
106
  .modalTransitionExitActive .overlay.curtain::before {
107
107
  opacity: 0;
108
- transition: opacity 4s;
108
+ transition: opacity 0.3s;
109
109
  }
110
110
  }
111
111
  @media (prefers-reduced-motion: no-preference) {
@@ -101,11 +101,11 @@
101
101
  @media (prefers-reduced-motion: no-preference) and (max-width: 479.98px) {
102
102
  .modalTransitionExitActive .overlay.curtain {
103
103
  opacity: 0;
104
- transition: opacity 4s;
104
+ transition: opacity 0.3s;
105
105
  }
106
106
  .modalTransitionExitActive .overlay.curtain::before {
107
107
  opacity: 0;
108
- transition: opacity 4s;
108
+ transition: opacity 0.3s;
109
109
  }
110
110
  }
111
111
  @media (prefers-reduced-motion: no-preference) {
@@ -281,4 +281,9 @@
281
281
  flex-direction: column;
282
282
  width: 100%;
283
283
  min-height: 150px;
284
+ }
285
+
286
+ .motionDisabled .overlay, .motionDisabled .modal, .motionDisabled .overlay::before {
287
+ transition: none !important;
288
+ animation: none !important;
284
289
  }
package/modal/types.d.ts CHANGED
@@ -29,6 +29,11 @@ type ModalPropsOwn = React.ComponentPropsWithoutRef<'div'> & ModalCloseButtonPro
29
29
  * @default false
30
30
  */
31
31
  show: boolean;
32
+ /**
33
+ * Анимировать появление и закрытие окна. Учитывает системную настройку `prefers-reduced-motion`.
34
+ * @default true
35
+ */
36
+ animated?: boolean;
32
37
  /**
33
38
  * Размер модального окна.
34
39
  * @default 'm'
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from 'react';
1
+ import type { CSSProperties, ReactNode } from 'react';
2
2
  import type { ScrollValueProps } from './modal-context';
3
3
  import type { ModalProps } from './types';
4
4
  type UseModalParams = Pick<ModalProps, 'show' | 'onClose' | 'overlayClose' | 'variant' | 'children'>;
@@ -15,6 +15,8 @@ export declare function useModal({ show, onClose, overlayClose, variant, childre
15
15
  position: number;
16
16
  scroll: ScrollValueProps;
17
17
  changeContentOnScroll: (value: ScrollValueProps) => void;
18
+ renderedChildren: ReactNode;
19
+ onExited: () => void;
18
20
  modalRef: import("react").RefObject<HTMLDivElement | null>;
19
21
  overlayRef: import("react").RefObject<HTMLDivElement | null>;
20
22
  nodeRef: import("react").RefObject<null>;
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { layerManager, useLayer } from '../_internal/layer';
4
- import { useBreakpoint } from '../hooks';
4
+ import { useBreakpoint, useIsomorphicLayoutEffect } from '../hooks';
5
5
  import { MODAL_LAYER } from './constants';
6
6
  import { getModalTimeout } from './utils';
7
7
  import { useModalRefs } from './use-modal-refs';
@@ -15,6 +15,20 @@ export function useModal({ show, onClose, overlayClose = true, variant = 'simple
15
15
  const refs = useModalRefs();
16
16
  const [firstModalHeight, setFirstModalHeight] = useState(null);
17
17
  const [scroll, setScroll] = useState({ top: false, bottom: false });
18
+ const visibleChildrenRef = useRef(null);
19
+ useIsomorphicLayoutEffect(() => {
20
+ if (show)
21
+ visibleChildrenRef.current = { children };
22
+ }, [show, children]);
23
+ const renderedChildren = show
24
+ ? children
25
+ : visibleChildrenRef.current
26
+ ? visibleChildrenRef.current.children
27
+ : children;
28
+ const onExited = useCallback(() => {
29
+ if (!show)
30
+ visibleChildrenRef.current = null;
31
+ }, [show]);
18
32
  const breakpoint = useBreakpoint();
19
33
  const timeout = getModalTimeout(variant, breakpoint);
20
34
  // Позиция среди открытых окон — из стека слоёв, а не из порядка в DOM
@@ -45,5 +59,5 @@ export function useModal({ show, onClose, overlayClose = true, variant = 'simple
45
59
  return result;
46
60
  }, [position, firstModalHeight]);
47
61
  const changeContentOnScroll = useCallback((value) => setScroll(value), []);
48
- return { ...refs, timeout, style, position, scroll, changeContentOnScroll };
62
+ return { ...refs, timeout, style, position, scroll, changeContentOnScroll, renderedChildren, onExited };
49
63
  }
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import type { NavigationLinkItem } from './types';
3
- export type CompactVariant = 'rail' | 'bar' | 'bottom';
2
+ import type { CompactVariant, NavigationLinkItem } from './types';
4
3
  type CompactItemProps = {
5
4
  item: NavigationLinkItem;
6
5
  variant: CompactVariant;
@@ -1,9 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from 'clsx';
4
- import React, { useContext, useEffect, useRef, useState } from 'react';
4
+ import React, { useContext } from 'react';
5
5
  import { contextProvider } from '../_internal/compat';
6
- import { useUniqID } from '../hooks';
7
6
  import { Popover } from '../popover';
8
7
  import { Tooltip } from '../tooltip';
9
8
  import { NavigationCloseContext, useNavigationClassNames, useNavigationContext } from './context';
@@ -13,10 +12,10 @@ import { NavigationList } from './navigation-list';
13
12
  import { NavigationEntries } from './navigation-tree';
14
13
  import { getItemTooltip, useItemTooltip } from './use-item-tooltip';
15
14
  import styles from './styles/navigation.module.css';
15
+ import { useNavigationFlyout } from './use-navigation-flyout';
16
16
  const CloseProvider = contextProvider(NavigationCloseContext);
17
17
  const toId = (key) => key.replace(/\s+/g, '_');
18
18
  /** Клавиша, которой с пункта открывается список */
19
- const OPEN_KEY = { bar: 'ArrowDown', bottom: 'ArrowUp', rail: 'ArrowRight' };
20
19
  const PLACEMENT = { bar: 'bottom-start', bottom: 'top', rail: 'right-start' };
21
20
  /** Пункт рейки, шапки или нижней панели: без вложенных — ссылка или кнопка, с вложенными — всплывающий список */
22
21
  export function NavigationCompactItem({ item, variant, forceInPath = false }) {
@@ -42,38 +41,11 @@ export function NavigationCompactItem({ item, variant, forceInPath = false }) {
42
41
  return _jsx(NavigationFlyout, { item: item, variant: variant, id: id, className: className, inPath: inPath });
43
42
  }
44
43
  function NavigationFlyout({ item, variant, id, className, inPath }) {
45
- var _a, _b;
46
44
  const { size, submenuTrigger, container } = useNavigationContext('NavigationFlyout');
47
45
  const classNames = useNavigationClassNames();
48
- const [open, setOpen] = useState(false);
49
46
  const itemTooltip = useItemTooltip();
50
- const keyboardOpen = useRef(false);
51
- const menuId = useUniqID(5, 'navigation-menu');
47
+ const { open, setOpen, menuId, entries, onKeyDown } = useNavigationFlyout(item, variant);
52
48
  const labelHidden = variant === 'rail';
53
- // Ссылка родителя не теряется: она становится первым пунктом списка
54
- const entries = item.href
55
- ? [{ ...item, children: undefined, key: `${item.key}__self` }, ...((_a = item.children) !== null && _a !== void 0 ? _a : [])]
56
- : ((_b = item.children) !== null && _b !== void 0 ? _b : []);
57
- const openKey = OPEN_KEY[variant];
58
- const onKeyDown = (event) => {
59
- if (event.key !== openKey || item.disabled)
60
- return;
61
- event.preventDefault();
62
- keyboardOpen.current = true;
63
- setOpen(true);
64
- };
65
- // С клавиатуры фокус переходит в список: иначе стрелки продолжили бы двигаться по рейке
66
- useEffect(() => {
67
- if (!open || !keyboardOpen.current)
68
- return undefined;
69
- keyboardOpen.current = false;
70
- const frame = requestAnimationFrame(() => {
71
- var _a, _b;
72
- (_b = (_a = document
73
- .getElementById(menuId)) === null || _a === void 0 ? void 0 : _a.querySelector('[data-lt-ui="navigation-item"]:not(:disabled)')) === null || _b === void 0 ? void 0 : _b.focus();
74
- });
75
- return () => cancelAnimationFrame(frame);
76
- }, [open, menuId]);
77
49
  const label = typeof item.label === 'string' ? item.label : undefined;
78
50
  const popover = (_jsx(Popover, { open: open, onOpenChange: setOpen, trigger: submenuTrigger === 'hover' ? ['hover', 'click'] : 'click', placement: PLACEMENT[variant], offset: variant === 'rail' ? 4 : 8, openDelay: submenuTrigger === 'hover' ? 150 : 0, closeDelay: submenuTrigger === 'hover' ? 200 : 0, arrow: false, container: container, id: menuId, role: "presentation", className: clsx(styles.flyout, size === 's' && styles.sizeS, size === 'l' && styles.sizeL, classNames.flyout), anchor: _jsx(NavigationControl, { item: { ...item, href: undefined }, navId: id, selected: false, className: className, "aria-haspopup": "menu", "aria-expanded": open, "data-path": inPath ? '' : undefined, onKeyDown: onKeyDown, children: _jsx(NavigationItemContent, { item: item, variant: variant, nested: true }) }), children: _jsxs(CloseProvider, { value: () => setOpen(false), children: [labelHidden && _jsx("div", { className: styles.flyoutTitle, children: item.label }), _jsx(NavigationList, { orientation: "vertical", tree: true, className: clsx(styles.menu, classNames.list), "aria-label": label, children: _jsx(NavigationEntries, { entries: entries }) })] }) }));
79
51
  // Подсказка с названием, пока список закрыт: у пункта со списком нет другого способа узнать, что это
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import type { CompactVariant } from './navigation-compact';
3
- import type { NavigationEntry } from './types';
2
+ import type { CompactVariant, NavigationEntry } from './types';
4
3
  /** Плоский ряд пунктов (шапка или нижняя панель); не поместившиеся пункты уходят в «Ещё» */
5
4
  export declare function NavigationRow({ entries, variant, }: {
6
5
  entries: NavigationEntry[];
@@ -1,47 +1,20 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from 'clsx';
4
- import React, { useRef } from 'react';
5
- import { useLocale } from '../locale/use-locale';
6
- import { useNavigationClassNames, useNavigationContext } from './context';
4
+ import React from 'react';
5
+ import { useNavigationClassNames } from './context';
7
6
  import { NavigationCompactItem } from './navigation-compact';
8
7
  import { NavigationList } from './navigation-list';
9
- import { useOverflow } from './use-overflow';
10
- import { flattenGroups, isLinkItem } from './utils';
8
+ import { useNavigationRow } from './use-navigation-row';
11
9
  import styles from './styles/navigation.module.css';
12
10
  const MoreIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": true, focusable: "false", children: [_jsx("circle", { cx: "5", cy: "12", r: "2" }), _jsx("circle", { cx: "12", cy: "12", r: "2" }), _jsx("circle", { cx: "19", cy: "12", r: "2" })] }));
13
11
  /** Плоский ряд пунктов (шапка или нижняя панель); не поместившиеся пункты уходят в «Ещё» */
14
12
  export function NavigationRow({ entries, variant, }) {
15
- const { t } = useLocale();
16
- const { value } = useNavigationContext('NavigationRow');
17
13
  const classNames = useNavigationClassNames();
18
- const listRef = useRef(null);
19
- const flat = flattenGroups(entries).filter(isLinkItem);
20
- // В шапке пункты `placement: 'end'` стоят у правого края; на нижней панели порядок не меняется
21
- const links = variant === 'bar'
22
- ? [...flat.filter(link => link.placement !== 'end'), ...flat.filter(link => link.placement === 'end')]
23
- : flat;
24
- // На нижней панели помещается не больше 5 разделов: остальное сразу в «Ещё»
25
- const limit = variant === 'bottom' ? 5 : Infinity;
26
- const base = links.length > limit ? links.length - (limit - 1) : 0;
27
- const hidden = useOverflow({ listRef, base, max: Math.max(links.length - 1, 0), total: links.length });
28
- const visibleLinks = hidden > 0 ? links.slice(0, links.length - hidden) : links;
29
- const hiddenLinks = hidden > 0 ? links.slice(links.length - hidden) : [];
30
- const more = {
31
- key: '__more',
32
- label: t('navigation.more'),
33
- icon: _jsx(MoreIcon, {}),
34
- children: hiddenLinks,
35
- };
36
- const moreSelected = hiddenLinks.some(link => link.key === value || hasKey(link, value));
14
+ const { listRef, visibleLinks, hiddenLinks, more, moreSelected } = useNavigationRow({ entries, variant });
15
+ const moreItem = { ...more, icon: _jsx(MoreIcon, {}) };
37
16
  return (_jsxs(NavigationList, { orientation: "horizontal", className: clsx(styles.row, styles[`${variant}List`], classNames.list), ref: listRef, children: [visibleLinks.map((link, index) => {
38
17
  var _a;
39
18
  return (_jsxs(React.Fragment, { children: [variant === 'bar' && link.placement === 'end' && ((_a = visibleLinks[index - 1]) === null || _a === void 0 ? void 0 : _a.placement) !== 'end' && (_jsx("li", { "aria-hidden": true, className: styles.spacer })), _jsx(NavigationCompactItem, { item: link, variant: variant })] }, link.key));
40
- }), hiddenLinks.length > 0 && (_jsx(NavigationCompactItem, { item: more, variant: variant, forceInPath: moreSelected }))] }));
41
- }
42
- function hasKey(item, key) {
43
- var _a;
44
- if (key === null)
45
- return false;
46
- return ((_a = item.children) !== null && _a !== void 0 ? _a : []).some(child => isLinkItem(child) && (child.key === key || hasKey(child, key)));
19
+ }), hiddenLinks.length > 0 && (_jsx(NavigationCompactItem, { item: moreItem, variant: variant, forceInPath: moreSelected }))] }));
47
20
  }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import clsx from 'clsx';
4
- import React, { useEffect, useState } from 'react';
4
+ import React from 'react';
5
5
  import { useThemeAttribute } from '../theme-provider/theme-context';
6
6
  import { CloseButton } from '../button';
7
7
  import { contextProvider } from '../_internal/compat';
@@ -15,39 +15,18 @@ import { NavigationBranchesClosedContext, useNavigationClassNames, useNavigation
15
15
  import { NavigationRailEntries } from './navigation-rail';
16
16
  import { NavigationList } from './navigation-list';
17
17
  import { NavigationEntries } from './navigation-tree';
18
+ import { useNavigationPanelStages } from './use-navigation-panel-stages';
18
19
  import { splitByPlacement } from './utils';
19
20
  import styles from './styles/navigation.module.css';
20
21
  const BranchesClosedProvider = contextProvider(NavigationBranchesClosedContext);
21
22
  export const renderSlot = (slot, state) => typeof slot === 'function' ? slot(state) : slot;
22
23
  const BurgerIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": true, focusable: "false", children: [_jsx("rect", { x: "3", y: "6", width: "18", height: "2", rx: "1" }), _jsx("rect", { x: "3", y: "11", width: "18", height: "2", rx: "1" }), _jsx("rect", { x: "3", y: "16", width: "18", height: "2", rx: "1" })] }));
23
- // Ширина панели меняется за 200 мс (CSS), вложенные пункты ждут её окончания
24
- const WIDTH_MS = 220;
25
- /**
26
- * Смена рейки и панели в две стадии, без рывка: разворачиваем — сначала ширина, потом раскрываются ветки;
27
- * сворачиваем — ветки закрываются одновременно с сужением, и только потом рисуется рейка.
28
- * Анимации делает CSS (ширина, высота `CollapseBox`), здесь только два флага с таймером.
29
- */
30
- function useRailStages(rail) {
31
- const [railSettled, setRailSettled] = useState(rail);
32
- const [branchesOpen, setBranchesOpen] = useState(!rail);
33
- useEffect(() => {
34
- if (rail) {
35
- setBranchesOpen(false);
36
- const timer = setTimeout(() => setRailSettled(true), WIDTH_MS);
37
- return () => clearTimeout(timer);
38
- }
39
- setRailSettled(false);
40
- const timer = setTimeout(() => setBranchesOpen(true), WIDTH_MS);
41
- return () => clearTimeout(timer);
42
- }, [rail]);
43
- return { showRail: rail && railSettled, branchesClosed: !branchesOpen };
44
- }
45
24
  /** Вертикальная панель или рейка: шапка, прокручиваемый список, подвал и кнопка сворачивания */
46
25
  export function NavigationPanel({ items, state, header, footer, slotState, collapsible, }) {
47
26
  const { t } = useLocale();
48
27
  const classNames = useNavigationClassNames();
49
28
  const rail = state.layout === 'rail';
50
- const { showRail, branchesClosed } = useRailStages(rail);
29
+ const { showRail, branchesClosed } = useNavigationPanelStages(rail);
51
30
  const { start, end } = splitByPlacement(items);
52
31
  const panelHeader = renderSlot(header, slotState);
53
32
  const panelFooter = renderSlot(footer, slotState);
@@ -376,6 +376,7 @@
376
376
  }
377
377
 
378
378
  .bar {
379
+ width: 100%;
379
380
  border-block-end: 1px solid var(--lt-ui-navigation-border-color, var(--background-secondary));
380
381
  }
381
382
 
@@ -506,6 +507,7 @@
506
507
  .barShell {
507
508
  display: flex;
508
509
  align-items: center;
510
+ width: 100%;
509
511
  min-width: 0;
510
512
  }
511
513
  .barShell .row {
@@ -4,6 +4,7 @@ import type { ThemeSetting } from '../theme-provider/theme-context';
4
4
  import type { BreakpointName } from '../tokens';
5
5
  import type { ComponentClassNames, DataAttributes } from '../utils';
6
6
  export type NavigationOrientation = 'vertical' | 'horizontal';
7
+ export type CompactVariant = 'rail' | 'bar' | 'bottom';
7
8
  /**
8
9
  * Вид навигации на экране:
9
10
  * - `expanded` — вертикальная панель с подписями;
@@ -0,0 +1,9 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ import type { CompactVariant, NavigationEntry, NavigationLinkItem } from './types';
3
+ export declare function useNavigationFlyout(item: NavigationLinkItem, variant: CompactVariant): {
4
+ open: boolean;
5
+ setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ menuId: string;
7
+ entries: NavigationEntry[];
8
+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
9
+ };
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { useUniqID } from '../hooks';
4
+ const OPEN_KEY = {
5
+ bar: 'ArrowDown',
6
+ bottom: 'ArrowUp',
7
+ rail: 'ArrowRight',
8
+ };
9
+ export function useNavigationFlyout(item, variant) {
10
+ var _a, _b;
11
+ const [open, setOpen] = useState(false);
12
+ const keyboardOpen = useRef(false);
13
+ const menuId = useUniqID(5, 'navigation-menu');
14
+ const entries = item.href
15
+ ? [{ ...item, children: undefined, key: `${item.key}__self` }, ...((_a = item.children) !== null && _a !== void 0 ? _a : [])]
16
+ : ((_b = item.children) !== null && _b !== void 0 ? _b : []);
17
+ const onKeyDown = (event) => {
18
+ if (event.key !== OPEN_KEY[variant] || item.disabled)
19
+ return;
20
+ event.preventDefault();
21
+ keyboardOpen.current = true;
22
+ setOpen(true);
23
+ };
24
+ useEffect(() => {
25
+ if (!open || !keyboardOpen.current)
26
+ return undefined;
27
+ keyboardOpen.current = false;
28
+ const frame = requestAnimationFrame(() => {
29
+ var _a, _b;
30
+ (_b = (_a = document
31
+ .getElementById(menuId)) === null || _a === void 0 ? void 0 : _a.querySelector('[data-lt-ui="navigation-item"]:not(:disabled)')) === null || _b === void 0 ? void 0 : _b.focus();
32
+ });
33
+ return () => cancelAnimationFrame(frame);
34
+ }, [open, menuId]);
35
+ return { open, setOpen, menuId, entries, onKeyDown };
36
+ }
@@ -0,0 +1,5 @@
1
+ /** Согласует появление дерева пунктов с переходом ширины между рейкой и панелью. */
2
+ export declare function useNavigationPanelStages(rail: boolean): {
3
+ showRail: boolean;
4
+ branchesClosed: boolean;
5
+ };
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { useEffect, useState } from 'react';
3
+ // Синхронизировано с CSS transition ширины в navigation.module.scss.
4
+ const WIDTH_MS = 220;
5
+ /** Согласует появление дерева пунктов с переходом ширины между рейкой и панелью. */
6
+ export function useNavigationPanelStages(rail) {
7
+ const [railSettled, setRailSettled] = useState(rail);
8
+ const [branchesOpen, setBranchesOpen] = useState(!rail);
9
+ useEffect(() => {
10
+ if (rail) {
11
+ setBranchesOpen(false);
12
+ const timer = setTimeout(() => setRailSettled(true), WIDTH_MS);
13
+ return () => clearTimeout(timer);
14
+ }
15
+ setRailSettled(false);
16
+ const timer = setTimeout(() => setBranchesOpen(true), WIDTH_MS);
17
+ return () => clearTimeout(timer);
18
+ }, [rail]);
19
+ return { showRail: rail && railSettled, branchesClosed: !branchesOpen };
20
+ }
@@ -0,0 +1,16 @@
1
+ import type { RefObject } from 'react';
2
+ import type { CompactVariant, NavigationEntry, NavigationLinkItem } from './types';
3
+ type Params = {
4
+ entries: NavigationEntry[];
5
+ variant: Exclude<CompactVariant, 'rail'>;
6
+ };
7
+ type NavigationRowModel = {
8
+ listRef: RefObject<HTMLUListElement | null>;
9
+ visibleLinks: NavigationLinkItem[];
10
+ hiddenLinks: NavigationLinkItem[];
11
+ more: NavigationLinkItem;
12
+ moreSelected: boolean;
13
+ };
14
+ /** Подготавливает плоские пункты и состояние переполнения строки навигации. */
15
+ export declare function useNavigationRow({ entries, variant }: Params): NavigationRowModel;
16
+ export {};
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { useRef } from 'react';
3
+ import { useLocale } from '../locale/use-locale';
4
+ import { useNavigationContext } from './context';
5
+ import { useOverflow } from './use-overflow';
6
+ import { flattenGroups, isLinkItem } from './utils';
7
+ /** Подготавливает плоские пункты и состояние переполнения строки навигации. */
8
+ export function useNavigationRow({ entries, variant }) {
9
+ const { t } = useLocale();
10
+ const { value } = useNavigationContext('NavigationRow');
11
+ const listRef = useRef(null);
12
+ const flat = flattenGroups(entries).filter(isLinkItem);
13
+ // В шапке пункты `placement: 'end'` стоят у правого края; на нижней панели порядок не меняется
14
+ const links = variant === 'bar'
15
+ ? [...flat.filter(link => link.placement !== 'end'), ...flat.filter(link => link.placement === 'end')]
16
+ : flat;
17
+ // На нижней панели помещается не больше 5 разделов: остальное сразу в «Ещё»
18
+ const limit = variant === 'bottom' ? 5 : Infinity;
19
+ const base = links.length > limit ? links.length - (limit - 1) : 0;
20
+ const hidden = useOverflow({ listRef, base, max: Math.max(links.length - 1, 0), total: links.length });
21
+ const visibleLinks = hidden > 0 ? links.slice(0, links.length - hidden) : links;
22
+ const hiddenLinks = hidden > 0 ? links.slice(links.length - hidden) : [];
23
+ const more = {
24
+ key: '__more',
25
+ label: t('navigation.more'),
26
+ children: hiddenLinks,
27
+ };
28
+ const moreSelected = hiddenLinks.some(link => link.key === value || hasKey(link, value));
29
+ return { listRef, visibleLinks, hiddenLinks, more, moreSelected };
30
+ }
31
+ function hasKey(item, key) {
32
+ var _a;
33
+ if (key === null)
34
+ return false;
35
+ return ((_a = item.children) !== null && _a !== void 0 ? _a : []).some(child => isLinkItem(child) && (child.key === key || hasKey(child, key)));
36
+ }
@@ -354,6 +354,7 @@ export declare function useNumberInput(props: NumberInputProps, ref: React.Ref<H
354
354
  onTransitionStartCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
355
355
  readOnly?: boolean | undefined | undefined;
356
356
  required?: boolean | undefined | undefined;
357
+ webkitdirectory?: boolean | string | undefined | undefined;
357
358
  } | {
358
359
  id: string;
359
360
  ref: React.RefCallback<HTMLInputElement>;
@@ -660,5 +661,6 @@ export declare function useNumberInput(props: NumberInputProps, ref: React.Ref<H
660
661
  onTransitionStartCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
661
662
  readOnly?: boolean | undefined | undefined;
662
663
  required?: boolean | undefined | undefined;
664
+ webkitdirectory?: boolean | string | undefined | undefined;
663
665
  };
664
666
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lt-ui/uikit",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "LT UI",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -58,10 +58,10 @@ type PopoverPropsOwn = OverlayContainerProps & {
58
58
  shift?: boolean;
59
59
  /**
60
60
  * Ширина поповера равна ширине активатора (выпадающие списки). `'min'` — не уже активатора, но по длине
61
- * содержимого без переноса.
61
+ * содержимого без переноса. Число задаёт фиксированную ширину в пикселях.
62
62
  * @default false
63
63
  */
64
- matchWidth?: boolean | 'min';
64
+ matchWidth?: boolean | 'min' | number;
65
65
  /**
66
66
  * Задержка открытия для `hover`, мс.
67
67
  * @default 0
@@ -13,6 +13,8 @@ export type SelectMultiselectPanelProps<T extends ItemValue = ItemValue> = {
13
13
  onRemoveChip: (value: T) => void;
14
14
  onClear: () => void;
15
15
  showPanelHeader?: boolean;
16
+ /** Рисовать чипсы и переключатель их раскрытия в панели. */
17
+ chipsEnabled?: boolean;
16
18
  chipsExpanded: boolean;
17
19
  /**
18
20
  * Режим раскрытия chips (см. `chipsExpandedMode` в `SelectProps`). При `'auto'` панель сама
@@ -57,4 +59,4 @@ export type SelectMultiselectPanelProps<T extends ItemValue = ItemValue> = {
57
59
  mobile?: boolean;
58
60
  virtualized?: SelectVirtualized;
59
61
  };
60
- export declare function SelectMultiselectPanel<T extends ItemValue = ItemValue>({ id, options, chipOptions, value: selectedValues, onUpdate: onSelect, onRemoveChip, onClear, showPanelHeader, chipsExpanded, chipsExpandedMode, onToggleChips, onChipsOverflow, emptySelectionLabel: emptySelectionLabelProp, selectedCountLabel: selectedCountLabelProp, collapseLabel: collapseLabelProp, clearLabel: clearLabelProp, size, className, children, open, showLoader, showNotFound, showMinCharsHint, notFoundContent, minCharsContent, loadingContent, activeValue, onOptionMouseMove, onListMouseMove, keyboardNavActive, restoreComboboxFocus, maxHeight, chipsMaxRows, mobile, searchActive, virtualized, }: Readonly<SelectMultiselectPanelProps<T>>): React.JSX.Element | null;
62
+ export declare function SelectMultiselectPanel<T extends ItemValue = ItemValue>({ id, options, chipOptions, value: selectedValues, onUpdate: onSelect, onRemoveChip, onClear, showPanelHeader, chipsEnabled, chipsExpanded, chipsExpandedMode, onToggleChips, onChipsOverflow, emptySelectionLabel: emptySelectionLabelProp, selectedCountLabel: selectedCountLabelProp, collapseLabel: collapseLabelProp, clearLabel: clearLabelProp, size, className, children, open, showLoader, showNotFound, showMinCharsHint, notFoundContent, minCharsContent, loadingContent, activeValue, onOptionMouseMove, onListMouseMove, keyboardNavActive, restoreComboboxFocus, maxHeight, chipsMaxRows, mobile, searchActive, virtualized, }: Readonly<SelectMultiselectPanelProps<T>>): React.JSX.Element | null;