@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/tabs/tab-list.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { useContext, useEffect } from 'react';
3
+ import React, { useContext } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { useThemeAttribute } from '../theme-provider/theme-context';
6
- import { ListNavigationContext, useListNavigation } from '../hooks';
6
+ import { ListNavigationContext } from '../hooks';
7
7
  import { TabsContext } from './context';
8
8
  import { useTabs } from './use-tabs';
9
+ import { useTabListNavigation } from './use-tab-list-navigation';
9
10
  import styles from './styles/tab-list.module.css';
10
11
  import { contextProvider, withRef } from '../_internal/compat';
11
12
  const ListNavigationProvider = contextProvider(ListNavigationContext);
@@ -26,27 +27,8 @@ const StandaloneList = withRef(function StandaloneList(props, ref) {
26
27
  return (_jsx(TabsProvider, { value: context, children: _jsx(TabListView, { ...rest, context: context, ref: ref }) }));
27
28
  });
28
29
  const TabListView = withRef(function TabListView({ context, align = 'start', className, children, theme, ...rest }, ref) {
29
- const { value, activation, select, getTabId, valueById } = context;
30
30
  const themeAttribute = useThemeAttribute(theme);
31
- const navigation = useListNavigation({
32
- mode: 'focus',
33
- tabStop: 'single',
34
- orientation: 'horizontal',
35
- defaultActiveId: value === undefined ? undefined : getTabId(value),
36
- onActiveChange: (id, reason) => {
37
- if (activation !== 'auto' || reason !== 'keyboard' || id === null)
38
- return;
39
- const next = valueById.get(id);
40
- if (next !== undefined && next !== value)
41
- select(next);
42
- },
43
- });
44
- // Выбранная снаружи вкладка становится точкой входа в список
45
- const { api } = navigation;
46
- useEffect(() => {
47
- if (value !== undefined)
48
- api.setActive(getTabId(value), 'api');
49
- }, [value, api, getTabId]);
31
+ const navigation = useTabListNavigation(context);
50
32
  return (_jsx("div", { role: "tablist", "aria-orientation": "horizontal", ...rest, ...navigation.rootProps, ref: ref, className: clsx(styles.tabList, styles[align], styles[context.variant], context.divider && context.variant === 'line' && styles.divider, context.classNames.list, className), "data-lt-ui-theme": themeAttribute, "data-lt-ui": "tab-list", children: _jsx(ListNavigationProvider, { value: navigation.context, children: children }) }));
51
33
  });
52
34
  /**
package/tabs/tab-panel.js CHANGED
@@ -1,16 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import React, { useEffect } from 'react';
3
+ import React from 'react';
4
4
  import clsx from 'clsx';
5
- import { useTabsContext } from './context';
6
5
  import styles from './styles/tab-panel.module.css';
7
6
  import { withRef } from '../_internal/compat';
7
+ import { useTabPanel } from './use-tab-panel';
8
8
  /**
9
9
  * `<TabPanel />` — содержимое вкладки. Скрыта, пока вкладка не выбрана; размонтируется, если не задан `keepMounted`.
10
10
  */
11
11
  export const TabPanel = withRef(function TabPanel({ value, keepMounted = false, className, children, ...rest }, ref) {
12
- const { value: selectedValue, getTabId, getPanelId, registerPanel, classNames, } = useTabsContext('TabPanel');
13
- const selected = selectedValue === value;
14
- useEffect(() => registerPanel(value), [registerPanel, value]);
15
- return (_jsx("div", { role: "tabpanel", tabIndex: selected ? 0 : -1, ...rest, ref: ref, id: getPanelId(value), "aria-labelledby": getTabId(value), hidden: !selected, className: clsx(styles.panel, classNames.panel, className), "data-lt-ui": "tab-panel", children: selected || keepMounted ? children : null }));
12
+ const { selected, tabId, panelId, classNames } = useTabPanel(value);
13
+ return (_jsx("div", { role: "tabpanel", tabIndex: selected ? 0 : -1, ...rest, ref: ref, id: panelId, "aria-labelledby": tabId, hidden: !selected, className: clsx(styles.panel, classNames.panel, className), "data-lt-ui": "tab-panel", children: selected || keepMounted ? children : null }));
16
14
  });
