@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
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useTimeColumnList = useTimeColumnList;
5
+ const react_1 = require("react");
6
+ function useTimeColumnList(column, onSelect) {
7
+ const listRef = (0, react_1.useRef)(null);
8
+ const selectedIndex = column.options.findIndex(option => option.selected);
9
+ const firstEnabled = column.options.findIndex(option => !option.disabled);
10
+ const rovingIndex = selectedIndex !== -1 ? selectedIndex : Math.max(firstEnabled, 0);
11
+ const placed = (0, react_1.useRef)(false);
12
+ (0, react_1.useEffect)(() => {
13
+ const list = listRef.current;
14
+ const target = list === null || list === void 0 ? void 0 : list.querySelectorAll('[role="option"]')[rovingIndex];
15
+ if (!list || !target)
16
+ return;
17
+ const gap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
18
+ const top = target.offsetTop - 2 * (target.offsetHeight + gap);
19
+ const first = !placed.current;
20
+ placed.current = true;
21
+ const visible = target.offsetTop >= list.scrollTop &&
22
+ target.offsetTop + target.offsetHeight <= list.scrollTop + list.clientHeight;
23
+ if (!first && visible)
24
+ return;
25
+ const calm = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
26
+ if (first || calm || typeof list.scrollTo !== 'function')
27
+ list.scrollTop = top;
28
+ else
29
+ list.scrollTo({ top, behavior: 'smooth' });
30
+ }, [rovingIndex]);
31
+ const onKeyDown = (event) => {
32
+ var _a, _b;
33
+ const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
34
+ const edge = { Home: 0, End: column.options.length - 1 }[event.key];
35
+ if (step === undefined && edge === undefined)
36
+ return;
37
+ event.preventDefault();
38
+ let index = step === undefined ? edge : rovingIndex + step;
39
+ const direction = step !== null && step !== void 0 ? step : (edge === 0 ? 1 : -1);
40
+ while (index >= 0 && index < column.options.length && column.options[index].disabled)
41
+ index += direction;
42
+ if (index < 0 || index >= column.options.length)
43
+ return;
44
+ onSelect(column.options[index].value);
45
+ (_b = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[role="option"]')[index]) === null || _b === void 0 ? void 0 : _b.focus();
46
+ };
47
+ return { listRef, rovingIndex, onKeyDown };
48
+ }
@@ -65,6 +65,6 @@ const Tooltip = ({ className, classNames: classNamesProp, title, placement = 'to
65
65
  const { open, setOpen, tooltipId, anchorContent } = (0, use_tooltip_1.useTooltip)({ children });
66
66
  const anchorRef = (0, react_1.useRef)(null);
67
67
  const controlledShown = (0, use_tooltip_1.useDelayedOpen)(controlledOpen, openDelay);
68
- return ((0, jsx_runtime_1.jsx)(popover_1.Popover, { "data-testid": (0, data_attributes_1.getRelatedTestId)((_a = props['data-testid']) !== null && _a !== void 0 ? _a : 'tooltip', 'popup'), anchor: (0, jsx_runtime_1.jsx)("span", { ...props, ...(0, data_attributes_1.getDataAttributes)(props, 'tooltip'), ref: anchorRef, className: (0, clsx_1.default)(styles_module_scss_1.default.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: (0, clsx_1.default)(styles_module_scss_1.default.tooltip, classNames.popup), theme: theme, children: typeof title === 'string' ? ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(styles_module_scss_1.default.text, classNames.text), children: title })) : ((0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.node, children: title })) }));
68
+ return ((0, jsx_runtime_1.jsx)(popover_1.Popover, { "data-testid": (0, data_attributes_1.getRelatedTestId)((_a = props['data-testid']) !== null && _a !== void 0 ? _a : 'tooltip', 'popup'), anchor: (0, jsx_runtime_1.jsx)("span", { ...props, ...(0, data_attributes_1.getDataAttributes)(props, 'tooltip'), ref: anchorRef, className: (0, clsx_1.default)(styles_module_scss_1.default.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: (0, clsx_1.default)(styles_module_scss_1.default.tooltip, classNames.popup), theme: theme, children: typeof title === 'string' ? ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(styles_module_scss_1.default.text, classNames.text, classNames.content), children: title })) : ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(styles_module_scss_1.default.node, classNames.content), children: title })) }));
69
69
  };
