@lt-ui/uikit 0.0.1 → 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 (210) hide show
  1. package/_internal/base-button/styles.module.css +1 -1
  2. package/_internal/field/_motion.css +0 -0
  3. package/_internal/field/field.module.css +21 -23
  4. package/_internal/floating/use-floating.d.ts +1 -1
  5. package/_internal/floating/use-floating.js +6 -2
  6. package/_internal/picker/picker-field.module.css +1 -1
  7. package/_internal/picker/picker-sheet.module.css +1 -1
  8. package/accordion/styles.module.css +3 -4
  9. package/alert/styles/alert.module.css +8 -8
  10. package/avatar/avatar-group.module.css +1 -1
  11. package/avatar/styles.module.css +3 -3
  12. package/badge/styles.module.css +3 -3
  13. package/breadcrumbs/styles.module.css +4 -4
  14. package/button/styles.module.css +7 -7
  15. package/calendar/styles.module.css +11 -11
  16. package/caption/styles.module.css +1 -1
  17. package/checkbox/styles/style.module.css +10 -12
  18. package/chip/styles.module.css +3 -3
  19. package/cjs/_internal/base-button/styles.module.css +1 -1
  20. package/cjs/_internal/field/_motion.css +0 -0
  21. package/cjs/_internal/field/field.module.css +21 -23
  22. package/cjs/_internal/floating/use-floating.js +6 -2
  23. package/cjs/_internal/picker/picker-field.module.css +1 -1
  24. package/cjs/_internal/picker/picker-sheet.module.css +1 -1
  25. package/cjs/accordion/styles.module.css +3 -4
  26. package/cjs/alert/styles/alert.module.css +8 -8
  27. package/cjs/avatar/avatar-group.module.css +1 -1
  28. package/cjs/avatar/styles.module.css +3 -3
  29. package/cjs/badge/styles.module.css +3 -3
  30. package/cjs/breadcrumbs/styles.module.css +4 -4
  31. package/cjs/button/styles.module.css +7 -7
  32. package/cjs/calendar/styles.module.css +11 -11
  33. package/cjs/caption/styles.module.css +1 -1
  34. package/cjs/checkbox/styles/style.module.css +10 -12
  35. package/cjs/chip/styles.module.css +3 -3
  36. package/cjs/date-picker/styles.module.css +10 -10
  37. package/cjs/drawer/styles.module.css +10 -12
  38. package/cjs/file/styles.module.css +3 -4
  39. package/cjs/hint/styles/buttons.module.css +2 -2
  40. package/cjs/hint/styles/hint-content.module.css +3 -3
  41. package/cjs/hint/styles/hint.module.css +2 -2
  42. package/cjs/image/image-viewer.js +3 -13
  43. package/cjs/image/image.js +4 -27
  44. package/cjs/image/use-image-preview.js +32 -0
  45. package/cjs/image/use-image-viewer.js +21 -0
  46. package/cjs/image/viewer.module.css +1 -1
  47. package/cjs/list/list-divider/styles.module.css +2 -2
  48. package/cjs/list/list-item/styles.module.css +2 -2
  49. package/cjs/list/list-section/styles.module.css +4 -4
  50. package/cjs/modal/modal.js +4 -10
  51. package/cjs/modal/styles/_animations.css +2 -2
  52. package/cjs/modal/styles/modal-footer.module.css +3 -3
  53. package/cjs/modal/styles/modal-header.module.css +5 -5
  54. package/cjs/modal/styles/modal.module.css +9 -4
  55. package/cjs/modal/use-modal.js +15 -1
  56. package/cjs/navigation/navigation-compact.js +2 -30
  57. package/cjs/navigation/navigation-row.js +5 -65
  58. package/cjs/navigation/navigation-views.js +3 -57
  59. package/cjs/navigation/navigation.js +2 -1
  60. package/cjs/navigation/styles/navigation.module.css +98 -81
  61. package/cjs/navigation/use-navigation-flyout.js +39 -0
  62. package/cjs/navigation/use-navigation-panel-stages.js +23 -0
  63. package/cjs/navigation/use-navigation-row.js +39 -0
  64. package/cjs/pagination/styles.module.css +2 -2
  65. package/cjs/pin-input/styles.module.css +2 -2
  66. package/cjs/progress-bar/styles.module.css +1 -1
  67. package/cjs/quantity-input/styles.module.css +3 -3
  68. package/cjs/radio/styles.module.css +4 -5
  69. package/cjs/radio-group/styles.module.css +1 -1
  70. package/cjs/segmented-control/styles/segmented-control-item.module.css +9 -9
  71. package/cjs/segmented-control/styles/segmented-control.module.css +4 -4
  72. package/cjs/select/components/select-field-multiselect-value.js +2 -2
  73. package/cjs/select/components/select-field.js +8 -6
  74. package/cjs/select/components/select-multiselect-panel.js +9 -67
  75. package/cjs/select/components/select-option-row.js +7 -53
  76. package/cjs/select/hooks/use-select-multiselect-panel-layout.js +53 -0
  77. package/cjs/select/hooks/use-select-option-row.js +23 -0
  78. package/cjs/select/hooks/use-select-view-model.js +3 -1
  79. package/cjs/select/styles/select-field.module.css +20 -1
  80. package/cjs/select/styles/select.module.css +2 -2
  81. package/cjs/select/views/select-view.js +4 -4
  82. package/cjs/select/views/styles.module.css +1 -1
  83. package/cjs/snackbar/snack-view.js +9 -42
  84. package/cjs/snackbar/styles/snack.module.css +1 -1
  85. package/cjs/snackbar/use-snack-view.js +16 -0
  86. package/cjs/switch/styles/base.module.css +2 -2
  87. package/cjs/tabs/styles/tab-list.module.css +1 -1
  88. package/cjs/tabs/styles/tab.module.css +6 -6
  89. package/cjs/tabs/tab-list.js +2 -20
  90. package/cjs/tabs/tab-panel.js +4 -39
  91. package/cjs/tabs/use-tab-list-navigation.js +27 -0
  92. package/cjs/tabs/use-tab-panel.js +12 -0
  93. package/cjs/textarea/styles.module.css +1 -1
  94. package/cjs/theme-provider/styles.module.css +6 -6
  95. package/cjs/time-picker/styles.module.css +9 -9
  96. package/cjs/time-picker/time-panel.js +2 -47
  97. package/cjs/time-picker/use-time-column-list.js +48 -0
  98. package/cjs/tooltip/tooltip.js +1 -1
  99. package/cjs/tree/styles.module.css +5 -5
  100. package/cjs/tree/tree-row.js +13 -73
  101. package/cjs/tree/tree-select.module.css +2 -2
  102. package/cjs/tree/use-tree-row.js +102 -0
  103. package/cjs/utils/class-names.js +3 -1
  104. package/date-picker/styles.module.css +10 -10
  105. package/drawer/styles.module.css +10 -12
  106. package/file/styles.module.css +3 -4
  107. package/hint/styles/buttons.module.css +2 -2
  108. package/hint/styles/hint-content.module.css +3 -3
  109. package/hint/styles/hint.module.css +2 -2
  110. package/image/image-viewer.js +3 -13
  111. package/image/image.js +5 -28
  112. package/image/use-image-preview.d.ts +10 -0
  113. package/image/use-image-preview.js +29 -0
  114. package/image/use-image-viewer.d.ts +8 -0
  115. package/image/use-image-viewer.js +18 -0
  116. package/image/viewer.module.css +1 -1
  117. package/input/fields/use-text-field.d.ts +2 -0
  118. package/list/list-divider/styles.module.css +2 -2
  119. package/list/list-item/styles.module.css +2 -2
  120. package/list/list-section/styles.module.css +4 -4
  121. package/masked-input/use-mask.d.ts +2 -0
  122. package/modal/modal.d.ts +1 -0
  123. package/modal/modal.js +4 -10
  124. package/modal/styles/_animations.css +2 -2
  125. package/modal/styles/modal-footer.module.css +3 -3
  126. package/modal/styles/modal-header.module.css +5 -5
  127. package/modal/styles/modal.module.css +9 -4
  128. package/modal/types.d.ts +5 -0
  129. package/modal/use-modal.d.ts +3 -1
  130. package/modal/use-modal.js +17 -3
  131. package/navigation/navigation-compact.d.ts +1 -2
  132. package/navigation/navigation-compact.js +3 -31
  133. package/navigation/navigation-row.d.ts +1 -2
  134. package/navigation/navigation-row.js +6 -33
  135. package/navigation/navigation-views.js +3 -24
  136. package/navigation/navigation.d.ts +1 -0
  137. package/navigation/navigation.js +2 -1
  138. package/navigation/styles/navigation.module.css +98 -81
  139. package/navigation/types.d.ts +3 -2
  140. package/navigation/use-navigation-flyout.d.ts +9 -0
  141. package/navigation/use-navigation-flyout.js +36 -0
  142. package/navigation/use-navigation-panel-stages.d.ts +5 -0
  143. package/navigation/use-navigation-panel-stages.js +20 -0
  144. package/navigation/use-navigation-row.d.ts +16 -0
  145. package/navigation/use-navigation-row.js +36 -0
  146. package/number-input/use-number-input.d.ts +2 -0
  147. package/package.json +6 -2
  148. package/pagination/styles.module.css +2 -2
  149. package/pin-input/styles.module.css +2 -2
  150. package/popover/types.d.ts +2 -2
  151. package/progress-bar/styles.module.css +1 -1
  152. package/quantity-input/styles.module.css +3 -3
  153. package/radio/styles.module.css +4 -5
  154. package/radio-group/styles.module.css +1 -1
  155. package/scss/_functions.scss +12 -24
  156. package/scss/_grid.scss +2 -2
  157. package/scss/_index.scss +1 -6
  158. package/scss/_interaction.scss +3 -3
  159. package/scss/_mixins.scss +5 -51
  160. package/scss/_tokens.generated.scss +578 -0
  161. package/scss/_tokens.scss +2 -396
  162. package/scss/_typography.scss +0 -1
  163. package/segmented-control/styles/segmented-control-item.module.css +9 -9
  164. package/segmented-control/styles/segmented-control.module.css +4 -4
  165. package/select/components/select-field-multiselect-value.d.ts +1 -0
  166. package/select/components/select-field-multiselect-value.js +2 -2
  167. package/select/components/select-field.d.ts +3 -1
  168. package/select/components/select-field.js +8 -6
  169. package/select/components/select-multiselect-panel.d.ts +3 -1
  170. package/select/components/select-multiselect-panel.js +8 -66
  171. package/select/components/select-option-row.js +7 -20
  172. package/select/hooks/use-select-multiselect-panel-layout.d.ts +14 -0
  173. package/select/hooks/use-select-multiselect-panel-layout.js +49 -0
  174. package/select/hooks/use-select-option-row.d.ts +13 -0
  175. package/select/hooks/use-select-option-row.js +20 -0
  176. package/select/hooks/use-select-view-model.d.ts +4 -2
  177. package/select/hooks/use-select-view-model.js +3 -1
  178. package/select/select.d.ts +3 -2
  179. package/select/styles/select-field.module.css +20 -1
  180. package/select/styles/select.module.css +2 -2
  181. package/select/types.d.ts +6 -3
  182. package/select/views/select-view.js +4 -4
  183. package/select/views/styles.module.css +1 -1
  184. package/snackbar/snack-view.js +7 -7
  185. package/snackbar/styles/snack.module.css +1 -1
  186. package/snackbar/use-snack-view.d.ts +8 -0
  187. package/snackbar/use-snack-view.js +13 -0
  188. package/switch/styles/base.module.css +2 -2
  189. package/tabs/styles/tab-list.module.css +1 -1
  190. package/tabs/styles/tab.module.css +6 -6
  191. package/tabs/tab-list.js +4 -22
  192. package/tabs/tab-panel.js +4 -6
  193. package/tabs/use-tab-list-navigation.d.ts +2 -0
  194. package/tabs/use-tab-list-navigation.js +24 -0
  195. package/tabs/use-tab-panel.d.ts +6 -0
  196. package/tabs/use-tab-panel.js +9 -0
  197. package/textarea/styles.module.css +1 -1
  198. package/theme-provider/styles.module.css +6 -6
  199. package/time-picker/styles.module.css +9 -9
  200. package/time-picker/time-panel.js +2 -47
  201. package/time-picker/use-time-column-list.d.ts +7 -0
  202. package/time-picker/use-time-column-list.js +45 -0
  203. package/tooltip/tooltip.js +1 -1
  204. package/tree/styles.module.css +5 -5
  205. package/tree/tree-row.js +15 -75
  206. package/tree/tree-select.module.css +2 -2
  207. package/tree/use-tree-row.d.ts +331 -0
  208. package/tree/use-tree-row.js +99 -0
  209. package/utils/class-names.d.ts +1 -1
  210. package/utils/class-names.js +3 -1