@@ -0,0 +1,2 @@
1
+ import type { TabsContextValue } from './context';
2
+ export declare function useTabListNavigation(context: TabsContextValue): import("..").ListNavigation;
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+ import { useListNavigation } from '../hooks';
4
+ export function useTabListNavigation(context) {
5
+ const { value, activation, select, getTabId, valueById } = context;
6
+ const navigation = useListNavigation({
7
+ mode: 'focus',
8
+ tabStop: 'single',
9
+ orientation: 'horizontal',
10
+ defaultActiveId: value === undefined ? undefined : getTabId(value),
11
+ onActiveChange: (id, reason) => {
12
+ if (activation !== 'auto' || reason !== 'keyboard' || id === null)
13
+ return;
14
+ const next = valueById.get(id);
15
+ if (next !== undefined && next !== value)
16
+ select(next);
17
+ },
18
+ });
19
+ useEffect(() => {
20
+ if (value !== undefined)
21
+ navigation.api.setActive(getTabId(value), 'api');
22
+ }, [value, navigation.api, getTabId]);
23
+ return navigation;
24
+ }
@@ -0,0 +1,6 @@
1
+ export declare function useTabPanel(value: string | number): {
2
+ selected: boolean;
3
+ tabId: string;
4
+ panelId: string;
5
+ classNames: Partial<Record<"icon" | "tab" | "list" | "panel" | "badge", string>>;
6
+ };
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+ import { useTabsContext } from './context';
4
+ export function useTabPanel(value) {
5
+ const { value: selectedValue, getTabId, getPanelId, registerPanel, classNames, } = useTabsContext('TabPanel');
6
+ const selected = selectedValue === value;
7
+ useEffect(() => registerPanel(value), [registerPanel, value]);
8
+ return { selected, tabId: getTabId(value), panelId: getPanelId(value), classNames };
9
+ }
@@ -19,7 +19,7 @@
19
19
  width: 20px;
20
20
  height: 20px;
21
21
  padding: 3px;
22
- margin: 0 2px 2px 0;
22
+ margin: 0 var(--space-2) var(--space-2) 0;
23
23
  color: var(--control-secondary);
24
24
  touch-action: none;
25
25
  }
@@ -68,6 +68,12 @@
68
68
  --palette-red-light: #FFD7D4;
69
69
  --palette-black: #000000;
70
70
  --palette-white: #FFFFFF;
71
+ --box-shadow-s: 0 1px 4px rgba(0, 0, 0, 0.16), 0 2px 9px rgba(0, 0, 0, 0.02);
72
+ --box-shadow-m: 0 1.17px 2px rgba(0, 0, 0, 0.0196802), 0 1.4px 5px rgba(0, 0, 0, 0.03), 0 2px 10px rgba(0, 0, 0, 0.03), 0 2px 18px rgba(0, 0, 0, 0.04), 0 9px 33px rgba(0, 0, 0, 0.03);
73
+ --box-shadow-l: 0 0.166035px 2.21381px rgba(0, 0, 0, 0.0196802), 0 0.399006px 5.32008px rgba(0, 0, 0, 0.0282725), 0 0.751293px 10.0172px rgba(0, 0, 0, 0.035), 0 12px 40px rgba(0, 0, 0, 0.08);
74
+ --box-shadow-s-up: 0 -1px 4px rgba(0, 0, 0, 0.16), 0 -2px 9px rgba(0, 0, 0, 0.02);
75
+ --box-shadow-m-up: 0 -1.17px 2px rgba(0, 0, 0, 0.0196802), 0 -1.4px 5px rgba(0, 0, 0, 0.03), 0 -2px 10px rgba(0, 0, 0, 0.03), 0 -2px 18px rgba(0, 0, 0, 0.04), 0 -9px 33px rgba(0, 0, 0, 0.03);
76
+ --box-shadow-l-up: 0 -0.166035px 2.21381px rgba(0, 0, 0, 0.0196802), 0 -0.399006px 5.32008px rgba(0, 0, 0, 0.0282725), 0 -0.751293px 10.0172px rgba(0, 0, 0, 0.035), 0 -12px 40px rgba(0, 0, 0, 0.08);
71
77
  --space-2: 2px;