70
70
  exports.Tooltip = Tooltip;
@@ -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
 
@@ -7,92 +7,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TreeRowView = TreeRowView;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const clsx_1 = __importDefault(require("clsx"));
10
- const react_1 = require("react");
11
- const use_list_navigation_1 = require("../hooks/use-list-navigation");
12
10
  const utils_1 = require("../utils");
13
11
  const class_names_context_1 = require("./class-names-context");
14
12
  const styles_module_scss_1 = __importDefault(require("./styles.module.css"));
15
13
  const tree_row_content_1 = require("./tree-row-content");
14
+ const use_tree_row_1 = require("./use-tree-row");
16
15
  /** Строка дерева: линии уровней, индикатор ветки/листа, чекбокс, иконка, заголовок и контейнер справа */
17
16
  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, }) {
18
- var _a;
19
- const nav = (0, use_list_navigation_1.useListNavigationItem)({ id: row.id, disabled });
20
17
  const classNames = (0, class_names_context_1.useTreeClassNames)();
21
- const { ref: extraRef, className: extraClass, style: extraStyle, onClick: extraClick, ...extraRest } = extra !== null && extra !== void 0 ? extra : {};
22
- // Раскрытие отключается отдельно от строки: недоступная строка с рабочим индикатором и наоборот
23
- const toggleLocked = (_a = node.toggleDisabled) !== null && _a !== void 0 ? _a : disabled;
24
- // Клик по кнопке, ссылке или полю внутри строки (контейнер справа, свой заголовок) — отдельная зона: строку не выбирает
25
- const handleClick = (0, react_1.useCallback)((event) => {
26
- var _a, _b;
27
- const zone = (_b = (_a = event.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'button, a, input, textarea, select, [role="button"]');
28
- if (zone && zone !== event.currentTarget && event.currentTarget.contains(zone))
29
- return;
30
- if (!disabled)
31
- onActivate(row.id);
32
- }, [disabled, onActivate, row.id]);
33
- const handleToggle = (0, react_1.useCallback)((event) => {
34
- event.stopPropagation();
35
- if (!toggleLocked)
36
- onToggle(row.id);
37
- }, [toggleLocked, onToggle, row.id]);
38
- const isCheckbox = selectionMode === 'checkbox';
39
- const isSelectable = selectionMode === 'single' || selectionMode === 'multiple';
40
- const aria = {
41
- 'aria-level': row.level,
42
- 'aria-setsize': row.setSize,
43
- 'aria-posinset': row.posInSet,
44
- 'aria-disabled': disabled || undefined,
45
- 'aria-busy': loading || undefined,
46
- };
47
- if (row.expandable)
48
- aria['aria-expanded'] = row.expanded;
49
- if (isSelectable)
50
- aria['aria-selected'] = selected;
51
- if (isCheckbox)
52
- aria['aria-checked'] = checked;
53
- const indicatorProps = {
18
+ const { navProps, rootRef, extraRest, extraClass, extraStyle, extraClick, isCheckbox, aria, contentProps, item, handleClick, } = (0, use_tree_row_1.useTreeRow)({
54
19
  row,
55
- node: node,
56
- loading,
57
- toggleLocked,
58
- showLeafIndicator,
59
- onToggle: handleToggle,
60
- testId,
61
- };
62
- const contentProps = {
63
- ...indicatorProps,
64
- isCheckbox,
65
- checked,
66
- disabled,
67
- matched,
68
- query,
69
- label,
70
- selectedCount,
71
- };
72
- const item = {
73
- id: row.id,
74
20
  node,
75
- level: row.level,
76
- expanded: row.expanded,
77
- expandable: row.expandable,
21
+ selectionMode,
78
22
  selected,
79
23
  checked,
80
24
  disabled,
81
25
  loading,
82
26
  matched,
83
- toggleDisabled: toggleLocked,
27
+ query,
28
+ showLeafIndicator,
84
29
  label,
85
- indicator: (0, jsx_runtime_1.jsx)(tree_row_content_1.TreeIndicator, { ...indicatorProps }),
86
- toggle: () => !toggleLocked && onToggle(row.id),
87
- setExpanded: value => !toggleLocked && setExpanded(row.id, value),
88
- activate: () => !disabled && onActivate(row.id),
89
- getToggleProps: () => ({
90
- onClick: handleToggle,
91
- 'aria-expanded': row.expandable ? row.expanded : undefined,
92
- 'aria-disabled': toggleLocked || undefined,
93
- 'data-locked': toggleLocked || undefined,
94
- tabIndex: -1,
95
- }),
96
- };
97
- return ((0, jsx_runtime_1.jsxs)("div", { ...extraRest, ...nav.props, ...aria, ref: (0, utils_1.mergeRefs)([nav.props.ref, extraRef]), role: "treeitem", id: `${testId !== null && testId !== void 0 ? testId : 'tree'}-${row.id}`, className: (0, clsx_1.default)(styles_module_scss_1.default.row, styles_module_scss_1.default[`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: (0, utils_1.composeEventHandlers)(handleClick, extraClick), children: [row.guides.map((guide, index) => ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(styles_module_scss_1.default.guide, classNames.guide), "data-guide": showLines ? guide : 'none', "aria-hidden": true }, index))), renderItem ? renderItem(item) : (0, jsx_runtime_1.jsx)(tree_row_content_1.TreeRowContent, { ...contentProps })] }));
30
+ selectedCount,
31
+ onActivate,
32
+ onToggle,
33
+ setExpanded,
34
+ extra,
35
+ testId,
36
+ });
37
+ return ((0, jsx_runtime_1.jsxs)("div", { ...extraRest, ...navProps, ...aria, ref: rootRef, role: "treeitem", id: `${testId !== null && testId !== void 0 ? testId : 'tree'}-${row.id}`, className: (0, clsx_1.default)(styles_module_scss_1.default.row, styles_module_scss_1.default[`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: (0, utils_1.composeEventHandlers)(handleClick, extraClick), children: [row.guides.map((guide, index) => ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)(styles_module_scss_1.default.guide, classNames.guide), "data-guide": showLines ? guide : 'none', "aria-hidden": true }, index))), renderItem ? renderItem(item) : (0, jsx_runtime_1.jsx)(tree_row_content_1.TreeRowContent, { ...contentProps })] }));
98
38
  }
@@ -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
  }