package/image/image.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from 'clsx';
4
- import { useMemo, useState } from 'react';
4
+ import { useMemo } from 'react';
5
5
  import { withRef } from '../_internal/compat';
6
6
  import { useLocale } from '../locale/use-locale';
7
7
  import { mergeRefs, useClassNames } from '../utils';
@@ -9,6 +9,7 @@ import { getDataAttributes, getRelatedTestId, splitDataAttributes } from '../uti
9
9
  import { ImageViewer } from './image-viewer';
10
10
  import style from './style.module.css';
11
11
  import { useImage } from './use-image';
12
+ import { useImagePreview } from './use-image-preview';
12
13
  /**
13
14
  * `<Image />` — изображение с состояниями загрузки и ошибки, скруглением и необязательным просмотром на весь экран.
14
15
  * Принимает все атрибуты `<img>` (`srcSet`, `sizes`, `loading="lazy"`...).
@@ -18,7 +19,7 @@ import { useImage } from './use-image';
18
19
  * ```
19
20
  */
20
21
  export const Image = 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) {
21
- var _a, _b;
22
+ var _a, _b, _c;
22
23
  const { t } = useLocale();
23
24
  const classNames = useClassNames('Image', classNamesProp);
24
25
  const vm = useImage({
@@ -29,31 +30,7 @@ export const Image = withRef(function Image({ src, alt, rounding, width, height,
29
30
  previewOpen: previewOpenProp,
30
31
  onPreviewOpenChange,
31
32
  });
32
- const [resolved, setResolved] = useState();
33
- const [resolving, setResolving] = useState(false);
34
- const openPreview = async () => {
35
- vm.openPreview();
36
- if (!loadPreview || resolved)
37
- return;
38
- // Окно открывается сразу с индикатором, большая версия подставляется, когда загружена
39
- setResolving(true);
40
- try {
41
- const url = await loadPreview();
42
- await new Promise(resolve => {
43
- const probe = new globalThis.Image();
44
- probe.onload = () => resolve();
45
- probe.onerror = () => resolve();
46
- probe.src = url;
47
- });
48
- setResolved(url);
49
- }
50
- catch {
51
- // не получилось: останется то, что есть
52
- }
53
- finally {
54
- setResolving(false);
55
- }
56
- };
33
+ const previewState = useImagePreview({ loadPreview, openPreview: vm.openPreview });
57
34
  const imgRef = useMemo(() => mergeRefs([vm.setImg, ref]), [vm.setImg, ref]);
58
35
  const image = (_jsx("img", { ...splitDataAttributes(imgProps).nativeProps, ref: imgRef, className: clsx(style.img, classNames.img), style: { objectFit }, src: src, srcSet: srcSet, sizes: sizes, alt: alt, onLoad: vm.onLoad, onError: vm.onError }));
59
36
  const content = (_jsxs(_Fragment, { children: [image, vm.status === 'loading' && placeholder && (_jsx("span", { className: clsx(style.overlay, classNames.overlay), children: placeholder })), vm.status === 'error' && fallback && (_jsx("span", { className: clsx(style.overlay, classNames.overlay), children: fallback }))] }));
@@ -63,5 +40,5 @@ export const Image = withRef(function Image({ src, alt, rounding, width, height,
63
40
  ...getDataAttributes(imgProps, 'image-wrapper'),
64
41
  'data-status': vm.status,
65
42
  };
66
- return (_jsxs(_Fragment, { children: [vm.interactive ? (_jsx("button", { ...wrapperProps, type: "button", className: clsx(wrapperProps.className, style.interactive), "aria-label": `${previewLabel !== null && previewLabel !== void 0 ? previewLabel : t('image.preview')}: ${alt}`, "aria-haspopup": "dialog", onClick: openPreview, children: content })) : (_jsx("div", { ...wrapperProps, children: content })), vm.previewOpen && src && (_jsx(ImageViewer, { testId: 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 }))] }));
43
+ return (_jsxs(_Fragment, { children: [vm.interactive ? (_jsx("button", { ...wrapperProps, type: "button", className: clsx(wrapperProps.className, style.interactive), "aria-label": `${previewLabel !== null && previewLabel !== void 0 ? previewLabel : t('image.preview')}: ${alt}`, "aria-haspopup": "dialog", onClick: previewState.openPreview, children: content })) : (_jsx("div", { ...wrapperProps, children: content })), vm.previewOpen && src && (_jsx(ImageViewer, { testId: 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 }))] }));
67
44
  });
@@ -0,0 +1,10 @@
1
+ type Params = {
2
+ loadPreview?: () => Promise<string>;
3
+ openPreview: () => void;
4
+ };
5
+ export declare function useImagePreview({ loadPreview, openPreview }: Params): {
6
+ resolved: string | undefined;
7
+ resolving: boolean;
8
+ openPreview: () => Promise<void>;
9
+ };
10
+ export {};
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+ import { useCallback, useState } from 'react';
3
+ export function useImagePreview({ loadPreview, openPreview }) {
4
+ const [resolved, setResolved] = useState();
5
+ const [resolving, setResolving] = useState(false);
6
+ const open = useCallback(async () => {
7
+ openPreview();
8
+ if (!loadPreview || resolved)
9
+ return;
10
+ setResolving(true);
11
+ try {
12
+ const url = await loadPreview();
13
+ await new Promise(resolve => {
14
+ const probe = new globalThis.Image();
15
+ probe.onload = () => resolve();
16
+ probe.onerror = () => resolve();
17
+ probe.src = url;
18
+ });
19
+ setResolved(url);
20
+ }
21
+ catch {
22
+ // Если большая версия недоступна, остаётся исходное изображение.
23
+ }
24
+ finally {
25
+ setResolving(false);
26
+ }
27
+ }, [loadPreview, openPreview, resolved]);
28
+ return { resolved, resolving, openPreview: open };
29
+ }
@@ -0,0 +1,8 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ export declare function useImageViewer(onClose: () => void): {
3
+ imageRef: import("react").RefObject<HTMLImageElement | null>;
4
+ closeRef: import("react").RefObject<HTMLDivElement | null>;
5
+ zoomed: boolean;
6
+ toggleZoom: () => void;
7
+ onImageKeyDown: (event: KeyboardEvent<HTMLImageElement>) => void;
8
+ };
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+ import { useMemo, useRef, useState } from 'react';
3
+ import { useLayer } from '../_internal/layer';
4
+ export function useImageViewer(onClose) {
5
+ const imageRef = useRef(null);
6
+ const closeRef = useRef(null);
7
+ const [zoomed, setZoomed] = useState(false);
8
+ const contentRefs = useMemo(() => [imageRef, closeRef], []);
9
+ useLayer({ open: true, type: 'image-viewer', contentRefs, onClose });
10
+ const toggleZoom = () => setZoomed(value => !value);
11
+ const onImageKeyDown = (event) => {
12
+ if (event.key !== 'Enter' && event.key !== ' ')
13
+ return;
14
+ event.preventDefault();
15
+ toggleZoom();
16
+ };
17
+ return { imageRef, closeRef, zoomed, toggleZoom, onImageKeyDown };
18
+ }
@@ -15,7 +15,7 @@
15
15
  right: 16px;
16
16
  z-index: 1;
17
17
  display: flex;
18
- gap: 8px;
18
+ gap: var(--space-8);
19
19
  }
20
20
 
21
21
  .close .tool {
@@ -361,6 +361,7 @@ export declare function useTextField(props: InputProps, ref: Ref<HTMLInputElemen
361
361
  placeholder?: string | undefined | undefined;
362
362
  readOnly?: boolean | undefined | undefined;
363
363
  required?: boolean | undefined | undefined;
364
+ webkitdirectory?: boolean | string | undefined | undefined;
364
365
  type?: "text" | "search" | "password" | "email" | "tel" | "url";
365
366
  } | {
366
367
  id: string;
@@ -671,6 +672,7 @@ export declare function useTextField(props: InputProps, ref: Ref<HTMLInputElemen
671
672
  placeholder?: string | undefined | undefined;
672
673
  readOnly?: boolean | undefined | undefined;
673
674
  required?: boolean | undefined | undefined;
675
+ webkitdirectory?: boolean | string | undefined | undefined;
674
676
  type?: "text" | "search" | "password" | "email" | "tel" | "url";
675
677
  };
676
678
  };
@@ -1,7 +1,7 @@
1
1
  .m {
2
- margin: 4px 0 3px;
2
+ margin: var(--space-4) 0 3px;
3
3
  }
4
4
 
5
5
  .l {
6
- margin: 8px 0 7px;
6
+ margin: var(--space-8) 0 7px;
7
7
  }
@@ -69,7 +69,7 @@
69
69
  }
70
70
  .listItemClickableContent[data-description-position=top] .description {
71
71
  margin-top: 0;
72
- margin-bottom: 2px;
72
+ margin-bottom: var(--space-2);
73
73
  }
74
74
 
75
75
  .listItemClickableContent[data-alignment=center] {
@@ -129,7 +129,7 @@
129
129
  .description {
130
130
  z-index: 0;
131
131
  grid-area: description;
132
- margin-top: 2px;
132
+ margin-top: var(--space-2);
133
133
  color: var(--lt-ui-list-item-description-color, var(--text-minor));
134
134
  }
135
135
  .description:empty {
@@ -13,15 +13,15 @@
13
13
  }
14
14
 
15
15
  .l.accent {
16
- padding: 13px 16px;
16
+ padding: 13px var(--space-16);
17
17
  }
18
18
  .l.minor {
19
- padding: 8px 16px;
19
+ padding: var(--space-8) var(--space-16);
20
20
  }
21
21
 
22
22
  .m.accent {
23
- padding: 11px 12px;
23
+ padding: 11px var(--space-12);
24
24
  }
25
25
  .m.minor {
26
- padding: 6px 12px;
26
+ padding: 6px var(--space-12);
27
27
  }
@@ -319,6 +319,7 @@ export declare const useMask: (props: MaskedInputProps, inputRef: React.RefObjec
319
319
  placeholder?: string | undefined | undefined;
320
320
  readOnly?: boolean | undefined | undefined;
321
321
  required?: boolean | undefined | undefined;
322
+ webkitdirectory?: boolean | string | undefined | undefined;
322
323
  type?: "text" | "search" | "password" | "email" | "tel" | "url";
323
324
  defaultValue?: string;
324
325
  classNames?: import("..").ComponentClassNames<"Input">;
@@ -642,6 +643,7 @@ export declare const useMask: (props: MaskedInputProps, inputRef: React.RefObjec
642
643
  placeholder?: string | undefined | undefined;
643
644
  readOnly?: boolean | undefined | undefined;
644
645
  required?: boolean | undefined | undefined;
646
+ webkitdirectory?: boolean | string | undefined | undefined;
645
647
  type?: "text" | "search" | "password" | "email" | "tel" | "url";
646
648
  defaultValue?: string;
647
649
  classNames?: import("..").ComponentClassNames<"Input">;
package/modal/modal.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare const Modal: import("react").ForwardRefExoticComponent<import("..
13
13
  theme?: import("..").ThemeSetting;
14
14
  modalID?: string;
15
15
  show: boolean;
16
+ animated?: boolean;
16
17
  size?: import("./types").ModalSize;
17
18
  variant?: import("./types").ModalVariant;
18
19
  toTop?: boolean;
package/modal/modal.js CHANGED
@@ -28,22 +28,16 @@ export { getTimerCurtain } from './utils';
28
28
  </Modal>;
29
29
  * ```
30
30
  */
31
- export const Modal = 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) {
31
+ export const Modal = 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) {
32
32
  const classNames = useClassNames('Modal', classNamesProp);
33
- const { modalRef, overlayRef, nodeRef, timeout, style, scroll, changeContentOnScroll } = useModal({
34
- show,
35
- onClose,
36
- overlayClose,
37
- variant,
38
- children,
39
- });
33
+ const { modalRef, overlayRef, nodeRef, timeout, style, scroll, changeContentOnScroll, renderedChildren, onExited, } = useModal({ show, onClose, overlayClose, variant, children });
40
34
  const themeAttribute = useThemeAttribute(theme, { portal: true });
41
35
  const overLayClass = clsx(styles.overlay, styles[variant], classNames.overlay);
42
36
  const modalClass = clsx(styles.modal, styles[variant], styles[size], sticky && styles.sticky, classNames.root, className);
43
37
  const wrapperClass = clsx(styles.wrapper, styles[size], styles[variant], toTop && styles.toTop, classNames.wrapper);
44
38
  const scrollContext = useMemo(() => ({ changeContentOnScroll, scrollTop: scroll.top, scrollBottom: scroll.bottom }), [changeContentOnScroll, scroll.top, scroll.bottom]);
45
39
  const modalContext = useMemo(() => ({ variant, sticky, size, classNames }), [variant, sticky, size, classNames]);
46
- return (_jsx(Portal, { container: container, children: _jsx(CSSTransition, { nodeRef: nodeRef, timeout: timeout, in: show,
40
+ return (_jsx(Portal, { container: container, children: _jsx(CSSTransition, { nodeRef: nodeRef, timeout: animated ? timeout : 0, in: show, enter: animated, exit: animated, onExited: onExited,
47
41
  // Окно, смонтированное уже открытым (`{open && <Modal show />}`), тоже должно появляться с анимацией
48
42
  appear: true, classNames: {
49
43
  appear: styles.modalTransitionEnter,
@@ -52,5 +46,5 @@ export const Modal = withRef(function Modal({ children, modalID, className = '',
52
46
  enterActive: styles.modalTransitionEnterActive,
53
47
  exit: styles.modalTransitionExit,
54
48
  exitActive: styles.modalTransitionExitActive,
55
- }, unmountOnExit: true, children: _jsxs("div", { className: styles.animationWrapper, ref: nodeRef, children: [_jsx(RestoreFocus, {}), _jsx(FocusTrap, { children: _jsx("div", { ref: overlayRef, className: overLayClass, style: style, "data-lt-ui-theme": themeAttribute, ...getDataAttributes(dataProps, 'modal'), "data-lt-ui": "modal", children: _jsx("div", { className: wrapperClass, ref: ref, children: _jsxs("div", { className: modalClass, role: "dialog", "aria-modal": "true", "aria-labelledby": modalID && `${modalID}_label`, "aria-describedby": modalID && `${modalID}_desc`, ref: modalRef, children: [closeButton && _jsx(ModalCloseButton, { onClose: onClose, className: classNames.close }), _jsx(ScrollProvider, { value: scrollContext, children: _jsx(ModalProvider, { value: modalContext, children: _jsx(FocusOnProvider, { value: true, children: _jsx("div", { className: styles.contentWrapper, children: children }) }) }) })] }) }) }) })] }) }) }));
49
+ }, unmountOnExit: true, children: _jsxs("div", { className: clsx(styles.animationWrapper, !animated && styles.motionDisabled), ref: nodeRef, children: [_jsx(RestoreFocus, {}), _jsx(FocusTrap, { children: _jsx("div", { ref: overlayRef, className: overLayClass, style: style, "data-lt-ui-theme": themeAttribute, ...getDataAttributes(dataProps, 'modal'), "data-lt-ui": "modal", children: _jsx("div", { className: wrapperClass, ref: ref, children: _jsxs("div", { className: modalClass, role: "dialog", "aria-modal": "true", "aria-labelledby": modalID && `${modalID}_label`, "aria-describedby": modalID && `${modalID}_desc`, ref: modalRef, children: [closeButton && _jsx(ModalCloseButton, { onClose: onClose, className: classNames.close }), _jsx(ScrollProvider, { value: scrollContext, children: _jsx(ModalProvider, { value: modalContext, children: _jsx(FocusOnProvider, { value: true, children: _jsx("div", { className: styles.contentWrapper, children: renderedChildren }) }) }) })] }) }) }) })] }) }) }));
56
50
  });
@@ -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) {
@@ -1,9 +1,9 @@
1
1
  .modalFooter {
2
2
  z-index: 1;
3
3
  display: flex;
4
- gap: 16px;
4
+ gap: var(--space-16);
5
5
  justify-content: space-between;
6
- padding: 32px 40px 40px;
6
+ padding: var(--space-32) var(--space-40) var(--space-40);
7
7
  margin-top: auto;
8
8
  color: var(--text-primary);
9
9
  }
@@ -18,7 +18,7 @@
18
18
  @media (max-width: 767.98px) {
19
19
  .modalFooter.column {
20
20
  flex-direction: column-reverse;
21
- row-gap: 16px;
21
+ row-gap: var(--space-16);
22
22
  align-items: stretch;
23
23
  }
24
24
  }
@@ -1,5 +1,5 @@
1
1
  .modalHeader {
2
- padding: 40px 80px 16px 40px;
2
+ padding: 40px 80px var(--space-16) 40px;
3
3
  color: var(--text-primary);
4
4
  }
5
5
  .modalHeader.onScroll {
@@ -8,18 +8,18 @@
8
8
  will-change: box-shadow;
9
9
  }
10
10
  .modalHeader.emptyHeader {
11
- padding-top: 64px;
11
+ padding-top: var(--space-64);
12
12
  }
13
13
  @media (max-width: 479.98px) {
14
14
  .modalHeader {
15
- padding: 8px 48px;
15
+ padding: var(--space-8) var(--space-48);
16
16
  text-align: center;
17
17
  }
18
18
  .modalHeader.emptyHeader {
19
- padding-top: 40px;
19
+ padding-top: var(--space-40);
20
20
  }
21
21
  .modalHeader .title {
22
- padding: 8px;
22
+ padding: var(--space-8);
23
23
  text-align: center;
24
24
  }
25
25
  .modalHeader.curtain {
@@ -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) {
@@ -170,7 +170,7 @@
170
170
  min-height: unset;
171
171
  }
172
172
  .wrapper:not(.full-screen) {
173
- padding: 0 16px;
173
+ padding: 0 var(--space-16);
174
174
  }
175
175
  .wrapper:not(.full-screen).toTop {
176
176
  flex-flow: wrap;
@@ -216,7 +216,7 @@
216
216
  transform: translate(0, 0);
217
217
  }
218
218
  .modal:not(.full-screen).sticky {
219
- max-height: calc(100vh - 80px * 2);
219
+ max-height: calc(100vh - 160px);
220
220
  }
221
221
  @media (max-width: 319.98px) {
222
222
  .modal:not(.full-screen) {
@@ -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
  }