72
78
  --space-4: 4px;
73
79
  --space-8: 8px;
@@ -85,12 +91,6 @@
85
91
  --rounding-l: 8px;
86
92
  --rounding-xl: 16px;
87
93
  --rounding-circular: 100vmin;
88
- --box-shadow-s: 0 1px 4px rgba(0, 0, 0, 0.16), 0 2px 9px rgba(0, 0, 0, 0.02);
89
- --box-shadow-m: 0 1.17px 2px rgba(0, 0, 0, 0.0196802), 0 1.4px 5px rgba(0, 0, 0, 0.03), 0 2px 10px rgba(0, 0, 0, 0.03), 0 2px 18px rgba(0, 0, 0, 0.04), 0 9px 33px rgba(0, 0, 0, 0.03);
90
- --box-shadow-l: 0 0.166035px 2.21381px rgba(0, 0, 0, 0.0196802), 0 0.399006px 5.32008px rgba(0, 0, 0, 0.0282725), 0 0.751293px 10.0172px rgba(0, 0, 0, 0.035), 0 12px 40px rgba(0, 0, 0, 0.08);
91
- --box-shadow-s-up: 0 -1px 4px rgba(0, 0, 0, 0.16), 0 -2px 9px rgba(0, 0, 0, 0.02);
92
- --box-shadow-m-up: 0 -1.17px 2px rgba(0, 0, 0, 0.0196802), 0 -1.4px 5px rgba(0, 0, 0, 0.03), 0 -2px 10px rgba(0, 0, 0, 0.03), 0 -2px 18px rgba(0, 0, 0, 0.04), 0 -9px 33px rgba(0, 0, 0, 0.03);
93
- --box-shadow-l-up: 0 -0.166035px 2.21381px rgba(0, 0, 0, 0.0196802), 0 -0.399006px 5.32008px rgba(0, 0, 0, 0.0282725), 0 -0.751293px 10.0172px rgba(0, 0, 0, 0.035), 0 -12px 40px rgba(0, 0, 0, 0.08);
94
94
  --opacity-40: 0.4;
95
95
  --opacity-60: 0.6;
96
96
  --opacity-80: 0.8;
@@ -2,8 +2,8 @@
2
2
  --time-option-h: 36px;
3
3
  --time-column-w: 56px;
4
4
  display: inline-flex;
5
- gap: 4px;
6
- padding: 8px;
5
+ gap: var(--space-4);
6
+ padding: var(--space-8);
7
7
  }
8
8
 