@@ -0,0 +1,102 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useTreeRow = useTreeRow;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const use_list_navigation_1 = require("../hooks/use-list-navigation");
8
+ const utils_1 = require("../utils");
9
+ const tree_row_content_1 = require("./tree-row-content");
10
+ /** Поведение строки дерева: клавиатурная навигация, зоны клика и API пользовательского рендера. */
11
+ function useTreeRow(params) {
12
+ var _a;
13
+ const { row, node, selectionMode, selected, checked, disabled, loading, matched, query, showLeafIndicator, label, selectedCount, onActivate, onToggle, setExpanded, extra, testId, } = params;
14
+ const nav = (0, use_list_navigation_1.useListNavigationItem)({ id: row.id, disabled });
15
+ const { ref: extraRef, className: extraClass, style: extraStyle, onClick: extraClick, ...extraRest } = extra !== null && extra !== void 0 ? extra : {};
16
+ const toggleLocked = (_a = node.toggleDisabled) !== null && _a !== void 0 ? _a : disabled;
17
+ const handleClick = (0, react_1.useCallback)((event) => {
18
+ var _a, _b;
19
+ const zone = (_b = (_a = event.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'button, a, input, textarea, select, [role="button"]');
20
+ if (zone && zone !== event.currentTarget && event.currentTarget.contains(zone))
21
+ return;
22
+ if (!disabled)
23
+ onActivate(row.id);
24
+ }, [disabled, onActivate, row.id]);
25
+ const handleToggle = (0, react_1.useCallback)((event) => {
26
+ event.stopPropagation();
27
+ if (!toggleLocked)
28
+ onToggle(row.id);
29
+ }, [toggleLocked, onToggle, row.id]);
30
+ const isCheckbox = selectionMode === 'checkbox';
31
+ const isSelectable = selectionMode === 'single' || selectionMode === 'multiple';
32
+ const aria = {
33
+ 'aria-level': row.level,
34
+ 'aria-setsize': row.setSize,
35
+ 'aria-posinset': row.posInSet,
36
+ 'aria-disabled': disabled || undefined,
37
+ 'aria-busy': loading || undefined,
38
+ };
39
+ if (row.expandable)
40
+ aria['aria-expanded'] = row.expanded;
41
+ if (isSelectable)
42
+ aria['aria-selected'] = selected;
43
+ if (isCheckbox)
44
+ aria['aria-checked'] = checked;
45
+ const indicatorProps = {
46
+ row,
47
+ node: node,
48
+ loading,
49
+ toggleLocked,
50
+ showLeafIndicator,
51
+ onToggle: handleToggle,
52
+ testId,
53
+ };
54
+ const contentProps = {
55
+ ...indicatorProps,
56
+ isCheckbox,
57
+ checked,
58
+ disabled,
59
+ matched,
60
+ query,
61
+ label,
62
+ selectedCount,
63
+ };
64
+ const item = {
65
+ id: row.id,
66
+ node,
67
+ level: row.level,
68
+ expanded: row.expanded,
69
+ expandable: row.expandable,
70
+ selected,
71
+ checked,
72
+ disabled,
73
+ loading,
74
+ matched,
75
+ toggleDisabled: toggleLocked,
76
+ label,
77
+ indicator: (0, jsx_runtime_1.jsx)(tree_row_content_1.TreeIndicator, { ...indicatorProps }),
78
+ toggle: () => !toggleLocked && onToggle(row.id),
79
+ setExpanded: value => !toggleLocked && setExpanded(row.id, value),
80
+ activate: () => !disabled && onActivate(row.id),
81
+ getToggleProps: () => ({
82
+ onClick: handleToggle,
83
+ 'aria-expanded': row.expandable ? row.expanded : undefined,
84
+ 'aria-disabled': toggleLocked || undefined,
85
+ 'data-locked': toggleLocked || undefined,
86
+ tabIndex: -1,
87
+ }),
88
+ };
89
+ return {
90
+ navProps: nav.props,
91
+ rootRef: (0, utils_1.mergeRefs)([nav.props.ref, extraRef]),
92
+ extraRest,
93
+ extraClass,
94
+ extraStyle,
95
+ extraClick,
96
+ isCheckbox,
97
+ aria,
98
+ contentProps,
99
+ item,
100
+ handleClick,
101
+ };
102
+ }
@@ -10,6 +10,8 @@ exports.getStaticClassName = exports.componentClassNames = void 0;
10
10
  * - ключ — компонент в PascalCase, значение — части в camelCase; `root` — корневой элемент;
11
11
  * - часть — это элемент DOM, на который класс попадает вместе со своим классом компонента (свой не заменяется);
12
12
  * - состояния частей — атрибуты (`data-selected`, `data-open`, `aria-current`…), на них пишутся селекторы;
13
+ * - произвольный пользовательский JSX получает слот `content`; библиотека не навязывает ему раскладку и отступы,
14
+ * а пользователь оформляет его своим классом и компонентными токенами;
13
15
  * - новый компонент: добавить строку сюда, описания — в docs, применить `useClassNames` (см. `use-class-names.ts`).
14
16
  */
15
17
  /** Части рамки поля (`FieldFrame`): одинаковы у Input, Textarea, NumberInput, DatePicker, TimePicker */
@@ -90,7 +92,7 @@ exports.componentClassNames = {
90
92
  Avatar: ['root', 'picture', 'icon', 'name', 'description'],
91
93
  ProgressBar: ['root', 'track', 'fill', 'text'],
92
94
  Skeleton: ['root', 'line', 'content'],
93
- Tooltip: ['root', 'popup', 'text'],
95
+ Tooltip: ['root', 'popup', 'content', 'text'],
94
96
  Popover: ['root', 'arrow', 'content'],
95
97
  Hint: ['root', 'popover', 'content', 'header', 'paragraph', 'buttons'],
96
98
  Stepper: ['root', 'step', 'control', 'marker', 'title', 'description'],
@@ -14,13 +14,13 @@
14
14
  .time {
15
15
  display: flex;
16
16
  align-items: center;
17
- padding: 16px 16px 16px 0;
17
+ padding: var(--space-16) var(--space-16) var(--space-16) 0;
18
18
  border-left: 1px solid var(--control-minor);
19
19
  }
20
20
 
21
21
  .withTime .time {
22
- padding-inline-start: 8px;
23
- margin-inline-start: -8px;
22
+ padding-inline-start: var(--space-8);
23
+ margin-inline-start: calc(-1 * var(--space-8));
24
24
  }
25
25
 
26
26
  @media (max-width: 767.98px) {
@@ -29,7 +29,7 @@
29
29
  }
30
30
  .withTime .time {
31
31
  justify-content: center;
32
- padding: 0 16px 16px;
32
+ padding: 0 var(--space-16) var(--space-16);
33
33
  margin: 0;
34
34
  border-top: 1px solid var(--control-minor);
35
35
  border-left: 0;
@@ -37,7 +37,7 @@
37
37
  }
38
38
  .rangeTime {
39
39
  flex-direction: column;
40
- gap: 8px;
40
+ gap: var(--space-8);
41
41
  align-items: stretch;
42
42
  min-width: 0;
43
43
  }
@@ -81,7 +81,7 @@
81
81
  font-weight: 600;
82
82
  line-height: 1.2;
83
83
  letter-spacing: 0.2px;
84
- padding: 0 16px 4px;
84
+ padding: 0 var(--space-16) var(--space-4);
85
85
  color: var(--text-primary);
86
86
  }
87
87
 
@@ -91,7 +91,7 @@
91
91
  width: 100%;
92
92
  }
