@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
@@ -9,7 +9,7 @@ export type UseFloatingOptions = {
9
9
  shift?: boolean;
10
10
  arrowSize?: number;
11
11
  /** Ширина плавающего элемента равна ширине опорного; `'min'` — не уже опорного, но по содержимому без переноса */
12
- matchWidth?: boolean | 'min';
12
+ matchWidth?: boolean | 'min' | number;
13
13
  /** Окно не выходит за этот элемент (контейнер портала с обрезкой, рамка превью), а не только за окно браузера */
14
14
  boundary?: HTMLElement | null;
15
15
  };
@@ -69,7 +69,11 @@ export function useFloating({ open, placement = 'bottom', offset = 0, padding =
69
69
  return;
70
70
  const referenceRect = reference.getBoundingClientRect();
71
71
  const origin = getOrigin(floating);
72
- const width = matchWidth === true ? referenceRect.width / origin.scale : undefined;
72
+ const width = typeof matchWidth === 'number'
73
+ ? matchWidth
74
+ : matchWidth === true
75
+ ? referenceRect.width / origin.scale
76
+ : undefined;
73
77
  const minWidth = matchWidth === 'min' ? referenceRect.width / origin.scale : undefined;
74
78
  // Размеры окна считаем в экранных пикселях, как и опорного элемента
75
79
  const size = {
@@ -130,7 +134,7 @@ export function useFloating({ open, placement = 'bottom', offset = 0, padding =
130
134
  left: state.x,
131
135
  width: (_a = state.width) !== null && _a !== void 0 ? _a : (state.minWidth ? 'max-content' : undefined),
132
136
  minWidth: state.minWidth,
133
- maxWidth: state.minWidth ? '100vw' : undefined,
137
+ maxWidth: state.minWidth ? '100vw' : typeof matchWidth === 'number' ? 'calc(100vw - 16px)' : undefined,
134
138
  // До первого расчёта элемент уже в DOM, но не должен мигать в углу
135
139
  visibility: state.positioned ? undefined : 'hidden',
136
140
  };
@@ -72,7 +72,11 @@ function useFloating({ open, placement = 'bottom', offset = 0, padding = 8, flip
72
72
  return;
73
73
  const referenceRect = reference.getBoundingClientRect();
74
74
  const origin = (0, origin_1.getOrigin)(floating);
75
- const width = matchWidth === true ? referenceRect.width / origin.scale : undefined;
75
+ const width = typeof matchWidth === 'number'
76
+ ? matchWidth
77
+ : matchWidth === true
78
+ ? referenceRect.width / origin.scale
79
+ : undefined;
76
80
  const minWidth = matchWidth === 'min' ? referenceRect.width / origin.scale : undefined;
77
81
  // Размеры окна считаем в экранных пикселях, как и опорного элемента
78
82
  const size = {
@@ -133,7 +137,7 @@ function useFloating({ open, placement = 'bottom', offset = 0, padding = 8, flip
133
137
  left: state.x,
134
138
  width: (_a = state.width) !== null && _a !== void 0 ? _a : (state.minWidth ? 'max-content' : undefined),
135
139
  minWidth: state.minWidth,
136
- maxWidth: state.minWidth ? '100vw' : undefined,
140
+ maxWidth: state.minWidth ? '100vw' : typeof matchWidth === 'number' ? 'calc(100vw - 16px)' : undefined,
137
141
  // До первого расчёта элемент уже в DOM, но не должен мигать в углу
138
142
  visibility: state.positioned ? undefined : 'hidden',
139
143
  };
@@ -6,17 +6,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ImageViewer = ImageViewer;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
- const react_1 = require("react");
10
9
  const react_dom_1 = __importDefault(require("react-dom"));
11
10
  const compat_1 = require("../_internal/compat");
12
11
  const focus_trap_1 = require("../_internal/focus-trap");
13
12
  const hooks_1 = require("../_internal/hooks");
14
- const layer_1 = require("../_internal/layer");
15
13
  const button_1 = require("../button");
16
14
  const icons_1 = require("../icons");
17
15
  const loader_1 = require("../loader");
18
16
  const portal_1 = require("../portal");
19
17
  const viewer_module_scss_1 = __importDefault(require("./viewer.module.css"));
18
+ const use_image_viewer_1 = require("./use-image-viewer");
20
19
  const FocusOnProvider = (0, compat_1.contextProvider)(hooks_1.FocusOnContext);
21
20
  /**
22
21
  * Полноэкранный просмотр: затемнение, фокус остаётся внутри, закрывается Escape, кликом вне картинки или крестиком.
@@ -25,22 +24,13 @@ const FocusOnProvider = (0, compat_1.contextProvider)(hooks_1.FocusOnContext);
25
24
  const DownloadIcon = () => ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", "aria-hidden": true, children: (0, jsx_runtime_1.jsx)("path", { d: "M12 4v11m0 0-4-4m4 4 4-4M5 19.5h14", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
26
25
  function ImageViewer({ testId, src, alt, srcSet, sizes, closeLabel, loading, downloadLabel, downloadName, onClose, container, }) {
27
26
  const target = (0, portal_1.usePortalTarget)({ container });
28
- const imageRef = (0, react_1.useRef)(null);
29
- const closeRef = (0, react_1.useRef)(null);
30
- const [zoomed, setZoomed] = (0, react_1.useState)(false);
31
- const contentRefs = (0, react_1.useMemo)(() => [imageRef, closeRef], []);
32
- (0, layer_1.useLayer)({ open: true, type: 'image-viewer', contentRefs, onClose });
27
+ const { imageRef, closeRef, zoomed, toggleZoom, onImageKeyDown } = (0, use_image_viewer_1.useImageViewer)(onClose);
33
28
  const viewer = ((0, jsx_runtime_1.jsx)(focus_trap_1.FocusTrap, { returnFocus: true, children: (0, jsx_runtime_1.jsxs)("div", { className: viewer_module_scss_1.default.viewer, role: "dialog", "data-testid": testId, "aria-modal": "true", "aria-label": alt, "data-lt-ui-theme": "dark", "data-lt-ui-portal": "", children: [(0, jsx_runtime_1.jsxs)("div", { ref: closeRef, className: viewer_module_scss_1.default.close, children: [downloadLabel && !loading && ((0, jsx_runtime_1.jsx)(button_1.Button, { iconOnly: true, compact: true, "aria-label": downloadLabel, variant: "link-minor", className: viewer_module_scss_1.default.tool, onClick: () => {
34
29
  const link = globalThis.document.createElement('a');
35
30
  link.href = src;
36
31
  link.download = downloadName !== null && downloadName !== void 0 ? downloadName : '';
37
32
  link.click();
38
- }, children: (0, jsx_runtime_1.jsx)(DownloadIcon, {}) })), (0, jsx_runtime_1.jsx)(button_1.Button, { iconOnly: true, compact: true, "aria-label": closeLabel, variant: "link-minor", className: viewer_module_scss_1.default.tool, onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_1.CloseIcon, {}) })] }), (0, jsx_runtime_1.jsx)("div", { className: zoomed ? viewer_module_scss_1.default.scrollZoomed : viewer_module_scss_1.default.scroll, children: (0, jsx_runtime_1.jsx)(FocusOnProvider, { value: true, children: loading ? ((0, jsx_runtime_1.jsx)(loader_1.Loader, { size: "m" })) : ((0, jsx_runtime_1.jsx)("img", { ref: imageRef, className: zoomed ? viewer_module_scss_1.default.zoomed : viewer_module_scss_1.default.fit, src: src, srcSet: srcSet, sizes: sizes, alt: alt, role: "button", tabIndex: 0, "aria-pressed": zoomed, onClick: () => setZoomed(value => !value), onKeyDown: event => {
39
- if (event.key === 'Enter' || event.key === ' ') {
40
- event.preventDefault();
41
- setZoomed(value => !value);
42
- }
43
- } })) }) })] }) }));
33
+ }, children: (0, jsx_runtime_1.jsx)(DownloadIcon, {}) })), (0, jsx_runtime_1.jsx)(button_1.Button, { iconOnly: true, compact: true, "aria-label": closeLabel, variant: "link-minor", className: viewer_module_scss_1.default.tool, onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_1.CloseIcon, {}) })] }), (0, jsx_runtime_1.jsx)("div", { className: zoomed ? viewer_module_scss_1.default.scrollZoomed : viewer_module_scss_1.default.scroll, children: (0, jsx_runtime_1.jsx)(FocusOnProvider, { value: true, children: loading ? ((0, jsx_runtime_1.jsx)(loader_1.Loader, { size: "m" })) : ((0, jsx_runtime_1.jsx)("img", { ref: imageRef, className: zoomed ? viewer_module_scss_1.default.zoomed : viewer_module_scss_1.default.fit, src: src, srcSet: srcSet, sizes: sizes, alt: alt, role: "button", tabIndex: 0, "aria-pressed": zoomed, onClick: toggleZoom, onKeyDown: onImageKeyDown })) }) })] }) }));
44
34
  if ((0, portal_1.isInlineContainer)(container))
45
35
  return viewer;
46
36
  return target ? react_dom_1.default.createPortal(viewer, target) : null;
@@ -15,6 +15,7 @@ const data_attributes_1 = require("../utils/data-attributes");
15
15
  const image_viewer_1 = require("./image-viewer");
16
16
  const style_module_scss_1 = __importDefault(require("./style.module.css"));
17
17
  const use_image_1 = require("./use-image");
18
+ const use_image_preview_1 = require("./use-image-preview");
18
19
  /**
19
20
  * `<Image />` — изображение с состояниями загрузки и ошибки, скруглением и необязательным просмотром на весь экран.
20
21
  * Принимает все атрибуты `<img>` (`srcSet`, `sizes`, `loading="lazy"`...).
@@ -24,7 +25,7 @@ const use_image_1 = require("./use-image");
24
25
  * ```
25
26
  */
26
27
  exports.Image = (0, compat_1.withRef)(function Image({ src, alt, rounding, width, height, objectFit, fallback, placeholder, preview, previewSrc, loadPreview, download, downloadLabel, previewOpen: previewOpenProp, onPreviewOpenChange, previewLabel, previewCloseLabel, container, className, classNames: classNamesProp, style: styleProp, onLoad, onError, srcSet, sizes, ...imgProps }, ref) {
27
- var _a, _b;
28
+ var _a, _b, _c;
28
29
  const { t } = (0, use_locale_1.useLocale)();
29
30
  const classNames = (0, utils_1.useClassNames)('Image', classNamesProp);
30
31
  const vm = (0, use_image_1.useImage)({
@@ -35,31 +36,7 @@ exports.Image = (0, compat_1.withRef)(function Image({ src, alt, rounding, width
35
36
  previewOpen: previewOpenProp,
36
37
  onPreviewOpenChange,
37
38
  });
38
- const [resolved, setResolved] = (0, react_1.useState)();
39
- const [resolving, setResolving] = (0, react_1.useState)(false);
40
- const openPreview = async () => {
41
- vm.openPreview();
42
- if (!loadPreview || resolved)
43
- return;
44
- // Окно открывается сразу с индикатором, большая версия подставляется, когда загружена
45
- setResolving(true);
46
- try {
47
- const url = await loadPreview();
48
- await new Promise(resolve => {
49
- const probe = new globalThis.Image();
50
- probe.onload = () => resolve();
51
- probe.onerror = () => resolve();
52
- probe.src = url;
53
- });
54
- setResolved(url);
55
- }
56
- catch {
57
- // не получилось: останется то, что есть
58
- }
59
- finally {
60
- setResolving(false);
61
- }
62
- };
39
+ const previewState = (0, use_image_preview_1.useImagePreview)({ loadPreview, openPreview: vm.openPreview });
63
40
  const imgRef = (0, react_1.useMemo)(() => (0, utils_1.mergeRefs)([vm.setImg, ref]), [vm.setImg, ref]);
64
41
  const image = ((0, jsx_runtime_1.jsx)("img", { ...(0, data_attributes_1.splitDataAttributes)(imgProps).nativeProps, ref: imgRef, className: (0, clsx_1.default)(style_module_scss_1.default.img, classNames.img), style: { objectFit }, src: src, srcSet: srcSet, sizes: sizes, alt: alt, onLoad: vm.onLoad, onError: vm.onError }));
65
42
  const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [image, vm.status === 'loading' && placeholder && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(style_module_scss_1.default.overlay, classNames.overlay), children: placeholder })), vm.status === 'error' && fallback && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(style_module_scss_1.default.overlay, classNames.overlay), children: fallback }))] }));
@@ -69,5 +46,5 @@ exports.Image = (0, compat_1.withRef)(function Image({ src, alt, rounding, width
69
46
  ...(0, data_attributes_1.getDataAttributes)(imgProps, 'image-wrapper'),
70
47
  'data-status': vm.status,
71
48
  };
72
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [vm.interactive ? ((0, jsx_runtime_1.jsx)("button", { ...wrapperProps, type: "button", className: (0, clsx_1.default)(wrapperProps.className, style_module_scss_1.default.interactive), "aria-label": `${previewLabel !== null && previewLabel !== void 0 ? previewLabel : t('image.preview')}: ${alt}`, "aria-haspopup": "dialog", onClick: openPreview, children: content })) : ((0, jsx_runtime_1.jsx)("div", { ...wrapperProps, children: content })), vm.previewOpen && src && ((0, jsx_runtime_1.jsx)(image_viewer_1.ImageViewer, { testId: (0, data_attributes_1.getRelatedTestId)((_a = imgProps['data-testid']) !== null && _a !== void 0 ? _a : 'image-wrapper', 'popup'), src: (_b = resolved !== null && resolved !== void 0 ? resolved : previewSrc) !== null && _b !== void 0 ? _b : src, srcSet: resolved || previewSrc ? undefined : srcSet, sizes: sizes, alt: alt, closeLabel: previewCloseLabel !== null && previewCloseLabel !== void 0 ? previewCloseLabel : t('image.closePreview'), loading: resolving, downloadLabel: download ? (downloadLabel !== null && downloadLabel !== void 0 ? downloadLabel : t('image.download')) : undefined, downloadName: typeof download === 'string' ? download : undefined, onClose: vm.closePreview, container: container }))] }));
49
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [vm.interactive ? ((0, jsx_runtime_1.jsx)("button", { ...wrapperProps, type: "button", className: (0, clsx_1.default)(wrapperProps.className, style_module_scss_1.default.interactive), "aria-label": `${previewLabel !== null && previewLabel !== void 0 ? previewLabel : t('image.preview')}: ${alt}`, "aria-haspopup": "dialog", onClick: previewState.openPreview, children: content })) : ((0, jsx_runtime_1.jsx)("div", { ...wrapperProps, children: content })), vm.previewOpen && src && ((0, jsx_runtime_1.jsx)(image_viewer_1.ImageViewer, { testId: (0, data_attributes_1.getRelatedTestId)((_a = imgProps['data-testid']) !== null && _a !== void 0 ? _a : 'image-wrapper', 'popup'), src: (_c = (_b = previewState.resolved) !== null && _b !== void 0 ? _b : previewSrc) !== null && _c !== void 0 ? _c : src, srcSet: previewState.resolved || previewSrc ? undefined : srcSet, sizes: sizes, alt: alt, closeLabel: previewCloseLabel !== null && previewCloseLabel !== void 0 ? previewCloseLabel : t('image.closePreview'), loading: previewState.resolving, downloadLabel: download ? (downloadLabel !== null && downloadLabel !== void 0 ? downloadLabel : t('image.download')) : undefined, downloadName: typeof download === 'string' ? download : undefined, onClose: vm.closePreview, container: container }))] }));
73
50
  });
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useImagePreview = useImagePreview;
5
+ const react_1 = require("react");
6
+ function useImagePreview({ loadPreview, openPreview }) {
7
+ const [resolved, setResolved] = (0, react_1.useState)();
8
+ const [resolving, setResolving] = (0, react_1.useState)(false);
9
+ const open = (0, react_1.useCallback)(async () => {
10
+ openPreview();
11
+ if (!loadPreview || resolved)
12
+ return;
13
+ setResolving(true);
14
+ try {
15
+ const url = await loadPreview();
16
+ await new Promise(resolve => {
17
+ const probe = new globalThis.Image();
18
+ probe.onload = () => resolve();
19
+ probe.onerror = () => resolve();
20
+ probe.src = url;
21
+ });
22
+ setResolved(url);
23
+ }
24
+ catch {
25
+ // Если большая версия недоступна, остаётся исходное изображение.
26
+ }
27
+ finally {
28
+ setResolving(false);
29
+ }
30
+ }, [loadPreview, openPreview, resolved]);
31
+ return { resolved, resolving, openPreview: open };
32
+ }
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useImageViewer = useImageViewer;
5
+ const react_1 = require("react");
6
+ const layer_1 = require("../_internal/layer");
7
+ function useImageViewer(onClose) {
8
+ const imageRef = (0, react_1.useRef)(null);
9
+ const closeRef = (0, react_1.useRef)(null);
10
+ const [zoomed, setZoomed] = (0, react_1.useState)(false);
11
+ const contentRefs = (0, react_1.useMemo)(() => [imageRef, closeRef], []);
12
+ (0, layer_1.useLayer)({ open: true, type: 'image-viewer', contentRefs, onClose });
13
+ const toggleZoom = () => setZoomed(value => !value);
14
+ const onImageKeyDown = (event) => {
15
+ if (event.key !== 'Enter' && event.key !== ' ')
16
+ return;
17
+ event.preventDefault();
18
+ toggleZoom();
19
+ };
20
+ return { imageRef, closeRef, zoomed, toggleZoom, onImageKeyDown };
21
+ }
@@ -35,22 +35,16 @@ Object.defineProperty(exports, "getTimerCurtain", { enumerable: true, get: funct
35
35
  </Modal>;
36
36
  * ```
37
37
  */
38
- exports.Modal = (0, compat_1.withRef)(function Modal({ children, modalID, className = '', classNames: classNamesProp, onClose, size = 'm', variant = 'simple', show, toTop = false, sticky, closeButton = true, overlayClose = true, container, theme, ...dataProps }, ref) {
38
+ exports.Modal = (0, compat_1.withRef)(function Modal({ children, modalID, className = '', classNames: classNamesProp, onClose, size = 'm', variant = 'simple', show, animated = true, toTop = false, sticky, closeButton = true, overlayClose = true, container, theme, ...dataProps }, ref) {
39
39
  const classNames = (0, utils_1.useClassNames)('Modal', classNamesProp);
40
- const { modalRef, overlayRef, nodeRef, timeout, style, scroll, changeContentOnScroll } = (0, use_modal_1.useModal)({
41
- show,
42
- onClose,
43
- overlayClose,
44
- variant,
45
- children,
46
- });
40
+ const { modalRef, overlayRef, nodeRef, timeout, style, scroll, changeContentOnScroll, renderedChildren, onExited, } = (0, use_modal_1.useModal)({ show, onClose, overlayClose, variant, children });
47
41
  const themeAttribute = (0, theme_context_1.useThemeAttribute)(theme, { portal: true });
48
42
  const overLayClass = (0, clsx_1.default)(modal_module_scss_1.default.overlay, modal_module_scss_1.default[variant], classNames.overlay);
49
43
  const modalClass = (0, clsx_1.default)(modal_module_scss_1.default.modal, modal_module_scss_1.default[variant], modal_module_scss_1.default[size], sticky && modal_module_scss_1.default.sticky, classNames.root, className);
50
44
  const wrapperClass = (0, clsx_1.default)(modal_module_scss_1.default.wrapper, modal_module_scss_1.default[size], modal_module_scss_1.default[variant], toTop && modal_module_scss_1.default.toTop, classNames.wrapper);
51
45
  const scrollContext = (0, react_1.useMemo)(() => ({ changeContentOnScroll, scrollTop: scroll.top, scrollBottom: scroll.bottom }), [changeContentOnScroll, scroll.top, scroll.bottom]);
52
46
  const modalContext = (0, react_1.useMemo)(() => ({ variant, sticky, size, classNames }), [variant, sticky, size, classNames]);
53
- return ((0, jsx_runtime_1.jsx)(portal_1.Portal, { container: container, children: (0, jsx_runtime_1.jsx)(transition_1.CSSTransition, { nodeRef: nodeRef, timeout: timeout, in: show,
47
+ return ((0, jsx_runtime_1.jsx)(portal_1.Portal, { container: container, children: (0, jsx_runtime_1.jsx)(transition_1.CSSTransition, { nodeRef: nodeRef, timeout: animated ? timeout : 0, in: show, enter: animated, exit: animated, onExited: onExited,
54
48
  // Окно, смонтированное уже открытым (`{open && <Modal show />}`), тоже должно появляться с анимацией
55
49
  appear: true, classNames: {
56
50
  appear: modal_module_scss_1.default.modalTransitionEnter,
@@ -59,5 +53,5 @@ exports.Modal = (0, compat_1.withRef)(function Modal({ children, modalID, classN
59
53
  enterActive: modal_module_scss_1.default.modalTransitionEnterActive,
60
54
  exit: modal_module_scss_1.default.modalTransitionExit,
61
55
  exitActive: modal_module_scss_1.default.modalTransitionExitActive,
62
- }, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)("div", { className: modal_module_scss_1.default.animationWrapper, ref: nodeRef, children: [(0, jsx_runtime_1.jsx)(hooks_1.RestoreFocus, {}), (0, jsx_runtime_1.jsx)(focus_trap_1.FocusTrap, { children: (0, jsx_runtime_1.jsx)("div", { ref: overlayRef, className: overLayClass, style: style, "data-lt-ui-theme": themeAttribute, ...(0, data_attributes_1.getDataAttributes)(dataProps, 'modal'), "data-lt-ui": "modal", children: (0, jsx_runtime_1.jsx)("div", { className: wrapperClass, ref: ref, children: (0, jsx_runtime_1.jsxs)("div", { className: modalClass, role: "dialog", "aria-modal": "true", "aria-labelledby": modalID && `${modalID}_label`, "aria-describedby": modalID && `${modalID}_desc`, ref: modalRef, children: [closeButton && (0, jsx_runtime_1.jsx)(modal_close_button_1.ModalCloseButton, { onClose: onClose, className: classNames.close }), (0, jsx_runtime_1.jsx)(ScrollProvider, { value: scrollContext, children: (0, jsx_runtime_1.jsx)(ModalProvider, { value: modalContext, children: (0, jsx_runtime_1.jsx)(FocusOnProvider, { value: true, children: (0, jsx_runtime_1.jsx)("div", { className: modal_module_scss_1.default.contentWrapper, children: children }) }) }) })] }) }) }) })] }) }) }));
56
+ }, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)(modal_module_scss_1.default.animationWrapper, !animated && modal_module_scss_1.default.motionDisabled), ref: nodeRef, children: [(0, jsx_runtime_1.jsx)(hooks_1.RestoreFocus, {}), (0, jsx_runtime_1.jsx)(focus_trap_1.FocusTrap, { children: (0, jsx_runtime_1.jsx)("div", { ref: overlayRef, className: overLayClass, style: style, "data-lt-ui-theme": themeAttribute, ...(0, data_attributes_1.getDataAttributes)(dataProps, 'modal'), "data-lt-ui": "modal", children: (0, jsx_runtime_1.jsx)("div", { className: wrapperClass, ref: ref, children: (0, jsx_runtime_1.jsxs)("div", { className: modalClass, role: "dialog", "aria-modal": "true", "aria-labelledby": modalID && `${modalID}_label`, "aria-describedby": modalID && `${modalID}_desc`, ref: modalRef, children: [closeButton && (0, jsx_runtime_1.jsx)(modal_close_button_1.ModalCloseButton, { onClose: onClose, className: classNames.close }), (0, jsx_runtime_1.jsx)(ScrollProvider, { value: scrollContext, children: (0, jsx_runtime_1.jsx)(ModalProvider, { value: modalContext, children: (0, jsx_runtime_1.jsx)(FocusOnProvider, { value: true, children: (0, jsx_runtime_1.jsx)("div", { className: modal_module_scss_1.default.contentWrapper, children: renderedChildren }) }) }) })] }) }) }) })] }) }) }));
63
57
  });
@@ -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
  }
@@ -18,6 +18,20 @@ function useModal({ show, onClose, overlayClose = true, variant = 'simple', chil
18
18
  const refs = (0, use_modal_refs_1.useModalRefs)();
19
19
  const [firstModalHeight, setFirstModalHeight] = (0, react_1.useState)(null);
20
20
  const [scroll, setScroll] = (0, react_1.useState)({ top: false, bottom: false });
21
+ const visibleChildrenRef = (0, react_1.useRef)(null);
22
+ (0, hooks_1.useIsomorphicLayoutEffect)(() => {
23
+ if (show)
24
+ visibleChildrenRef.current = { children };
25
+ }, [show, children]);
26
+ const renderedChildren = show
27
+ ? children
28
+ : visibleChildrenRef.current
29
+ ? visibleChildrenRef.current.children
30
+ : children;
31
+ const onExited = (0, react_1.useCallback)(() => {
32
+ if (!show)
33
+ visibleChildrenRef.current = null;
34
+ }, [show]);
21
35
  const breakpoint = (0, hooks_1.useBreakpoint)();
22
36
  const timeout = (0, utils_1.getModalTimeout)(variant, breakpoint);
23
37
  // Позиция среди открытых окон — из стека слоёв, а не из порядка в DOM
@@ -48,5 +62,5 @@ function useModal({ show, onClose, overlayClose = true, variant = 'simple', chil
48
62
  return result;
49
63
  }, [position, firstModalHeight]);
50
64
  const changeContentOnScroll = (0, react_1.useCallback)((value) => setScroll(value), []);
51
- return { ...refs, timeout, style, position, scroll, changeContentOnScroll };
65
+ return { ...refs, timeout, style, position, scroll, changeContentOnScroll, renderedChildren, onExited };
52
66
  }
@@ -42,7 +42,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
42
42
  const clsx_1 = __importDefault(require("clsx"));
43
43
  const react_1 = __importStar(require("react"));
44
44
  const compat_1 = require("../_internal/compat");
45
- const hooks_1 = require("../hooks");
46
45
  const popover_1 = require("../popover");
47
46
  const tooltip_1 = require("../tooltip");
48
47
  const context_1 = require("./context");
@@ -52,10 +51,10 @@ const navigation_list_1 = require("./navigation-list");
52
51
  const navigation_tree_1 = require("./navigation-tree");
53
52
  const use_item_tooltip_1 = require("./use-item-tooltip");
54
53
  const navigation_module_scss_1 = __importDefault(require("./styles/navigation.module.css"));
54
+ const use_navigation_flyout_1 = require("./use-navigation-flyout");
55
55
  const CloseProvider = (0, compat_1.contextProvider)(context_1.NavigationCloseContext);
56
56
  const toId = (key) => key.replace(/\s+/g, '_');
57
57
  /** Клавиша, которой с пункта открывается список */
58
- const OPEN_KEY = { bar: 'ArrowDown', bottom: 'ArrowUp', rail: 'ArrowRight' };
59
58
  const PLACEMENT = { bar: 'bottom-start', bottom: 'top', rail: 'right-start' };
60
59
  /** Пункт рейки, шапки или нижней панели: без вложенных — ссылка или кнопка, с вложенными — всплывающий список */
61
60
  function NavigationCompactItem({ item, variant, forceInPath = false }) {
@@ -81,38 +80,11 @@ function NavigationCompactItem({ item, variant, forceInPath = false }) {
81
80
  return (0, jsx_runtime_1.jsx)(NavigationFlyout, { item: item, variant: variant, id: id, className: className, inPath: inPath });
82
81
  }
83
82
  function NavigationFlyout({ item, variant, id, className, inPath }) {
84
- var _a, _b;
85
83
  const { size, submenuTrigger, container } = (0, context_1.useNavigationContext)('NavigationFlyout');
86
84
  const classNames = (0, context_1.useNavigationClassNames)();
87
- const [open, setOpen] = (0, react_1.useState)(false);
88
85
  const itemTooltip = (0, use_item_tooltip_1.useItemTooltip)();
89
- const keyboardOpen = (0, react_1.useRef)(false);
90
- const menuId = (0, hooks_1.useUniqID)(5, 'navigation-menu');
86
+ const { open, setOpen, menuId, entries, onKeyDown } = (0, use_navigation_flyout_1.useNavigationFlyout)(item, variant);
91
87
  const labelHidden = variant === 'rail';
92
- // Ссылка родителя не теряется: она становится первым пунктом списка
93
- const entries = item.href
94
- ? [{ ...item, children: undefined, key: `${item.key}__self` }, ...((_a = item.children) !== null && _a !== void 0 ? _a : [])]
95
- : ((_b = item.children) !== null && _b !== void 0 ? _b : []);
96
- const openKey = OPEN_KEY[variant];
97
- const onKeyDown = (event) => {
98
- if (event.key !== openKey || item.disabled)
99
- return;
100
- event.preventDefault();
101
- keyboardOpen.current = true;
102
- setOpen(true);
103
- };
104
- // С клавиатуры фокус переходит в список: иначе стрелки продолжили бы двигаться по рейке
105
- (0, react_1.useEffect)(() => {
106
- if (!open || !keyboardOpen.current)
107
- return undefined;
108
- keyboardOpen.current = false;
109
- const frame = requestAnimationFrame(() => {
110
- var _a, _b;
111
- (_b = (_a = document
112
- .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();
113
- });
114
- return () => cancelAnimationFrame(frame);
115
- }, [open, menuId]);
116
88
  const label = typeof item.label === 'string' ? item.label : undefined;
117
89
  const popover = ((0, jsx_runtime_1.jsx)(popover_1.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: (0, clsx_1.default)(navigation_module_scss_1.default.flyout, size === 's' && navigation_module_scss_1.default.sizeS, size === 'l' && navigation_module_scss_1.default.sizeL, classNames.flyout), anchor: (0, jsx_runtime_1.jsx)(navigation_control_1.NavigationControl, { item: { ...item, href: undefined }, navId: id, selected: false, className: className, "aria-haspopup": "menu", "aria-expanded": open, "data-path": inPath ? '' : undefined, onKeyDown: onKeyDown, children: (0, jsx_runtime_1.jsx)(navigation_item_content_1.NavigationItemContent, { item: item, variant: variant, nested: true }) }), children: (0, jsx_runtime_1.jsxs)(CloseProvider, { value: () => setOpen(false), children: [labelHidden && (0, jsx_runtime_1.jsx)("div", { className: navigation_module_scss_1.default.flyoutTitle, children: item.label }), (0, jsx_runtime_1.jsx)(navigation_list_1.NavigationList, { orientation: "vertical", tree: true, className: (0, clsx_1.default)(navigation_module_scss_1.default.menu, classNames.list), "aria-label": label, children: (0, jsx_runtime_1.jsx)(navigation_tree_1.NavigationEntries, { entries: entries }) })] }) }));
118
90
  // Подсказка с названием, пока список закрыт: у пункта со списком нет другого способа узнать, что это
@@ -1,38 +1,5 @@
1
1
  'use client';
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
5
  };
@@ -40,47 +7,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
7
  exports.NavigationRow = NavigationRow;
41
8
  const jsx_runtime_1 = require("react/jsx-runtime");
42
9
  const clsx_1 = __importDefault(require("clsx"));
43
- const react_1 = __importStar(require("react"));
44
- const use_locale_1 = require("../locale/use-locale");
10
+ const react_1 = __importDefault(require("react"));
45
11
  const context_1 = require("./context");
46
12
  const navigation_compact_1 = require("./navigation-compact");
47
13
  const navigation_list_1 = require("./navigation-list");
48
- const use_overflow_1 = require("./use-overflow");
49
- const utils_1 = require("./utils");
14
+ const use_navigation_row_1 = require("./use-navigation-row");
50
15
  const navigation_module_scss_1 = __importDefault(require("./styles/navigation.module.css"));
51
16
  const MoreIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": true, focusable: "false", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "5", cy: "12", r: "2" }), (0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "2" }), (0, jsx_runtime_1.jsx)("circle", { cx: "19", cy: "12", r: "2" })] }));
52
17
  /** Плоский ряд пунктов (шапка или нижняя панель); не поместившиеся пункты уходят в «Ещё» */
53
18
  function NavigationRow({ entries, variant, }) {
54
- const { t } = (0, use_locale_1.useLocale)();
55
- const { value } = (0, context_1.useNavigationContext)('NavigationRow');
56
19
  const classNames = (0, context_1.useNavigationClassNames)();
57
- const listRef = (0, react_1.useRef)(null);
58
- const flat = (0, utils_1.flattenGroups)(entries).filter(utils_1.isLinkItem);
59
- // В шапке пункты `placement: 'end'` стоят у правого края; на нижней панели порядок не меняется
60
- const links = variant === 'bar'
61
- ? [...flat.filter(link => link.placement !== 'end'), ...flat.filter(link => link.placement === 'end')]
62
- : flat;
63
- // На нижней панели помещается не больше 5 разделов: остальное сразу в «Ещё»
64
- const limit = variant === 'bottom' ? 5 : Infinity;
65
- const base = links.length > limit ? links.length - (limit - 1) : 0;
66
- const hidden = (0, use_overflow_1.useOverflow)({ listRef, base, max: Math.max(links.length - 1, 0), total: links.length });
67
- const visibleLinks = hidden > 0 ? links.slice(0, links.length - hidden) : links;
68
- const hiddenLinks = hidden > 0 ? links.slice(links.length - hidden) : [];
69
- const more = {
70
- key: '__more',
71
- label: t('navigation.more'),
72
- icon: (0, jsx_runtime_1.jsx)(MoreIcon, {}),
73
- children: hiddenLinks,
74
- };
75
- const moreSelected = hiddenLinks.some(link => link.key === value || hasKey(link, value));
20
+ const { listRef, visibleLinks, hiddenLinks, more, moreSelected } = (0, use_navigation_row_1.useNavigationRow)({ entries, variant });
21
+ const moreItem = { ...more, icon: (0, jsx_runtime_1.jsx)(MoreIcon, {}) };
76
22
  return ((0, jsx_runtime_1.jsxs)(navigation_list_1.NavigationList, { orientation: "horizontal", className: (0, clsx_1.default)(navigation_module_scss_1.default.row, navigation_module_scss_1.default[`${variant}List`], classNames.list), ref: listRef, children: [visibleLinks.map((link, index) => {
77
23
  var _a;
78
24
  return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [variant === 'bar' && link.placement === 'end' && ((_a = visibleLinks[index - 1]) === null || _a === void 0 ? void 0 : _a.placement) !== 'end' && ((0, jsx_runtime_1.jsx)("li", { "aria-hidden": true, className: navigation_module_scss_1.default.spacer })), (0, jsx_runtime_1.jsx)(navigation_compact_1.NavigationCompactItem, { item: link, variant: variant })] }, link.key));
79
- }), hiddenLinks.length > 0 && ((0, jsx_runtime_1.jsx)(navigation_compact_1.NavigationCompactItem, { item: more, variant: variant, forceInPath: moreSelected }))] }));
80
- }
81
- function hasKey(item, key) {
82
- var _a;
83
- if (key === null)
84
- return false;
85
- return ((_a = item.children) !== null && _a !== void 0 ? _a : []).some(child => (0, utils_1.isLinkItem)(child) && (child.key === key || hasKey(child, key)));
25
+ }), hiddenLinks.length > 0 && ((0, jsx_runtime_1.jsx)(navigation_compact_1.NavigationCompactItem, { item: moreItem, variant: variant, forceInPath: moreSelected }))] }));
86
26
  }
@@ -1,38 +1,5 @@
1
1
  'use client';
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
5
  };
@@ -42,7 +9,7 @@ exports.NavigationPanel = NavigationPanel;
42
9
  exports.NavigationDrawer = NavigationDrawer;
43
10
  const jsx_runtime_1 = require("react/jsx-runtime");
44
11
  const clsx_1 = __importDefault(require("clsx"));
45
- const react_1 = __importStar(require("react"));
12
+ const react_1 = __importDefault(require("react"));
46
13
  const theme_context_1 = require("../theme-provider/theme-context");
47
14
  const button_1 = require("../button");
48
15
  const compat_1 = require("../_internal/compat");
@@ -56,40 +23,19 @@ const context_1 = require("./context");
56
23
  const navigation_rail_1 = require("./navigation-rail");
57
24
  const navigation_list_1 = require("./navigation-list");
58
25
  const navigation_tree_1 = require("./navigation-tree");
26
+ const use_navigation_panel_stages_1 = require("./use-navigation-panel-stages");
59
27
  const utils_1 = require("./utils");
60
28
  const navigation_module_scss_1 = __importDefault(require("./styles/navigation.module.css"));
61
29
  const BranchesClosedProvider = (0, compat_1.contextProvider)(context_1.NavigationBranchesClosedContext);
62
30
  const renderSlot = (slot, state) => typeof slot === 'function' ? slot(state) : slot;
63
31
  exports.renderSlot = renderSlot;
64
32
  const BurgerIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": true, focusable: "false", children: [(0, jsx_runtime_1.jsx)("rect", { x: "3", y: "6", width: "18", height: "2", rx: "1" }), (0, jsx_runtime_1.jsx)("rect", { x: "3", y: "11", width: "18", height: "2", rx: "1" }), (0, jsx_runtime_1.jsx)("rect", { x: "3", y: "16", width: "18", height: "2", rx: "1" })] }));
65
- // Ширина панели меняется за 200 мс (CSS), вложенные пункты ждут её окончания
66
- const WIDTH_MS = 220;
67
- /**
68
- * Смена рейки и панели в две стадии, без рывка: разворачиваем — сначала ширина, потом раскрываются ветки;
69
- * сворачиваем — ветки закрываются одновременно с сужением, и только потом рисуется рейка.
70
- * Анимации делает CSS (ширина, высота `CollapseBox`), здесь только два флага с таймером.
71
- */
72
- function useRailStages(rail) {
73
- const [railSettled, setRailSettled] = (0, react_1.useState)(rail);
74
- const [branchesOpen, setBranchesOpen] = (0, react_1.useState)(!rail);
75
- (0, react_1.useEffect)(() => {
76
- if (rail) {
77
- setBranchesOpen(false);
78
- const timer = setTimeout(() => setRailSettled(true), WIDTH_MS);
79
- return () => clearTimeout(timer);
80
- }
81
- setRailSettled(false);
82
- const timer = setTimeout(() => setBranchesOpen(true), WIDTH_MS);
83
- return () => clearTimeout(timer);
84
- }, [rail]);
85
- return { showRail: rail && railSettled, branchesClosed: !branchesOpen };
86
- }
87
33
  /** Вертикальная панель или рейка: шапка, прокручиваемый список, подвал и кнопка сворачивания */
88
34
  function NavigationPanel({ items, state, header, footer, slotState, collapsible, }) {
89
35
  const { t } = (0, use_locale_1.useLocale)();
90
36
  const classNames = (0, context_1.useNavigationClassNames)();
91
37
  const rail = state.layout === 'rail';
92
- const { showRail, branchesClosed } = useRailStages(rail);
38
+ const { showRail, branchesClosed } = (0, use_navigation_panel_stages_1.useNavigationPanelStages)(rail);
93
39
  const { start, end } = (0, utils_1.splitByPlacement)(items);
94
40
  const panelHeader = (0, exports.renderSlot)(header, slotState);
95
41
  const panelFooter = (0, exports.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 {
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useNavigationFlyout = useNavigationFlyout;
5
+ const react_1 = require("react");
6
+ const hooks_1 = require("../hooks");
7
+ const OPEN_KEY = {
8
+ bar: 'ArrowDown',
9
+ bottom: 'ArrowUp',
10
+ rail: 'ArrowRight',
11
+ };
12
+ function useNavigationFlyout(item, variant) {
13
+ var _a, _b;
14
+ const [open, setOpen] = (0, react_1.useState)(false);
15
+ const keyboardOpen = (0, react_1.useRef)(false);
16
+ const menuId = (0, hooks_1.useUniqID)(5, 'navigation-menu');
17
+ const entries = item.href
18
+ ? [{ ...item, children: undefined, key: `${item.key}__self` }, ...((_a = item.children) !== null && _a !== void 0 ? _a : [])]
19
+ : ((_b = item.children) !== null && _b !== void 0 ? _b : []);
20
+ const onKeyDown = (event) => {
21
+ if (event.key !== OPEN_KEY[variant] || item.disabled)
22
+ return;
23
+ event.preventDefault();
24
+ keyboardOpen.current = true;
25
+ setOpen(true);
26
+ };
27
+ (0, react_1.useEffect)(() => {
28
+ if (!open || !keyboardOpen.current)
29
+ return undefined;
30
+ keyboardOpen.current = false;
31
+ const frame = requestAnimationFrame(() => {
32
+ var _a, _b;
33
+ (_b = (_a = document
34
+ .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();
35
+ });
36
+ return () => cancelAnimationFrame(frame);
37
+ }, [open, menuId]);
38
+ return { open, setOpen, menuId, entries, onKeyDown };
39
+ }