9
9
  .s {
@@ -15,9 +15,9 @@
15
15
  position: relative;
16
16
  display: flex;
17
17
  flex-direction: column;
18
- gap: 2px;
18
+ gap: var(--space-2);
19
19
  width: var(--time-column-w);
20
- height: calc(var(--time-option-h) * 6 + 10px);
20
+ height: calc(var(--time-option-h) * 6 + var(--space-2) * 5);
21
21
  padding: 0;
22
22
  overflow-y: auto;
23
23
  overscroll-behavior: contain;
@@ -92,15 +92,15 @@
92
92
 
93
93
  .rangePanels {
94
94
  display: flex;
95
- gap: 4px;
96
- padding: 4px;
95
+ gap: var(--space-4);
96
+ padding: var(--space-4);
97
97
  }
98
98
 
99
99
  .rangePanels > hr.rangeDivider {
100
100
  --vertical-length: auto;
101
101
  align-self: stretch;
102
102
  height: auto;
103
- margin: 8px 0;
103
+ margin: var(--space-8) 0;
104
104
  }
105
105
 
106
106
  .rangeColumn {
@@ -113,12 +113,12 @@
113
113
  font-weight: 600;
114
114
  line-height: 1.2;
115
115
  letter-spacing: 0.2px;
116
- padding: 8px 8px 0;
116
+ padding: var(--space-8) var(--space-8) 0;
117
117
  color: var(--text-primary);
118
118
  }
119
119
 
120
120
  .sheetPanel {
121
121
  display: flex;
122
122
  justify-content: center;
123
- padding: 0 16px 8px;
123
+ padding: 0 var(--space-16) var(--space-8);
124
124
  }
@@ -1,61 +1,16 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import clsx from 'clsx';
4
- import { useEffect, useRef } from 'react';
5
4
  import { withRef } from '../_internal/compat';
6
5
  import { useUniqID } from '../hooks';
7
6
  import { useLocale } from '../locale/use-locale';
8
7
  import { getDataAttributes } from '../utils/data-attributes';
9
8
  import styles from './styles.module.css';
10
9
  import { useTimePanel } from './use-time-panel';
10
+ import { useTimeColumnList } from './use-time-column-list';
11
11
  /** Одна колонка: список вариантов с блуждающим фокусом; стрелки двигают фокус и сразу выбирают значение */
12
12
  function TimeColumnList({ column, label, onSelect }) {
13
- const listRef = useRef(null);
14
- const selectedIndex = column.options.findIndex(option => option.selected);
15
- const firstEnabled = column.options.findIndex(option => !option.disabled);
16
- const rovingIndex = selectedIndex !== -1 ? selectedIndex : Math.max(firstEnabled, 0);
17
- // Выбранный вариант держим в видимой части колонки, строки целиком: он становится третьим сверху,
18
- // а колонка прокручивается кратно высоте строки (сверху и снизу нет «обрезанных» вариантов).
19
- // Первый показ — сразу, без анимации. Дальше, если вариант уже виден целиком, колонка стоит на месте
20
- // (клик по видимому значению ничего не двигает), иначе плавно подъезжает к нужной строке
21
- const placed = useRef(false);
22
- useEffect(() => {
23
- const list = listRef.current;
24
- // Без выбранного значения показываем первый доступный вариант (например, начало рабочих часов)
25
- const target = list === null || list === void 0 ? void 0 : list.querySelectorAll('[role="option"]')[rovingIndex];
26
- if (!list || !target)
27
- return;
28
- const gap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
29
- const top = target.offsetTop - 2 * (target.offsetHeight + gap);
30
- const first = !placed.current;
31
- placed.current = true;
32
- const visible = target.offsetTop >= list.scrollTop &&
33
- target.offsetTop + target.offsetHeight <= list.scrollTop + list.clientHeight;
34
- if (!first && visible)
35
- return;
36
- const calm = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
37
- if (first || calm || typeof list.scrollTo !== 'function')
38
- list.scrollTop = top;
39
- else
40
- list.scrollTo({ top, behavior: 'smooth' });
41
- }, [rovingIndex]);
42
- const onKeyDown = (event) => {
43
- var _a, _b;
44
- const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
45
- const edge = { Home: 0, End: column.options.length - 1 }[event.key];
46
- if (step === undefined && edge === undefined)
47
- return;
48
- event.preventDefault();
49
- let index = step === undefined ? edge : rovingIndex + step;
50
- const direction = step !== null && step !== void 0 ? step : (edge === 0 ? 1 : -1);
51
- while (index >= 0 && index < column.options.length && column.options[index].disabled)
52
- index += direction;
53
- if (index < 0 || index >= column.options.length)
54
- return;
55
- onSelect(column.options[index].value);
56
- const options = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="option"]');
57
- (_b = options === null || options === void 0 ? void 0 : options[index]) === null || _b === void 0 ? void 0 : _b.focus();
58
- };
13
+ const { listRef, rovingIndex, onKeyDown } = useTimeColumnList(column, onSelect);
59
14
  return (_jsx("div", { ref: listRef, role: "listbox", "aria-label": label, className: styles.column, onKeyDown: onKeyDown, children: column.options.map((option, index) => (_jsx("button", { type: "button", role: "option", className: clsx(styles.option, option.selected && styles.selected), "aria-selected": option.selected, disabled: option.disabled, tabIndex: index === rovingIndex ? 0 : -1, onClick: () => onSelect(option.value), children: option.label }, option.value))) }));
60
15
  }