93
93
  .sheetBody > :first-child {
94
- --calendar-pad-x: 8px;
94
+ --calendar-pad-x: var(--space-8);
95
95
  flex: 1 0 0;
96
96
  min-width: 224px;
97
97
  }
@@ -100,7 +100,7 @@
100
100
  flex: 0 1 auto;
101
101
  align-items: stretch;
102
102
  min-width: 0;
103
- padding: 8px 2px;
103
+ padding: var(--space-8) var(--space-2);
104
104
  margin: 0;
105
105
  overflow: hidden;
106
106
  border-left: 1px solid var(--control-minor);
@@ -110,9 +110,9 @@
110
110
  --time-option-h: 32px;
111
111
  --time-column-w: 38px;
112
112
  flex: 0 1 auto;
113
- gap: 2px;
113
+ gap: var(--space-2);
114
114
  min-width: 0;
115
- padding: 0 2px;
115
+ padding: 0 var(--space-2);
116
116
  }
117
117
  .sheetTime .sheetTimePanel.sheetTimePanel > * {
118
118
  flex: 0 1 var(--time-column-w);
@@ -1,8 +1,6 @@
1
1
  .root {
2
2
  --drawer-duration-in: var(--lt-ui-drawer-duration-in, 320ms);
3
3
  --drawer-duration-out: var(--lt-ui-drawer-duration-out, 220ms);
4
- --drawer-ease-in: cubic-bezier(0.32, 0.72, 0, 1);
5
- --drawer-ease-out: cubic-bezier(0.4, 0, 1, 1);
6
4
  --drawer-scrim-opacity: var(--lt-ui-drawer-scrim-opacity, 0.6);
7
5
  --drawer-padding: var(--lt-ui-drawer-padding, 24px);
8
6
  position: fixed;
@@ -11,7 +9,7 @@
11
9
  }
12
10
  @media (max-width: 479.98px) {
13
11
  .root {
14
- --drawer-padding: 16px;
12
+ --drawer-padding: var(--space-16);
15
13
  }
16
14
  }
17
15
  .root:global([data-lt-ui-theme='dark']) {
@@ -153,7 +151,7 @@
153
151
  }
154
152
  .transitionEnterActive .panel {
155
153
  transform: translate3d(0, 0, 0);
156
- transition: transform var(--drawer-duration-in) var(--drawer-ease-in);
154
+ transition: transform var(--drawer-duration-in) cubic-bezier(0.32, 0.72, 0, 1);
157
155
  will-change: transform;
158
156
  }
159
157
 
@@ -167,7 +165,7 @@
167
165
  }