61
16
  /**
@@ -0,0 +1,7 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ import type { TimeColumn } from './time-model';
3
+ export declare function useTimeColumnList(column: TimeColumn, onSelect: (value: number) => void): {
4
+ listRef: import("react").RefObject<HTMLDivElement | null>;
5
+ rovingIndex: number;
6
+ onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
7
+ };
@@ -0,0 +1,45 @@
1
+ 'use client';
2
+ import { useEffect, useRef } from 'react';
3
+ export function useTimeColumnList(column, onSelect) {
4
+ const listRef = useRef(null);
5
+ const selectedIndex = column.options.findIndex(option => option.selected);
6
+ const firstEnabled = column.options.findIndex(option => !option.disabled);
7
+ const rovingIndex = selectedIndex !== -1 ? selectedIndex : Math.max(firstEnabled, 0);
8
+ const placed = useRef(false);
9
+ useEffect(() => {
10
+ const list = listRef.current;
11
+ const target = list === null || list === void 0 ? void 0 : list.querySelectorAll('[role="option"]')[rovingIndex];
12
+ if (!list || !target)
13
+ return;
14
+ const gap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
15
+ const top = target.offsetTop - 2 * (target.offsetHeight + gap);
16
+ const first = !placed.current;
17
+ placed.current = true;
18
+ const visible = target.offsetTop >= list.scrollTop &&
19
+ target.offsetTop + target.offsetHeight <= list.scrollTop + list.clientHeight;
20
+ if (!first && visible)
21
+ return;
22
+ const calm = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
23
+ if (first || calm || typeof list.scrollTo !== 'function')
24
+ list.scrollTop = top;
25
+ else
26
+ list.scrollTo({ top, behavior: 'smooth' });
27
+ }, [rovingIndex]);
28
+ const onKeyDown = (event) => {
29
+ var _a, _b;
30
+ const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
31
+ const edge = { Home: 0, End: column.options.length - 1 }[event.key];
32
+ if (step === undefined && edge === undefined)
33
+ return;
34
+ event.preventDefault();
35
+ let index = step === undefined ? edge : rovingIndex + step;
36
+ const direction = step !== null && step !== void 0 ? step : (edge === 0 ? 1 : -1);
37
+ while (index >= 0 && index < column.options.length && column.options[index].disabled)
38
+ index += direction;
39
+ if (index < 0 || index >= column.options.length)
40
+ return;
41
+ onSelect(column.options[index].value);
42
+ (_b = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="option"]')[index]) === null || _b === void 0 ? void 0 : _b.focus();
43
+ };
44
+ return { listRef, rovingIndex, onKeyDown };
45
+ }
@@ -26,5 +26,5 @@ export const Tooltip = ({ className, classNames: classNamesProp, title, placemen
26
26
  const { open, setOpen, tooltipId, anchorContent } = useTooltip({ children });
27
27
  const anchorRef = useRef(null);
28
28
  const controlledShown = useDelayedOpen(controlledOpen, openDelay);
29
- return (_jsx(Popover, { "data-testid": getRelatedTestId((_a = props['data-testid']) !== null && _a !== void 0 ? _a : 'tooltip', 'popup'), anchor: _jsx("span", { ...props, ...getDataAttributes(props, 'tooltip'), ref: anchorRef, className: clsx(cssStyles.wrapper, classNames.root, className), children: anchorContent }), open: controlledShown !== null && controlledShown !== void 0 ? controlledShown : open, onOpenChange: next => setOpen(next && overflowOnly ? isOverflowing(anchorRef.current) : next), trigger: controlledOpen === undefined ? ['hover', 'focus'] : 'manual', layer: "tooltip", placement: placement, openDelay: openDelay, closeDelay: 0, returnFocus: false, closeOnOutsideClick: false, container: container, id: tooltipId, role: "tooltip", className: clsx(cssStyles.tooltip, classNames.popup), theme: theme, children: typeof title === 'string' ? (_jsx("span", { className: clsx(cssStyles.text, classNames.text), children: title })) : (_jsx("span", { className: cssStyles.node, children: title })) }));
29
+ return (_jsx(Popover, { "data-testid": getRelatedTestId((_a = props['data-testid']) !== null && _a !== void 0 ? _a : 'tooltip', 'popup'), anchor: _jsx("span", { ...props, ...getDataAttributes(props, 'tooltip'), ref: anchorRef, className: clsx(cssStyles.wrapper, classNames.root, className), children: anchorContent }), open: controlledShown !== null && controlledShown !== void 0 ? controlledShown : open, onOpenChange: next => setOpen(next && overflowOnly ? isOverflowing(anchorRef.current) : next), trigger: controlledOpen === undefined ? ['hover', 'focus'] : 'manual', layer: "tooltip", placement: placement, openDelay: openDelay, closeDelay: 0, returnFocus: false, closeOnOutsideClick: false, container: container, id: tooltipId, role: "tooltip", className: clsx(cssStyles.tooltip, classNames.popup), theme: theme, children: typeof title === 'string' ? (_jsx("span", { className: clsx(cssStyles.text, classNames.text, classNames.content), children: title })) : (_jsx("span", { className: clsx(cssStyles.node, classNames.content), children: title })) }));
30
30
  };
@@ -33,7 +33,7 @@
33
33
  gap: var(--tree-gap);
34
34
  align-items: center;
35
35
  min-height: var(--tree-row-height);
36
- padding-inline-end: 8px;
36
+ padding-inline-end: var(--space-8);
37
37
  cursor: pointer;
38
38
  user-select: none;
39
39
  outline: none;
@@ -89,7 +89,7 @@
89
89
  margin-inline-end: calc(var(--tree-gap) * -1);
90
90
  }
91
91
  .guide:first-child {
92
- margin-inline-start: 8px;
92
+ margin-inline-start: var(--space-8);
93
93
  }
94
94
  .guide::before, .guide::after {
95
95
  position: absolute;
@@ -144,7 +144,7 @@
144
144
  }
145
145
 
146
146
  .row:not(:has(.guide)) {
147
- padding-inline-start: 8px;
147
+ padding-inline-start: var(--space-8);
148
148
  }
149
149
 
150
150
  .indicator {
@@ -239,13 +239,13 @@
239
239
  .end {
240
240
  display: inline-flex;
241
241
  flex: 0 0 auto;
242
- gap: 8px;
242
+ gap: var(--space-8);
243
243
  align-items: center;
244
244
  margin-inline-start: auto;
245
245
  }
246
246
 
247
247
  .empty {
248
- padding: 12px 8px;
248
+ padding: var(--space-12) var(--space-8);
249
249
  color: var(--text-minor);
250
250
  }
251
251
 
package/tree/tree-row.js CHANGED
@@ -1,92 +1,32 @@
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 { useCallback } from 'react';
5
- import { useListNavigationItem } from '../hooks/use-list-navigation';
6
- import { composeEventHandlers, mergeRefs } from '../utils';
4
+ import { composeEventHandlers } from '../utils';
7
5
  import { useTreeClassNames } from './class-names-context';
8
6
  import styles from './styles.module.css';
9
- import { TreeIndicator, TreeRowContent } from './tree-row-content';
7
+ import { TreeRowContent } from './tree-row-content';
8
+ import { useTreeRow } from './use-tree-row';
10
9
  /** Строка дерева: линии уровней, индикатор ветки/листа, чекбокс, иконка, заголовок и контейнер справа */