168
166
  .transitionExitActive .panel {
169
167
  transform: var(--drawer-from);
170
- transition: transform var(--drawer-duration-out) var(--drawer-ease-out);
168
+ transition: transform var(--drawer-duration-out) cubic-bezier(0.4, 0, 1, 1);
171
169
  }
172
170
 
173
171
  .root[data-dragging] .panel {
@@ -187,7 +185,7 @@
187
185
  display: flex;
188
186
  flex: none;
189
187
  justify-content: center;
190
- padding: 10px 0 2px;
188
+ padding: 10px 0 var(--space-2);
191
189
  touch-action: none;
192
190
  cursor: grab;
193
191
  }
@@ -217,9 +215,9 @@
217
215
  z-index: 2;
218
216
  display: flex;
219
217
  flex: none;
220
- gap: 8px;
218
+ gap: var(--space-8);
221
219
  align-items: center;
222
- padding: 12px calc(var(--drawer-padding) - 8px) 12px var(--drawer-padding);
220
+ padding: var(--space-12) calc(var(--drawer-padding) - var(--space-8)) var(--space-12) var(--drawer-padding);
223
221
  background-color: var(--background-elevated);
224
222
  transition: box-shadow 150ms ease-out;
225
223
  }
@@ -237,13 +235,13 @@
237
235
  .actions {
238
236
  display: flex;
239
237
  flex: none;
240
- gap: 4px;
238
+ gap: var(--space-4);
241
239
  align-items: center;
242
240
  }
243
241
 
244
242
  .back {
245
243
  flex: none;
246
- margin-inline-start: -8px;
244
+ margin-inline-start: calc(-1 * var(--space-8));
247
245
  }
248
246
 
249
247
  .close {
@@ -256,9 +254,9 @@
256
254
  z-index: 2;
257
255
  display: flex;
258
256
  flex: none;
259
- gap: 12px;
257
+ gap: var(--space-12);
260
258
  justify-content: space-between;
261
- padding: 16px var(--drawer-padding) max(16px, env(safe-area-inset-bottom, 0px));
259
+ padding: var(--space-16) var(--drawer-padding) max(var(--space-16), env(safe-area-inset-bottom, 0px));
262
260
  margin-top: auto;
263
261
  background-color: var(--background-elevated);
264
262
  transition: box-shadow 150ms ease-out;
@@ -10,23 +10,22 @@
10
10
  --file-pill-width: 132px;
11
11
  --file-pill-height: var(--space-32);
12
12
  --file-emblem-size: var(--space-24);
13
- --file-name-chrome: 76px;
13
+ --file-name-max-width: 56px;
14
14
  }
15
15
  .root.m {
16
16
  --file-pill-width: 144px;
17
17
  --file-pill-height: var(--space-40);
18
18
  --file-emblem-size: var(--space-32);
19
- --file-name-chrome: 92px;
19
+ --file-name-max-width: 52px;
20
20
  }
21
21
  .root.l {
22
22
  --file-pill-width: 152px;
23
23
  --file-pill-height: var(--space-48);
24
24
  --file-emblem-size: var(--space-32);
25
- --file-name-chrome: 92px;
25
+ --file-name-max-width: 60px;
26
26
  }
27
27
  .root:not(.imageRoot) {
28
28
  width: var(--file-pill-width);
29
- --file-name-max-width: calc(var(--file-pill-width) - var(--file-name-chrome));
30
29
  }
31
30
  .root:not(.imageRoot) .pillBody .fileName {
32
31
  max-width: var(--file-name-max-width);
@@ -3,12 +3,12 @@
3
3
  justify-self: end;
4
4
  width: fit-content;
5
5
  height: fit-content;
6
- margin: -4px -4px -4px 8px;
6
+ margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) var(--space-8);
7
7
  }
8
8
 
9
9
  .actionButton {
10
10
  width: 100%;
11
- padding: 4px 10px;
11
+ padding: var(--space-4) 10px;
12
12
  }
13
13
 
14
14
  .extraButton {
@@ -4,11 +4,11 @@
4
4
  }
5
5
 
6
6
  .hasChild {
7
- margin: 0 0 0 12px;
7
+ margin: 0 0 0 var(--space-12);
8
8
  }
9
9
  .hasChild.column {
10
10
  grid-area: 2/1/3/4;
11
- margin: 12px 0 0;
11
+ margin: var(--space-12) 0 0;
12
12
  }
13
13
 
14
14
  .header {
@@ -29,5 +29,5 @@
29
29
  color: var(--text-primary);
30
30
  }
31
31
  .paragraph:nth-child(2) {
32
- margin-top: 4px;
32
+ margin-top: var(--space-4);
33
33
  }
@@ -23,9 +23,9 @@
23
23
  .buttonBlock {
24
24
  display: flex;
25
25
  grid-area: button;
26
- gap: 8px;
26
+ gap: var(--space-8);
27
27
  justify-content: flex-end;
28
- margin-top: 16px;
28
+ margin-top: var(--space-16);
29
29
  }
30
30
 