11
10
  export function TreeRowView({ row, node, size, selectionMode, selected, checked, disabled, loading, matched, query, showLines, showLeafIndicator, label, selectedCount = 0, onActivate, onToggle, setExpanded, renderItem, extra, 'data-testid': testId, }) {
12
- var _a;
13
- const nav = useListNavigationItem({ id: row.id, disabled });
14
11
  const classNames = useTreeClassNames();
15
- const { ref: extraRef, className: extraClass, style: extraStyle, onClick: extraClick, ...extraRest } = extra !== null && extra !== void 0 ? extra : {};
16
- // Раскрытие отключается отдельно от строки: недоступная строка с рабочим индикатором и наоборот
17
- const toggleLocked = (_a = node.toggleDisabled) !== null && _a !== void 0 ? _a : disabled;
18
- // Клик по кнопке, ссылке или полю внутри строки (контейнер справа, свой заголовок) — отдельная зона: строку не выбирает
19
- const handleClick = useCallback((event) => {
20
- var _a, _b;
21
- const zone = (_b = (_a = event.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'button, a, input, textarea, select, [role="button"]');
22
- if (zone && zone !== event.currentTarget && event.currentTarget.contains(zone))
23
- return;
24
- if (!disabled)
25
- onActivate(row.id);
26
- }, [disabled, onActivate, row.id]);
27
- const handleToggle = useCallback((event) => {
28
- event.stopPropagation();
29
- if (!toggleLocked)
30
- onToggle(row.id);
31
- }, [toggleLocked, onToggle, row.id]);
32
- const isCheckbox = selectionMode === 'checkbox';
33
- const isSelectable = selectionMode === 'single' || selectionMode === 'multiple';
34
- const aria = {
35
- 'aria-level': row.level,
36
- 'aria-setsize': row.setSize,
37
- 'aria-posinset': row.posInSet,
38
- 'aria-disabled': disabled || undefined,
39
- 'aria-busy': loading || undefined,
40
- };
41
- if (row.expandable)
42
- aria['aria-expanded'] = row.expanded;
43
- if (isSelectable)
44
- aria['aria-selected'] = selected;
45
- if (isCheckbox)
46
- aria['aria-checked'] = checked;
47
- const indicatorProps = {
12
+ const { navProps, rootRef, extraRest, extraClass, extraStyle, extraClick, isCheckbox, aria, contentProps, item, handleClick, } = useTreeRow({
48
13
  row,
49
- node: node,
50
- loading,
51
- toggleLocked,
52
- showLeafIndicator,
53
- onToggle: handleToggle,
54
- testId,
55
- };
56
- const contentProps = {
57
- ...indicatorProps,
58
- isCheckbox,
59
- checked,
60
- disabled,
61
- matched,
62
- query,
63
- label,
64
- selectedCount,
65
- };
66
- const item = {
67
- id: row.id,
68
14
  node,
69
- level: row.level,
70
- expanded: row.expanded,
71
- expandable: row.expandable,
15
+ selectionMode,
72
16
  selected,
73
17
  checked,
74
18
  disabled,
75
19
  loading,
76
20
  matched,
77
- toggleDisabled: toggleLocked,
21
+ query,
22
+ showLeafIndicator,
78
23
  label,
79
- indicator: _jsx(TreeIndicator, { ...indicatorProps }),
80
- toggle: () => !toggleLocked && onToggle(row.id),
81
- setExpanded: value => !toggleLocked && setExpanded(row.id, value),
82
- activate: () => !disabled && onActivate(row.id),
83
- getToggleProps: () => ({
84
- onClick: handleToggle,
85
- 'aria-expanded': row.expandable ? row.expanded : undefined,
86
- 'aria-disabled': toggleLocked || undefined,
87
- 'data-locked': toggleLocked || undefined,
88
- tabIndex: -1,
89
- }),
90
- };
91
- return (_jsxs("div", { ...extraRest, ...nav.props, ...aria, ref: mergeRefs([nav.props.ref, extraRef]), role: "treeitem", id: `${testId !== null && testId !== void 0 ? testId : 'tree'}-${row.id}`, className: clsx(styles.row, styles[`size-${size}`], classNames.row, extraClass), style: { ...extraStyle, ['--tree-level']: row.level }, "data-tree-id": row.id, "data-selected": selected || undefined, "data-checked": isCheckbox && checked ? String(checked) : undefined, "data-disabled": disabled || undefined, "data-hoverable": node.hoverable === false ? 'false' : undefined, "data-custom": renderItem ? '' : undefined, "data-matched": matched || undefined, "data-expandable": row.expandable || undefined, "data-plain": (!row.expandable && !showLeafIndicator && !node.icon) || undefined, "data-icon-leaf": (!row.expandable && !showLeafIndicator && node.icon) || undefined, "data-bold": node.bold || undefined, onClick: composeEventHandlers(handleClick, extraClick), children: [row.guides.map((guide, index) => (_jsx("span", { className: clsx(styles.guide, classNames.guide), "data-guide": showLines ? guide : 'none', "aria-hidden": true }, index))), renderItem ? renderItem(item) : _jsx(TreeRowContent, { ...contentProps })] }));
24
+ selectedCount,
25
+ onActivate,
26
+ onToggle,
27
+ setExpanded,
28
+ extra,
29
+ testId,
30
+ });
31
+ return (_jsxs("div", { ...extraRest, ...navProps, ...aria, ref: rootRef, role: "treeitem", id: `${testId !== null && testId !== void 0 ? testId : 'tree'}-${row.id}`, className: clsx(styles.row, styles[`size-${size}`], classNames.row, extraClass), style: { ...extraStyle, ['--tree-level']: row.level }, "data-tree-id": row.id, "data-selected": selected || undefined, "data-checked": isCheckbox && checked ? String(checked) : undefined, "data-disabled": disabled || undefined, "data-hoverable": node.hoverable === false ? 'false' : undefined, "data-custom": renderItem ? '' : undefined, "data-matched": matched || undefined, "data-expandable": row.expandable || undefined, "data-plain": (!row.expandable && !showLeafIndicator && !node.icon) || undefined, "data-icon-leaf": (!row.expandable && !showLeafIndicator && node.icon) || undefined, "data-bold": node.bold || undefined, onClick: composeEventHandlers(handleClick, extraClick), children: [row.guides.map((guide, index) => (_jsx("span", { className: clsx(styles.guide, classNames.guide), "data-guide": showLines ? guide : 'none', "aria-hidden": true }, index))), renderItem ? renderItem(item) : _jsx(TreeRowContent, { ...contentProps })] }));
92
32
  }
@@ -21,11 +21,11 @@
21
21
  }
22
22
 
23
23
  .search {
24
- padding: 12px 12px 4px;
24
+ padding: var(--space-12) var(--space-12) var(--space-4);
25
25
  }
26
26
 
27
27
  .scroll {
28
- padding: 8px;
28
+ padding: var(--space-8);
29
29
  overflow: auto;
30
30
  overscroll-behavior: contain;
31
31
  }