31
31
  .extraButton {
@@ -1,16 +1,15 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo, useRef, useState } from 'react';
4
3
  import ReactDOM from 'react-dom';
5
4
  import { contextProvider } from '../_internal/compat';
6
5
  import { FocusTrap } from '../_internal/focus-trap';
7
6
  import { FocusOnContext } from '../_internal/hooks';
8
- import { useLayer } from '../_internal/layer';
9
7
  import { Button } from '../button';
10
8
  import { CloseIcon } from '../icons';
11
9
  import { Loader } from '../loader';
12
10
  import { isInlineContainer, usePortalTarget } from '../portal';
13
11
  import styles from './viewer.module.css';
12
+ import { useImageViewer } from './use-image-viewer';
14
13
  const FocusOnProvider = contextProvider(FocusOnContext);
15
14
  /**
16
15
  * Полноэкранный просмотр: затемнение, фокус остаётся внутри, закрывается Escape, кликом вне картинки или крестиком.
@@ -19,22 +18,13 @@ const FocusOnProvider = contextProvider(FocusOnContext);
19
18
  const DownloadIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", "aria-hidden": true, children: _jsx("path", { d: "M12 4v11m0 0-4-4m4 4 4-4M5 19.5h14", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
20
19
  export function ImageViewer({ testId, src, alt, srcSet, sizes, closeLabel, loading, downloadLabel, downloadName, onClose, container, }) {
21
20
  const target = usePortalTarget({ container });
22
- const imageRef = useRef(null);
23
- const closeRef = useRef(null);
24
- const [zoomed, setZoomed] = useState(false);
25
- const contentRefs = useMemo(() => [imageRef, closeRef], []);
26
- useLayer({ open: true, type: 'image-viewer', contentRefs, onClose });
21
+ const { imageRef, closeRef, zoomed, toggleZoom, onImageKeyDown } = useImageViewer(onClose);
27
22
  const viewer = (_jsx(FocusTrap, { returnFocus: true, children: _jsxs("div", { className: styles.viewer, role: "dialog", "data-testid": testId, "aria-modal": "true", "aria-label": alt, "data-lt-ui-theme": "dark", "data-lt-ui-portal": "", children: [_jsxs("div", { ref: closeRef, className: styles.close, children: [downloadLabel && !loading && (_jsx(Button, { iconOnly: true, compact: true, "aria-label": downloadLabel, variant: "link-minor", className: styles.tool, onClick: () => {
28
23
  const link = globalThis.document.createElement('a');
29
24
  link.href = src;
30
25
  link.download = downloadName !== null && downloadName !== void 0 ? downloadName : '';
31
26
  link.click();
32
- }, children: _jsx(DownloadIcon, {}) })), _jsx(Button, { iconOnly: true, compact: true, "aria-label": closeLabel, variant: "link-minor", className: styles.tool, onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: zoomed ? styles.scrollZoomed : styles.scroll, children: _jsx(FocusOnProvider, { value: true, children: loading ? (_jsx(Loader, { size: "m" })) : (_jsx("img", { ref: imageRef, className: zoomed ? styles.zoomed : styles.fit, src: src, srcSet: srcSet, sizes: sizes, alt: alt, role: "button", tabIndex: 0, "aria-pressed": zoomed, onClick: () => setZoomed(value => !value), onKeyDown: event => {
33
- if (event.key === 'Enter' || event.key === ' ') {
34
- event.preventDefault();
35
- setZoomed(value => !value);
36
- }
37
- } })) }) })] }) }));
27
+ }, children: _jsx(DownloadIcon, {}) })), _jsx(Button, { iconOnly: true, compact: true, "aria-label": closeLabel, variant: "link-minor", className: styles.tool, onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: zoomed ? styles.scrollZoomed : styles.scroll, children: _jsx(FocusOnProvider, { value: true, children: loading ? (_jsx(Loader, { size: "m" })) : (_jsx("img", { ref: imageRef, className: zoomed ? styles.zoomed : styles.fit, src: src, srcSet: srcSet, sizes: sizes, alt: alt, role: "button", tabIndex: 0, "aria-pressed": zoomed, onClick: toggleZoom, onKeyDown: onImageKeyDown })) }) })] }) }));
38
28
  if (isInlineContainer(container))
39
29
  return viewer;
40
30
  return target ? ReactDOM.createPortal(viewer, target) : null;