@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.
- package/_internal/base-button/styles.module.css +1 -1
- package/_internal/field/_motion.css +0 -0
- package/_internal/field/field.module.css +21 -23
- package/_internal/floating/use-floating.d.ts +1 -1
- package/_internal/floating/use-floating.js +6 -2
- package/_internal/picker/picker-field.module.css +1 -1
- package/_internal/picker/picker-sheet.module.css +1 -1
- package/accordion/styles.module.css +3 -4
- package/alert/styles/alert.module.css +8 -8
- package/avatar/avatar-group.module.css +1 -1
- package/avatar/styles.module.css +3 -3
- package/badge/styles.module.css +3 -3
- package/breadcrumbs/styles.module.css +4 -4
- package/button/styles.module.css +7 -7
- package/calendar/styles.module.css +11 -11
- package/caption/styles.module.css +1 -1
- package/checkbox/styles/style.module.css +10 -12
- package/chip/styles.module.css +3 -3
- package/cjs/_internal/base-button/styles.module.css +1 -1
- package/cjs/_internal/field/_motion.css +0 -0
- package/cjs/_internal/field/field.module.css +21 -23
- package/cjs/_internal/floating/use-floating.js +6 -2
- package/cjs/_internal/picker/picker-field.module.css +1 -1
- package/cjs/_internal/picker/picker-sheet.module.css +1 -1
- package/cjs/accordion/styles.module.css +3 -4
- package/cjs/alert/styles/alert.module.css +8 -8
- package/cjs/avatar/avatar-group.module.css +1 -1
- package/cjs/avatar/styles.module.css +3 -3
- package/cjs/badge/styles.module.css +3 -3
- package/cjs/breadcrumbs/styles.module.css +4 -4
- package/cjs/button/styles.module.css +7 -7
- package/cjs/calendar/styles.module.css +11 -11
- package/cjs/caption/styles.module.css +1 -1
- package/cjs/checkbox/styles/style.module.css +10 -12
- package/cjs/chip/styles.module.css +3 -3
- package/cjs/date-picker/styles.module.css +10 -10
- package/cjs/drawer/styles.module.css +10 -12
- package/cjs/file/styles.module.css +3 -4
- package/cjs/hint/styles/buttons.module.css +2 -2
- package/cjs/hint/styles/hint-content.module.css +3 -3
- package/cjs/hint/styles/hint.module.css +2 -2
- package/cjs/image/image-viewer.js +3 -13
- package/cjs/image/image.js +4 -27
- package/cjs/image/use-image-preview.js +32 -0
- package/cjs/image/use-image-viewer.js +21 -0
- package/cjs/image/viewer.module.css +1 -1
- package/cjs/list/list-divider/styles.module.css +2 -2
- package/cjs/list/list-item/styles.module.css +2 -2
- package/cjs/list/list-section/styles.module.css +4 -4
- package/cjs/modal/modal.js +4 -10
- package/cjs/modal/styles/_animations.css +2 -2
- package/cjs/modal/styles/modal-footer.module.css +3 -3
- package/cjs/modal/styles/modal-header.module.css +5 -5
- package/cjs/modal/styles/modal.module.css +9 -4
- package/cjs/modal/use-modal.js +15 -1
- package/cjs/navigation/navigation-compact.js +2 -30
- package/cjs/navigation/navigation-row.js +5 -65
- package/cjs/navigation/navigation-views.js +3 -57
- package/cjs/navigation/navigation.js +2 -1
- package/cjs/navigation/styles/navigation.module.css +98 -81
- package/cjs/navigation/use-navigation-flyout.js +39 -0
- package/cjs/navigation/use-navigation-panel-stages.js +23 -0
- package/cjs/navigation/use-navigation-row.js +39 -0
- package/cjs/pagination/styles.module.css +2 -2
- package/cjs/pin-input/styles.module.css +2 -2
- package/cjs/progress-bar/styles.module.css +1 -1
- package/cjs/quantity-input/styles.module.css +3 -3
- package/cjs/radio/styles.module.css +4 -5
- package/cjs/radio-group/styles.module.css +1 -1
- package/cjs/segmented-control/styles/segmented-control-item.module.css +9 -9
- package/cjs/segmented-control/styles/segmented-control.module.css +4 -4
- package/cjs/select/components/select-field-multiselect-value.js +2 -2
- package/cjs/select/components/select-field.js +8 -6
- package/cjs/select/components/select-multiselect-panel.js +9 -67
- package/cjs/select/components/select-option-row.js +7 -53
- package/cjs/select/hooks/use-select-multiselect-panel-layout.js +53 -0
- package/cjs/select/hooks/use-select-option-row.js +23 -0
- package/cjs/select/hooks/use-select-view-model.js +3 -1
- package/cjs/select/styles/select-field.module.css +20 -1
- package/cjs/select/styles/select.module.css +2 -2
- package/cjs/select/views/select-view.js +4 -4
- package/cjs/select/views/styles.module.css +1 -1
- package/cjs/snackbar/snack-view.js +9 -42
- package/cjs/snackbar/styles/snack.module.css +1 -1
- package/cjs/snackbar/use-snack-view.js +16 -0
- package/cjs/switch/styles/base.module.css +2 -2
- package/cjs/tabs/styles/tab-list.module.css +1 -1
- package/cjs/tabs/styles/tab.module.css +6 -6
- package/cjs/tabs/tab-list.js +2 -20
- package/cjs/tabs/tab-panel.js +4 -39
- package/cjs/tabs/use-tab-list-navigation.js +27 -0
- package/cjs/tabs/use-tab-panel.js +12 -0
- package/cjs/textarea/styles.module.css +1 -1
- package/cjs/theme-provider/styles.module.css +6 -6
- package/cjs/time-picker/styles.module.css +9 -9
- package/cjs/time-picker/time-panel.js +2 -47
- package/cjs/time-picker/use-time-column-list.js +48 -0
- package/cjs/tooltip/tooltip.js +1 -1
- package/cjs/tree/styles.module.css +5 -5
- package/cjs/tree/tree-row.js +13 -73
- package/cjs/tree/tree-select.module.css +2 -2
- package/cjs/tree/use-tree-row.js +102 -0
- package/cjs/utils/class-names.js +3 -1
- package/date-picker/styles.module.css +10 -10
- package/drawer/styles.module.css +10 -12
- package/file/styles.module.css +3 -4
- package/hint/styles/buttons.module.css +2 -2
- package/hint/styles/hint-content.module.css +3 -3
- package/hint/styles/hint.module.css +2 -2
- package/image/image-viewer.js +3 -13
- package/image/image.js +5 -28
- package/image/use-image-preview.d.ts +10 -0
- package/image/use-image-preview.js +29 -0
- package/image/use-image-viewer.d.ts +8 -0
- package/image/use-image-viewer.js +18 -0
- package/image/viewer.module.css +1 -1
- package/input/fields/use-text-field.d.ts +2 -0
- package/list/list-divider/styles.module.css +2 -2
- package/list/list-item/styles.module.css +2 -2
- package/list/list-section/styles.module.css +4 -4
- package/masked-input/use-mask.d.ts +2 -0
- package/modal/modal.d.ts +1 -0
- package/modal/modal.js +4 -10
- package/modal/styles/_animations.css +2 -2
- package/modal/styles/modal-footer.module.css +3 -3
- package/modal/styles/modal-header.module.css +5 -5
- package/modal/styles/modal.module.css +9 -4
- package/modal/types.d.ts +5 -0
- package/modal/use-modal.d.ts +3 -1
- package/modal/use-modal.js +17 -3
- package/navigation/navigation-compact.d.ts +1 -2
- package/navigation/navigation-compact.js +3 -31
- package/navigation/navigation-row.d.ts +1 -2
- package/navigation/navigation-row.js +6 -33
- package/navigation/navigation-views.js +3 -24
- package/navigation/navigation.d.ts +1 -0
- package/navigation/navigation.js +2 -1
- package/navigation/styles/navigation.module.css +98 -81
- package/navigation/types.d.ts +3 -2
- package/navigation/use-navigation-flyout.d.ts +9 -0
- package/navigation/use-navigation-flyout.js +36 -0
- package/navigation/use-navigation-panel-stages.d.ts +5 -0
- package/navigation/use-navigation-panel-stages.js +20 -0
- package/navigation/use-navigation-row.d.ts +16 -0
- package/navigation/use-navigation-row.js +36 -0
- package/number-input/use-number-input.d.ts +2 -0
- package/package.json +6 -2
- package/pagination/styles.module.css +2 -2
- package/pin-input/styles.module.css +2 -2
- package/popover/types.d.ts +2 -2
- package/progress-bar/styles.module.css +1 -1
- package/quantity-input/styles.module.css +3 -3
- package/radio/styles.module.css +4 -5
- package/radio-group/styles.module.css +1 -1
- package/scss/_functions.scss +12 -24
- package/scss/_grid.scss +2 -2
- package/scss/_index.scss +1 -6
- package/scss/_interaction.scss +3 -3
- package/scss/_mixins.scss +5 -51
- package/scss/_tokens.generated.scss +578 -0
- package/scss/_tokens.scss +2 -396
- package/scss/_typography.scss +0 -1
- package/segmented-control/styles/segmented-control-item.module.css +9 -9
- package/segmented-control/styles/segmented-control.module.css +4 -4
- package/select/components/select-field-multiselect-value.d.ts +1 -0
- package/select/components/select-field-multiselect-value.js +2 -2
- package/select/components/select-field.d.ts +3 -1
- package/select/components/select-field.js +8 -6
- package/select/components/select-multiselect-panel.d.ts +3 -1
- package/select/components/select-multiselect-panel.js +8 -66
- package/select/components/select-option-row.js +7 -20
- package/select/hooks/use-select-multiselect-panel-layout.d.ts +14 -0
- package/select/hooks/use-select-multiselect-panel-layout.js +49 -0
- package/select/hooks/use-select-option-row.d.ts +13 -0
- package/select/hooks/use-select-option-row.js +20 -0
- package/select/hooks/use-select-view-model.d.ts +4 -2
- package/select/hooks/use-select-view-model.js +3 -1
- package/select/select.d.ts +3 -2
- package/select/styles/select-field.module.css +20 -1
- package/select/styles/select.module.css +2 -2
- package/select/types.d.ts +6 -3
- package/select/views/select-view.js +4 -4
- package/select/views/styles.module.css +1 -1
- package/snackbar/snack-view.js +7 -7
- package/snackbar/styles/snack.module.css +1 -1
- package/snackbar/use-snack-view.d.ts +8 -0
- package/snackbar/use-snack-view.js +13 -0
- package/switch/styles/base.module.css +2 -2
- package/tabs/styles/tab-list.module.css +1 -1
- package/tabs/styles/tab.module.css +6 -6
- package/tabs/tab-list.js +4 -22
- package/tabs/tab-panel.js +4 -6
- package/tabs/use-tab-list-navigation.d.ts +2 -0
- package/tabs/use-tab-list-navigation.js +24 -0
- package/tabs/use-tab-panel.d.ts +6 -0
- package/tabs/use-tab-panel.js +9 -0
- package/textarea/styles.module.css +1 -1
- package/theme-provider/styles.module.css +6 -6
- package/time-picker/styles.module.css +9 -9
- package/time-picker/time-panel.js +2 -47
- package/time-picker/use-time-column-list.d.ts +7 -0
- package/time-picker/use-time-column-list.js +45 -0
- package/tooltip/tooltip.js +1 -1
- package/tree/styles.module.css +5 -5
- package/tree/tree-row.js +15 -75
- package/tree/tree-select.module.css +2 -2
- package/tree/use-tree-row.d.ts +331 -0
- package/tree/use-tree-row.js +99 -0
- package/utils/class-names.d.ts +1 -1
- package/utils/class-names.js +3 -1
|
@@ -1,94 +1,36 @@
|
|
|
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, {
|
|
4
|
+
import React, { useMemo, useRef } from 'react';
|
|
5
5
|
import { CHIPS_NAV_ATTR, useChipsNav } from '../../_internal/hooks';
|
|
6
6
|
import { Button } from '../../button';
|
|
7
|
-
import { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';
|
|
8
7
|
import { Icon } from '../../icon';
|
|
9
8
|
import { ArrowIcon, DelIcon } from '../../icons';
|
|
10
9
|
import { useLocale } from '../../locale/use-locale';
|
|
10
|
+
import { Typography } from '../../typography';
|
|
11
11
|
import { useAutoScrollToBottom } from '../hooks/use-auto-scroll-to-bottom';
|
|
12
12
|
import { useChipsLayout } from '../hooks/use-chips-row-count';
|
|
13
13
|
import { useSelectVirtual } from '../hooks/use-select-virtual';
|
|
14
|
+
import { useAutoDecideChipsOverflow, useContentAreaHeight, } from '../hooks/use-select-multiselect-panel-layout';
|
|
14
15
|
import styles from '../styles/select.module.css';
|
|
15
16
|
import { getOptionText } from '../utils/filter-options';
|
|
16
17
|
import { getStatusContent } from '../utils/get-status-content';
|
|
17
18
|
import { retainComboboxFocusOnMouseDown } from '../utils/retain-combobox-focus';
|
|
18
19
|
import { SelectOptionList } from './select-option-list';
|
|
19
20
|
import { SelectPanelStatus } from './select-panel-status';
|
|
20
|
-
/**
|
|
21
|
-
* `chipsExpandedMode="auto"`: панель открывается развёрнутой, чтобы измерить реальное число строк
|
|
22
|
-
* (см. `useSelectMultiselectPanelState`), и здесь по факту overflow решает — оставить развёрнутой
|
|
23
|
-
* или свернуть. Решение принимается один раз за сессию открытия, дальше чипсы можно переключать вручную.
|
|
24
|
-
*/
|
|
25
|
-
function useAutoDecideChipsOverflow({ open, chipsExpandedMode, showChipsArea, chipsFullMode, chipsRowCount, chipsNumericMaxRows, onChipsOverflow, }) {
|
|
26
|
-
const autoDecidedRef = useRef(false);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!open) {
|
|
29
|
-
autoDecidedRef.current = false;
|
|
30
|
-
}
|
|
31
|
-
}, [open]);
|
|
32
|
-
useIsomorphicLayoutEffect(() => {
|
|
33
|
-
if (!open || chipsExpandedMode !== 'auto' || autoDecidedRef.current || !showChipsArea) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (chipsFullMode) {
|
|
37
|
-
autoDecidedRef.current = true;
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (chipsRowCount === 0) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
autoDecidedRef.current = true;
|
|
44
|
-
if (chipsNumericMaxRows !== undefined && chipsRowCount > chipsNumericMaxRows) {
|
|
45
|
-
onChipsOverflow === null || onChipsOverflow === void 0 ? void 0 : onChipsOverflow();
|
|
46
|
-
}
|
|
47
|
-
}, [
|
|
48
|
-
open,
|
|
49
|
-
chipsExpandedMode,
|
|
50
|
-
showChipsArea,
|
|
51
|
-
chipsFullMode,
|
|
52
|
-
chipsRowCount,
|
|
53
|
-
chipsNumericMaxRows,
|
|
54
|
-
onChipsOverflow,
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
/** Высота области содержимого панели: нужна, чтобы блок чипсов в режиме `'full'` занял всё доступное место */
|
|
58
|
-
function useContentAreaHeight(ref, enabled, remeasureKey) {
|
|
59
|
-
const [height, setHeight] = useState(0);
|
|
60
|
-
useIsomorphicLayoutEffect(() => {
|
|
61
|
-
const contentArea = ref.current;
|
|
62
|
-
if (!enabled || !contentArea) {
|
|
63
|
-
setHeight(0);
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const measure = () => {
|
|
67
|
-
setHeight(contentArea.clientHeight);
|
|
68
|
-
};
|
|
69
|
-
measure();
|
|
70
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const observer = new ResizeObserver(measure);
|
|
74
|
-
observer.observe(contentArea);
|
|
75
|
-
return () => observer.disconnect();
|
|
76
|
-
}, [ref, enabled, remeasureKey]);
|
|
77
|
-
return height;
|
|
78
|
-
}
|
|
79
21
|
/** Какие части шапки панели показывать: заголовок с выбранным, блок чипсов или подпись «ничего не выбрано» */
|
|
80
|
-
function getHeaderVisibility(showPanelHeaderEnabled, hasSelection, chipsExpanded) {
|
|
22
|
+
function getHeaderVisibility(showPanelHeaderEnabled, hasSelection, chipsExpanded, chipsEnabled) {
|
|
81
23
|
const showSelectionHeader = showPanelHeaderEnabled && hasSelection;
|
|
82
24
|
return {
|
|
83
25
|
showPanelHeaderEnabled,
|
|
84
26
|
showSelectionHeader,
|
|
85
|
-
showChipsArea: showSelectionHeader && chipsExpanded,
|
|
27
|
+
showChipsArea: showSelectionHeader && chipsExpanded && chipsEnabled,
|
|
86
28
|
showEmptyLabel: showPanelHeaderEnabled && !hasSelection,
|
|
87
29
|
};
|
|
88
30
|
}
|
|
89
31
|
/** Padding-bottom `.chipsArea` (сверху паддинга нет — см. стили) — учитывается в max-height блока чипсов */
|
|
90
32
|
const CHIPS_AREA_VERTICAL_PADDING = 16;
|
|
91
|
-
export function SelectMultiselectPanel({ id, options, chipOptions, value: selectedValues, onUpdate: onSelect, onRemoveChip, onClear, showPanelHeader = true, chipsExpanded, chipsExpandedMode = 'auto', onToggleChips, onChipsOverflow, emptySelectionLabel: emptySelectionLabelProp, selectedCountLabel: selectedCountLabelProp, collapseLabel: collapseLabelProp, clearLabel: clearLabelProp, size = 'l', className, children, open = true, showLoader, showNotFound, showMinCharsHint, notFoundContent, minCharsContent, loadingContent, activeValue, onOptionMouseMove, onListMouseMove, keyboardNavActive, restoreComboboxFocus, maxHeight = 376, chipsMaxRows = 3, mobile = false, searchActive = false, virtualized, }) {
|
|
33
|
+
export function SelectMultiselectPanel({ id, options, chipOptions, value: selectedValues, onUpdate: onSelect, onRemoveChip, onClear, showPanelHeader = true, chipsEnabled = true, chipsExpanded, chipsExpandedMode = 'auto', onToggleChips, onChipsOverflow, emptySelectionLabel: emptySelectionLabelProp, selectedCountLabel: selectedCountLabelProp, collapseLabel: collapseLabelProp, clearLabel: clearLabelProp, size = 'l', className, children, open = true, showLoader, showNotFound, showMinCharsHint, notFoundContent, minCharsContent, loadingContent, activeValue, onOptionMouseMove, onListMouseMove, keyboardNavActive, restoreComboboxFocus, maxHeight = 376, chipsMaxRows = 3, mobile = false, searchActive = false, virtualized, }) {
|
|
92
34
|
const { t } = useLocale();
|
|
93
35
|
const emptySelectionLabel = emptySelectionLabelProp !== null && emptySelectionLabelProp !== void 0 ? emptySelectionLabelProp : t('select.emptySelection');
|
|
94
36
|
const selectedCountLabel = selectedCountLabelProp !== null && selectedCountLabelProp !== void 0 ? selectedCountLabelProp : ((count) => t('select.selectedCount', { count }));
|
|
@@ -120,7 +62,7 @@ export function SelectMultiselectPanel({ id, options, chipOptions, value: select
|
|
|
120
62
|
const onPanelMouseDownCapture = (event) => {
|
|
121
63
|
retainComboboxFocusOnMouseDown(event);
|
|
122
64
|
};
|
|
123
|
-
const { showPanelHeaderEnabled, showSelectionHeader, showChipsArea, showEmptyLabel } = getHeaderVisibility(showPanelHeader !== false, selectedOptions.length > 0, chipsExpanded);
|
|
65
|
+
const { showPanelHeaderEnabled, showSelectionHeader, showChipsArea, showEmptyLabel } = getHeaderVisibility(showPanelHeader !== false, selectedOptions.length > 0, chipsExpanded, chipsEnabled);
|
|
124
66
|
const showStatus = showLoader || showNotFound || showMinCharsHint;
|
|
125
67
|
const statusContent = getStatusContent({
|
|
126
68
|
loading: showLoader,
|
|
@@ -159,5 +101,5 @@ export function SelectMultiselectPanel({ id, options, chipOptions, value: select
|
|
|
159
101
|
return (_jsxs("div", { id: id, ref: panelRef, className: clsx(styles.panel, mobile && styles.panelMobile, !showPanelHeaderEnabled && styles.panelFit, className),
|
|
160
102
|
// С шапкой и чипсами высота фиксирована: при сворачивании чипсов панель не должна прыгать. Без шапки
|
|
161
103
|
// (`chipsVariant="none"`) панель по высоте списка — без пустого места под вариантами
|
|
162
|
-
style: showPanelHeaderEnabled ? { height: maxHeight } : { maxHeight }, onKeyDown: onChipsKeyDown, onMouseDownCapture: onPanelMouseDownCapture, onClickCapture: onPanelClickCapture, children: [showSelectionHeader && (_jsxs("div", { className: clsx(styles.panelHeader, showHeaderDivider && styles.panelHeaderDivider), children: [_jsx(Button, { type: "button", size: "m", variant: "link-secondary", iconRight: _jsx(ArrowIcon, { direction: headerCollapsed ? 'bottom' : 'top' }), tabIndex: -1, [CHIPS_NAV_ATTR]: '', onClick: onToggleChips, children: headerLabel }), _jsx(Button, { type: "button", size: "m", variant: "link-secondary", iconLeft: _jsx(DelIcon, {}), tabIndex: -1, [CHIPS_NAV_ATTR]: '', onClick: onClear, children: clearLabel })] })), _jsxs("div", { ref: contentAreaRef, className: styles.contentArea, children: [showChipsArea && (_jsx("div", { ref: chipsScrollRef, className: clsx(styles.chipsArea, !chipsFullMode && styles.chipsAreaFixed, chipsFullMode && styles.chipsAreaFull, chipsOverflows && styles.chipsAreaScrollable, showChipsDivider && styles.chipsAreaDivider), style: chipsAreaMaxHeight !== undefined ? { maxHeight: chipsAreaMaxHeight } : undefined, children: _jsx("div", { ref: chipsAreaRef, className: styles.chipsRow, children: selectedOptions.map(option => (_jsxs("span", { className: styles.panelChip, children: [_jsx("span", { className: styles.panelChipText, children: getOptionText(option) }), _jsx("button", { type: "button", className: styles.panelChipRemove, tabIndex: -1, [CHIPS_NAV_ATTR]: '', "aria-label": t('select.remove', { label: getOptionText(option) }), onClick: () => onRemoveChip(option.value), children: _jsx(Icon, { size: 16, color: "text-invert", children: _jsx(DelIcon, {}) }) })] }, String(option.value)))) }) })), showEmptyLabel && !showStatus && !searchActive && (_jsx("div", { className: styles.emptySelection, children: emptySelectionLabel })), _jsxs("div", { className: styles.listSection, children: [!showChipsArea && _jsx("div", { className: styles.listPaddingTop }), _jsx("div", { ref: virtual.enabled ? virtual.scrollRef : undefined, className: styles.listWrapFill, children: listContent }), _jsx("div", { className: styles.listPaddingBottom })] })] })] }));
|
|
104
|
+
style: showPanelHeaderEnabled ? { height: maxHeight } : { maxHeight }, onKeyDown: onChipsKeyDown, onMouseDownCapture: onPanelMouseDownCapture, onClickCapture: onPanelClickCapture, children: [showSelectionHeader && (_jsxs("div", { className: clsx(styles.panelHeader, showHeaderDivider && styles.panelHeaderDivider), children: [chipsEnabled ? (_jsx(Button, { type: "button", size: "m", variant: "link-secondary", iconRight: _jsx(ArrowIcon, { direction: headerCollapsed ? 'bottom' : 'top' }), tabIndex: -1, [CHIPS_NAV_ATTR]: '', onClick: onToggleChips, children: headerLabel })) : (_jsx(Typography, { variant: "body-s-compact", color: "text-secondary", children: selectedCountLabel(selectedOptions.length) })), _jsx(Button, { type: "button", size: "m", variant: "link-secondary", iconLeft: _jsx(DelIcon, {}), tabIndex: -1, [CHIPS_NAV_ATTR]: '', onClick: onClear, children: clearLabel })] })), _jsxs("div", { ref: contentAreaRef, className: styles.contentArea, children: [showChipsArea && (_jsx("div", { ref: chipsScrollRef, className: clsx(styles.chipsArea, !chipsFullMode && styles.chipsAreaFixed, chipsFullMode && styles.chipsAreaFull, chipsOverflows && styles.chipsAreaScrollable, showChipsDivider && styles.chipsAreaDivider), style: chipsAreaMaxHeight !== undefined ? { maxHeight: chipsAreaMaxHeight } : undefined, children: _jsx("div", { ref: chipsAreaRef, className: styles.chipsRow, children: selectedOptions.map(option => (_jsxs("span", { className: styles.panelChip, children: [_jsx("span", { className: styles.panelChipText, children: getOptionText(option) }), _jsx("button", { type: "button", className: styles.panelChipRemove, tabIndex: -1, [CHIPS_NAV_ATTR]: '', "aria-label": t('select.remove', { label: getOptionText(option) }), onClick: () => onRemoveChip(option.value), children: _jsx(Icon, { size: 16, color: "text-invert", children: _jsx(DelIcon, {}) }) })] }, String(option.value)))) }) })), showEmptyLabel && !showStatus && !searchActive && (_jsx("div", { className: styles.emptySelection, children: emptySelectionLabel })), _jsxs("div", { className: styles.listSection, children: [!showChipsArea && _jsx("div", { className: styles.listPaddingTop }), _jsx("div", { ref: virtual.enabled ? virtual.scrollRef : undefined, className: styles.listWrapFill, children: listContent }), _jsx("div", { className: styles.listPaddingBottom })] })] })] }));
|
|
163
105
|
}
|
|
@@ -1,37 +1,24 @@
|
|
|
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
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import { Icon } from '../../icon';
|
|
6
6
|
import { ListIcon } from '../../list/list-item/list-icon';
|
|
7
7
|
import { Typography } from '../../typography';
|
|
8
8
|
import { useSelectClassNames } from '../class-names-context';
|
|
9
9
|
import styles from '../styles/select.module.css';
|
|
10
10
|
import { getSelectOptionElementId } from '../utils/select-option-id';
|
|
11
|
+
import { useSelectOptionRow } from '../hooks/use-select-option-row';
|
|
11
12
|
export function SelectOptionRow({ value, text, description, selected = false, active = false, disabled = false, showSelectionIcon = true, size = 'l', setSize, posInSet, onSelect, onMouseMove, }) {
|
|
12
13
|
const classNames = useSelectClassNames();
|
|
13
14
|
const iconSize = size === 'm' ? 20 : 24;
|
|
14
15
|
const textVariant = size === 'l' ? 'body-m' : 'body-s';
|
|
15
16
|
const descriptionVariant = size === 'l' ? 'body-m-compact' : 'body-s-compact';
|
|
16
|
-
const onClick =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const onKeyDown = useCallback((event) => {
|
|
22
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
onClick();
|
|
25
|
-
}
|
|
26
|
-
}, [onClick]);
|
|
27
|
-
const onOptionMouseDown = useCallback((event) => {
|
|
28
|
-
event.preventDefault();
|
|
29
|
-
}, []);
|
|
30
|
-
const onOptionMouseMove = useCallback(() => {
|
|
31
|
-
if (!disabled) {
|
|
32
|
-
onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove();
|
|
33
|
-
}
|
|
34
|
-
}, [disabled, onMouseMove]);
|
|
17
|
+
const { onClick, onKeyDown, onOptionMouseDown, onOptionMouseMove } = useSelectOptionRow({
|
|
18
|
+
disabled,
|
|
19
|
+
onSelect,
|
|
20
|
+
onMouseMove,
|
|
21
|
+
});
|
|
35
22
|
return (_jsxs("li", { "data-lt-ui": "select-option", id: getSelectOptionElementId(value), role: "option", tabIndex: -1, "aria-selected": selected, "aria-disabled": disabled, "aria-setsize": setSize, "aria-posinset": posInSet, className: clsx(styles.optionRow, styles[`optionRow_${size}`], {
|
|
36
23
|
[styles.optionRowDisabled]: disabled,
|
|
37
24
|
[styles.optionRowActive]: active,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { ChipsExpandedMode } from './use-select-multiselect-panel-state';
|
|
3
|
+
type AutoDecideParams = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
chipsExpandedMode: ChipsExpandedMode;
|
|
6
|
+
showChipsArea: boolean;
|
|
7
|
+
chipsFullMode: boolean;
|
|
8
|
+
chipsRowCount: number;
|
|
9
|
+
chipsNumericMaxRows?: number;
|
|
10
|
+
onChipsOverflow?: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function useAutoDecideChipsOverflow({ open, chipsExpandedMode, showChipsArea, chipsFullMode, chipsRowCount, chipsNumericMaxRows, onChipsOverflow, }: AutoDecideParams): void;
|
|
13
|
+
export declare function useContentAreaHeight(ref: RefObject<HTMLDivElement | null>, enabled: boolean, remeasureKey: string): number;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';
|
|
4
|
+
export function useAutoDecideChipsOverflow({ open, chipsExpandedMode, showChipsArea, chipsFullMode, chipsRowCount, chipsNumericMaxRows, onChipsOverflow, }) {
|
|
5
|
+
const autoDecidedRef = useRef(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!open)
|
|
8
|
+
autoDecidedRef.current = false;
|
|
9
|
+
}, [open]);
|
|
10
|
+
useIsomorphicLayoutEffect(() => {
|
|
11
|
+
if (!open || chipsExpandedMode !== 'auto' || autoDecidedRef.current || !showChipsArea)
|
|
12
|
+
return;
|
|
13
|
+
if (chipsFullMode) {
|
|
14
|
+
autoDecidedRef.current = true;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (chipsRowCount === 0)
|
|
18
|
+
return;
|
|
19
|
+
autoDecidedRef.current = true;
|
|
20
|
+
if (chipsNumericMaxRows !== undefined && chipsRowCount > chipsNumericMaxRows)
|
|
21
|
+
onChipsOverflow === null || onChipsOverflow === void 0 ? void 0 : onChipsOverflow();
|
|
22
|
+
}, [
|
|
23
|
+
open,
|
|
24
|
+
chipsExpandedMode,
|
|
25
|
+
showChipsArea,
|
|
26
|
+
chipsFullMode,
|
|
27
|
+
chipsRowCount,
|
|
28
|
+
chipsNumericMaxRows,
|
|
29
|
+
onChipsOverflow,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
export function useContentAreaHeight(ref, enabled, remeasureKey) {
|
|
33
|
+
const [height, setHeight] = useState(0);
|
|
34
|
+
useIsomorphicLayoutEffect(() => {
|
|
35
|
+
const contentArea = ref.current;
|
|
36
|
+
if (!enabled || !contentArea) {
|
|
37
|
+
setHeight(0);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const measure = () => setHeight(contentArea.clientHeight);
|
|
41
|
+
measure();
|
|
42
|
+
if (typeof ResizeObserver === 'undefined')
|
|
43
|
+
return undefined;
|
|
44
|
+
const observer = new ResizeObserver(measure);
|
|
45
|
+
observer.observe(contentArea);
|
|
46
|
+
return () => observer.disconnect();
|
|
47
|
+
}, [ref, enabled, remeasureKey]);
|
|
48
|
+
return height;
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
+
type Params = {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
onSelect?: () => void;
|
|
5
|
+
onMouseMove?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function useSelectOptionRow({ disabled, onSelect, onMouseMove }: Params): {
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
onKeyDown: (event: KeyboardEvent<HTMLLIElement>) => void;
|
|
10
|
+
onOptionMouseDown: (event: MouseEvent<HTMLLIElement>) => void;
|
|
11
|
+
onOptionMouseMove: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
export function useSelectOptionRow({ disabled, onSelect, onMouseMove }) {
|
|
4
|
+
const onClick = useCallback(() => {
|
|
5
|
+
if (!disabled)
|
|
6
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
7
|
+
}, [disabled, onSelect]);
|
|
8
|
+
const onKeyDown = useCallback((event) => {
|
|
9
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
10
|
+
return;
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
onClick();
|
|
13
|
+
}, [onClick]);
|
|
14
|
+
const onOptionMouseDown = useCallback((event) => event.preventDefault(), []);
|
|
15
|
+
const onOptionMouseMove = useCallback(() => {
|
|
16
|
+
if (!disabled)
|
|
17
|
+
onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove();
|
|
18
|
+
}, [disabled, onMouseMove]);
|
|
19
|
+
return { onClick, onKeyDown, onOptionMouseDown, onOptionMouseMove };
|
|
20
|
+
}
|
|
@@ -5,9 +5,11 @@ export type SelectViewModel = ReturnType<typeof useSelectViewModel>;
|
|
|
5
5
|
export declare function useSelectViewModel(props: SelectProps, ref: React.Ref<SelectHandle>): {
|
|
6
6
|
readonly testId: string;
|
|
7
7
|
readonly dataProps: import("../..").DataAttributes;
|
|
8
|
+
readonly ariaLabel: any;
|
|
8
9
|
readonly select: import("..").UseSelectReturn<string | number>;
|
|
9
10
|
readonly isMultiple: boolean;
|
|
10
11
|
readonly label: string | undefined;
|
|
12
|
+
readonly startAdornment: import("react").ReactNode;
|
|
11
13
|
readonly status: import("../..").FieldStatus | undefined;
|
|
12
14
|
readonly theme: import("../..").ThemeSetting | undefined;
|
|
13
15
|
readonly caption: import("react").ReactNode;
|
|
@@ -20,12 +22,12 @@ export declare function useSelectViewModel(props: SelectProps, ref: React.Ref<Se
|
|
|
20
22
|
readonly selectedValueText: string | undefined;
|
|
21
23
|
readonly hasValue: boolean;
|
|
22
24
|
readonly popoverClassName: string | undefined;
|
|
23
|
-
readonly dropdownWidth: "content" | "field";
|
|
25
|
+
readonly dropdownWidth: number | "content" | "field";
|
|
24
26
|
readonly placement: import("../..").PopoverPlacement;
|
|
25
27
|
readonly container: import("../..").PortalContainer | undefined;
|
|
26
28
|
readonly children: import("react").ReactNode;
|
|
27
29
|
readonly presentation: import("../../_internal/picker").PickerPresentation;
|
|
28
|
-
readonly variant: "underline" | "outline";
|
|
30
|
+
readonly variant: "underline" | "outline" | "trigger";
|
|
29
31
|
readonly listSize: "m" | "l";
|
|
30
32
|
readonly onOpen: () => void;
|
|
31
33
|
readonly onToggle: () => void;
|
|
@@ -8,7 +8,7 @@ import { normalizeSelectedValues } from '../utils/normalize-value';
|
|
|
8
8
|
import { useSelect } from './use-select';
|
|
9
9
|
import { useSelectMultiselectPanelState } from './use-select-multiselect-panel-state';
|
|
10
10
|
export function useSelectViewModel(props, ref) {
|
|
11
|
-
const { value, defaultValue, onUpdate, mode, options, showSearch, strict, filterOption, disabled, open, defaultOpen, onOpenChange, allowClear: allowClearProp, placeholder, searchValue, onSearch, searchDelay, closeOnSelect, clearSearchOnSelect, loading, fetching, minCharsToSearch, notFoundContent, minCharsContent, loadingContent, onListScroll: onListScrollProp, hasMore = false, onLoadMore, chipsVariant = 'none', defaultChipsExpanded = false, chipsExpandedMode = 'auto', showPanelHeader: showPanelHeaderProp, hideHeaderOnSearch = false, emptySelectionLabel, selectedCountLabel, overflowSelectedLabel, collapseLabel, clearLabel, dropdownMaxHeight, virtualized, multiselectChipsMaxRows, label, status, theme, caption, mobile, variant: variantProp, fullWidth, className, size: sizeProp, popoverClassName, dropdownWidth = 'field', placement = 'bottom-start', container, children, 'data-testid': testId = 'select', } = props;
|
|
11
|
+
const { value, defaultValue, onUpdate, mode, options, showSearch, strict, filterOption, disabled, open, defaultOpen, onOpenChange, allowClear: allowClearProp, placeholder, searchValue, onSearch, searchDelay, closeOnSelect, clearSearchOnSelect, loading, fetching, minCharsToSearch, notFoundContent, minCharsContent, loadingContent, onListScroll: onListScrollProp, hasMore = false, onLoadMore, chipsVariant = 'none', defaultChipsExpanded = false, chipsExpandedMode = 'auto', showPanelHeader: showPanelHeaderProp, hideHeaderOnSearch = false, emptySelectionLabel, selectedCountLabel, overflowSelectedLabel, collapseLabel, clearLabel, dropdownMaxHeight, virtualized, multiselectChipsMaxRows, label, startAdornment, status, theme, caption, mobile, variant: variantProp, fullWidth, className, size: sizeProp, popoverClassName, dropdownWidth = 'field', placement = 'bottom-start', container, children, 'data-testid': testId = 'select', } = props;
|
|
12
12
|
// Подгрузка порциями: `onLoadMore` вызывается при прокрутке списка к концу, пока `hasMore` и не `fetching`
|
|
13
13
|
const loadMore = useLoadMore({
|
|
14
14
|
hasMore,
|
|
@@ -117,9 +117,11 @@ export function useSelectViewModel(props, ref) {
|
|
|
117
117
|
return {
|
|
118
118
|
testId,
|
|
119
119
|
dataProps: getDataAttributes(props),
|
|
120
|
+
ariaLabel: props['aria-label'],
|
|
120
121
|
select,
|
|
121
122
|
isMultiple,
|
|
122
123
|
label,
|
|
124
|
+
startAdornment,
|
|
123
125
|
status,
|
|
124
126
|
theme,
|
|
125
127
|
caption,
|
package/select/select.d.ts
CHANGED
|
@@ -10,14 +10,15 @@ export declare const Select: React.ForwardRefExoticComponent<import("..").DataAt
|
|
|
10
10
|
theme?: import("..").ThemeSetting;
|
|
11
11
|
caption?: React.ReactNode;
|
|
12
12
|
mobile?: import("../_internal/picker").PickerMobile;
|
|
13
|
-
variant?: "outline" | "underline";
|
|
13
|
+
variant?: "outline" | "underline" | "trigger";
|
|
14
|
+
startAdornment?: React.ReactNode;
|
|
14
15
|
fullWidth?: boolean;
|
|
15
16
|
className?: string;
|
|
16
17
|
id?: string;
|
|
17
18
|
size?: import("./components/select-field").SelectFieldSize;
|
|
18
19
|
popoverClassName?: string;
|
|
19
20
|
classNames?: import("..").ComponentClassNames<"Select">;
|
|
20
|
-
dropdownWidth?: "field" | "content";
|
|
21
|
+
dropdownWidth?: "field" | "content" | number;
|
|
21
22
|
placement?: import("..").PopoverPlacement;
|
|
22
23
|
children?: React.ReactNode;
|
|
23
24
|
'data-testid'?: string;
|
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
--input-right-padding: var(--space-16);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
.trigger {
|
|
7
|
+
border-radius: var(--rounding-m);
|
|
8
|
+
}
|
|
9
|
+
.trigger > [aria-hidden=true] {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
@media (hover: hover) and (min-width: 768px) {
|
|
13
|
+
.trigger:hover {
|
|
14
|
+
background: var(--background-secondary);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.trigger:active {
|
|
18
|
+
background: var(--background-secondary);
|
|
19
|
+
}
|
|
20
|
+
.trigger:focus-within {
|
|
21
|
+
outline: 2px solid var(--control-primary);
|
|
22
|
+
outline-offset: 2px;
|
|
23
|
+
}
|
|
24
|
+
|
|
6
25
|
.selectRoot_withClear {
|
|
7
26
|
--field-cross-w: 24px;
|
|
8
27
|
}
|
|
@@ -45,7 +64,7 @@
|
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
.selectValuePlaceholderReveal {
|
|
48
|
-
animation: select-placeholder-reveal
|
|
67
|
+
animation: select-placeholder-reveal 0.1s ease-in-out 0.12s both;
|
|
49
68
|
}
|
|
50
69
|
|
|
51
70
|
@keyframes select-placeholder-reveal {
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
gap: 6px;
|
|
112
112
|
align-items: center;
|
|
113
113
|
max-width: 100%;
|
|
114
|
-
padding: 6px
|
|
114
|
+
padding: 6px var(--space-8) 6px var(--space-12);
|
|
115
115
|
color: var(--text-invert);
|
|
116
116
|
background: var(--control-primary);
|
|
117
117
|
border: none;
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
line-height: 1.2307692308;
|
|
447
447
|
letter-spacing: 0.25px;
|
|
448
448
|
display: block;
|
|
449
|
-
padding:
|
|
449
|
+
padding: var(--space-8) var(--space-16) var(--space-4);
|
|
450
450
|
color: var(--text-minor);
|
|
451
451
|
}
|
|
452
452
|
|
package/select/types.d.ts
CHANGED
|
@@ -325,7 +325,9 @@ export type SelectProps<T extends ItemValue = ItemValue> = DataAttributes & (Use
|
|
|
325
325
|
* Вид поля: рамка или подчёркивание, как у `Input`. Не зависит от `mobile`; без значения в шторке поле
|
|
326
326
|
* подчёркнутое, рядом со списком — с рамкой.
|
|
327
327
|
*/
|
|
328
|
-
variant?: 'outline' | 'underline';
|
|
328
|
+
variant?: 'outline' | 'underline' | 'trigger';
|
|
329
|
+
/** Иконка или другой элемент перед значением. */
|
|
330
|
+
startAdornment?: ReactNode;
|
|
329
331
|
/**
|
|
330
332
|
* Растянуть поле на всю ширину контейнера. Без него у всех полей одна ширина по умолчанию
|
|
331
333
|
* (`--field-default-width`, 240px); у `Input` с `htmlSize` ширина считается по символам.
|
|
@@ -346,10 +348,11 @@ export type SelectProps<T extends ItemValue = ItemValue> = DataAttributes & (Use
|
|
|
346
348
|
/** Свои классы для частей компонента (список — в таблице «Классы» на странице документации) */
|
|
347
349
|
classNames?: ComponentClassNames<'Select'>;
|
|
348
350
|
/**
|
|
349
|
-
* Ширина выпадающей панели: `field` — как у поля, `content` — не уже поля, по самому длинному варианту без
|
|
351
|
+
* Ширина выпадающей панели: `field` — как у поля, `content` — не уже поля, по самому длинному варианту без переноса;
|
|
352
|
+
* число задаёт фиксированную ширину в пикселях (на узком экране панель ограничивается шириной окна).
|
|
350
353
|
* @default 'field'
|
|
351
354
|
*/
|
|
352
|
-
dropdownWidth?: 'field' | 'content';
|
|
355
|
+
dropdownWidth?: 'field' | 'content' | number;
|
|
353
356
|
/**
|
|
354
357
|
* Позиционирование выпадающей панели относительно поля
|
|
355
358
|
* @default 'bottom-start'
|
|
@@ -18,7 +18,7 @@ import viewStyles from './styles.module.css';
|
|
|
18
18
|
const SHEET_MULTISELECT_HEIGHT = 'calc(90dvh - 230px)';
|
|
19
19
|
export function SelectView({ vm }) {
|
|
20
20
|
var _a;
|
|
21
|
-
const { testId, select, isMultiple, label, status, theme, caption, placeholder, disabled, fullWidth, className, size, fieldDisplayValue, selectedValueText, hasValue, popoverClassName, dropdownWidth, placement, container, children, presentation, variant, listSize, onOpen, onToggle, onSearchChange, onClear, onRemoveChip, onToggleChips, onChipsOverflow, chipsVariant, showPanelHeader, multiselectPanel, emptySelectionLabel, selectedCountLabel, overflowSelectedLabel, collapseLabel, clearLabel, dropdownMaxHeight, virtualized, multiselectChipsMaxRows, selectedArray, onListScroll, fetching, } = vm;
|
|
21
|
+
const { testId, select, isMultiple, label, ariaLabel, startAdornment, status, theme, caption, placeholder, disabled, fullWidth, className, size, fieldDisplayValue, selectedValueText, hasValue, popoverClassName, dropdownWidth, placement, container, children, presentation, variant, listSize, onOpen, onToggle, onSearchChange, onClear, onRemoveChip, onToggleChips, onChipsOverflow, chipsVariant, showPanelHeader, multiselectPanel, emptySelectionLabel, selectedCountLabel, overflowSelectedLabel, collapseLabel, clearLabel, dropdownMaxHeight, virtualized, multiselectChipsMaxRows, selectedArray, onListScroll, fetching, } = vm;
|
|
22
22
|
const { t } = useLocale();
|
|
23
23
|
const sheet = presentation !== 'popup';
|
|
24
24
|
const classNames = useSelectClassNames();
|
|
@@ -39,10 +39,10 @@ export function SelectView({ vm }) {
|
|
|
39
39
|
popupRef,
|
|
40
40
|
inputRef: select.inputRef,
|
|
41
41
|
});
|
|
42
|
-
const field = (_jsx(SelectField, { ref: activatorRef, label: label, placeholder: placeholder, displayValue: fieldDisplayValue, mode: select.mode, multiselectLabels: select.multiselectDisplayLabels, chipsVariant: chipsVariant, open: select.open, disabled: disabled, status: status, theme: theme, filled: hasValue, size: size, variant: variant, fullWidth: fullWidth,
|
|
42
|
+
const field = (_jsx(SelectField, { ref: activatorRef, label: label, "aria-label": ariaLabel, startAdornment: startAdornment, placeholder: placeholder, displayValue: fieldDisplayValue, mode: select.mode, multiselectLabels: select.multiselectDisplayLabels, chipsVariant: chipsVariant, open: select.open, disabled: disabled, status: status, theme: theme, filled: hasValue, size: size, variant: variant, fullWidth: fullWidth,
|
|
43
43
|
// В шторке поле только открывает её: запрос вводят в строке поиска шторки, иначе клавиатура закрыла бы список
|
|
44
44
|
showSearch: select.showSearch && !sheet, searchValue: select.searchValue, selectedValueText: selectedValueText, onSearchChange: onSearchChange, onOpen: onOpen, onToggle: onToggle, overflowSelectedLabel: overflowSelectedLabel, allowClear: select.allowClear, onClear: onClear, caption: caption, className: className, listboxId: select.listboxId, controlRef: select.inputRef, activeDescendantId: select.activeOptionId, onComboboxKeyDown: select.onComboboxKeyDown }));
|
|
45
|
-
const panel = isMultiple ? (_jsx(SelectMultiselectPanel, { id: select.listboxId, options: select.listOptions, chipOptions: select.options, searchActive: !!select.searchValue, value: selectedArray, onUpdate: select.handleSelect, onRemoveChip: onRemoveChip, onClear: onClear, showPanelHeader: showPanelHeader, chipsExpanded: multiselectPanel.chipsExpanded, chipsExpandedMode: multiselectPanel.mode, onToggleChips: onToggleChips, onChipsOverflow: onChipsOverflow, emptySelectionLabel: emptySelectionLabel, selectedCountLabel: selectedCountLabel, collapseLabel: collapseLabel, clearLabel: clearLabel, virtualized: virtualized, chipsMaxRows: multiselectChipsMaxRows, size: listSize, open: select.open, showLoader: select.showLoader, showNotFound: select.showNotFound, showMinCharsHint: select.showMinCharsHint, notFoundContent: select.notFoundContent, minCharsContent: select.minCharsContent, loadingContent: select.loadingContent, className: panelClassName, activeValue: select.activeOptionValue, onOptionMouseMove: select.onOptionMouseMove, onListMouseMove: select.onListMouseMove, keyboardNavActive: select.keyboardNavActive, restoreComboboxFocus: select.restoreComboboxFocus, maxHeight: sheet ? SHEET_MULTISELECT_HEIGHT : dropdownMaxHeight, mobile: sheet, children: children })) : (_jsx(SelectSinglePanel, { id: select.listboxId, selectionMode: "single", value: select.selectedValues, onUpdate: select.handleSelect, options: select.listOptions, size: listSize, open: select.open, showNotFound: select.showNotFound, showMinCharsHint: select.showMinCharsHint, notFoundContent: select.notFoundContent, minCharsContent: select.minCharsContent, loadingContent: select.loadingContent, loading: select.loading, fetching: fetching, maxHeight: sheet ? 'none' : dropdownMaxHeight, virtualized: virtualized, onListScroll: onListScroll, activeValue: select.activeOptionValue, onOptionMouseMove: select.onOptionMouseMove, onListMouseMove: select.onListMouseMove, keyboardNavActive: select.keyboardNavActive, className: panelClassName, mobile: sheet, children: children }));
|
|
45
|
+
const panel = isMultiple ? (_jsx(SelectMultiselectPanel, { id: select.listboxId, options: select.listOptions, chipOptions: select.options, searchActive: !!select.searchValue, value: selectedArray, onUpdate: select.handleSelect, onRemoveChip: onRemoveChip, onClear: onClear, showPanelHeader: showPanelHeader, chipsEnabled: chipsVariant === 'inside', chipsExpanded: multiselectPanel.chipsExpanded, chipsExpandedMode: multiselectPanel.mode, onToggleChips: onToggleChips, onChipsOverflow: onChipsOverflow, emptySelectionLabel: emptySelectionLabel, selectedCountLabel: selectedCountLabel, collapseLabel: collapseLabel, clearLabel: clearLabel, virtualized: virtualized, chipsMaxRows: multiselectChipsMaxRows, size: listSize, open: select.open, showLoader: select.showLoader, showNotFound: select.showNotFound, showMinCharsHint: select.showMinCharsHint, notFoundContent: select.notFoundContent, minCharsContent: select.minCharsContent, loadingContent: select.loadingContent, className: panelClassName, activeValue: select.activeOptionValue, onOptionMouseMove: select.onOptionMouseMove, onListMouseMove: select.onListMouseMove, keyboardNavActive: select.keyboardNavActive, restoreComboboxFocus: select.restoreComboboxFocus, maxHeight: sheet ? SHEET_MULTISELECT_HEIGHT : dropdownMaxHeight, mobile: sheet, children: children })) : (_jsx(SelectSinglePanel, { id: select.listboxId, selectionMode: "single", value: select.selectedValues, onUpdate: select.handleSelect, options: select.listOptions, size: listSize, open: select.open, showNotFound: select.showNotFound, showMinCharsHint: select.showMinCharsHint, notFoundContent: select.notFoundContent, minCharsContent: select.minCharsContent, loadingContent: select.loadingContent, loading: select.loading, fetching: fetching, maxHeight: sheet ? 'none' : dropdownMaxHeight, virtualized: virtualized, onListScroll: onListScroll, activeValue: select.activeOptionValue, onOptionMouseMove: select.onOptionMouseMove, onListMouseMove: select.onListMouseMove, keyboardNavActive: select.keyboardNavActive, className: panelClassName, mobile: sheet, children: children }));
|
|
46
46
|
// Нет ни вариантов, ни статуса (загрузка, «ничего не найдено», подсказка): пустую панель не показываем
|
|
47
47
|
const hasNoPanelContent = !isMultiple &&
|
|
48
48
|
select.listOptions.length === 0 &&
|
|
@@ -60,5 +60,5 @@ export function SelectView({ vm }) {
|
|
|
60
60
|
return (_jsx("div", { ref: select.containerRef, ...vm.dataProps, "data-testid": testId, "data-lt-ui": "select", className: clsx(viewStyles.root, fullWidth && viewStyles.rootFullWidth), children: _jsx(Popover, { "data-testid": getRelatedTestId(testId, 'popup'), anchor: field, open: select.open && !hasNoPanelContent, onOpenChange: open => {
|
|
61
61
|
if (!open)
|
|
62
62
|
onPopoverClose();
|
|
63
|
-
}, trigger: "manual", layer: false, returnFocus: false, arrow: false, matchWidth: dropdownWidth === 'content' ? 'min' : true, placement: placement, offset: 4, container: container, className: viewStyles.selectPopover, children: _jsx("div", { ref: popupRef, role: "presentation", children: panel }) }) }));
|
|
63
|
+
}, trigger: "manual", layer: false, returnFocus: false, arrow: false, matchWidth: dropdownWidth === 'content' ? 'min' : dropdownWidth === 'field' ? true : dropdownWidth, placement: placement, offset: 4, container: container, className: viewStyles.selectPopover, children: _jsx("div", { ref: popupRef, role: "presentation", children: panel }) }) }));
|
|
64
64
|
}
|
package/snackbar/snack-view.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import React
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import { CollapseBox } from '../_internal/collapse-box';
|
|
6
6
|
import { contextProvider, withRef } from '../_internal/compat';
|
|
7
|
-
import { useControllableState } from '../_internal/hooks';
|
|
8
7
|
import { useUniqID } from '../hooks';
|
|
9
8
|
import { Icon } from '../icon';
|
|
10
9
|
import { ArrowIcon } from '../icons';
|
|
@@ -12,6 +11,7 @@ import { useLocale } from '../locale/use-locale';
|
|
|
12
11
|
import { useOppositeTheme, useThemeAttribute } from '../theme-provider/theme-context';
|
|
13
12
|
import { useClassNames } from '../utils';
|
|
14
13
|
import styles from './styles/snack.module.css';
|
|
14
|
+
import { useSnackViewState } from './use-snack-view';
|
|
15
15
|
export const SnackViewContext = React.createContext({});
|
|
16
16
|
const SnackViewProvider = contextProvider(SnackViewContext);
|
|
17
17
|
/** Заливки, цвет текста на которых — `text-invert`: на них схема обратна окружению */
|
|
@@ -36,10 +36,11 @@ export const SnackView = withRef(function SnackView({ className, classNames: cla
|
|
|
36
36
|
const classNames = useClassNames('Snack', classNamesProp);
|
|
37
37
|
const { t } = useLocale();
|
|
38
38
|
const detailsId = useUniqID(5, 'snack-details');
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const { expanded, setExpanded, contextValue } = useSnackViewState({
|
|
40
|
+
variant,
|
|
41
|
+
expanded: expandedProp,
|
|
42
|
+
defaultExpanded,
|
|
43
|
+
onExpandedChange,
|
|
43
44
|
});
|
|
44
45
|
const hasText = header || paragraph;
|
|
45
46
|
const snackClassName = clsx(styles.snack, styles[variant], classNames.root, className);
|
|
@@ -47,7 +48,6 @@ export const SnackView = withRef(function SnackView({ className, classNames: cla
|
|
|
47
48
|
const haveButtonsInHeader = closeButton || (!wideButton && haveChildren);
|
|
48
49
|
const haveButtonsInFooter = haveChildren && (wideButton || closeButton);
|
|
49
50
|
const expandable = expandedContent != null && expandedContent !== false;
|
|
50
|
-
const contextValue = useMemo(() => ({ variant }), [variant]);
|
|
51
51
|
// Заливки с цветом текста `text-invert`: кнопки на них берут схему, обратную окружению (текст остаётся ambient)
|
|
52
52
|
const opposite = useOppositeTheme();
|
|
53
53
|
// Жёлтая заливка одинакова в обеих схемах: кнопки на ней всегда в светлой
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SnackViewProps } from './types';
|
|
2
|
+
export declare function useSnackViewState(props: Pick<SnackViewProps, 'variant' | 'expanded' | 'defaultExpanded' | 'onExpandedChange'>): {
|
|
3
|
+
expanded: boolean;
|
|
4
|
+
setExpanded: (next: boolean) => void;
|
|
5
|
+
contextValue: {
|
|
6
|
+
variant: import("./types").SnackVariant | undefined;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useControllableState } from '../_internal/hooks';
|
|
4
|
+
export function useSnackViewState(props) {
|
|
5
|
+
const { variant, expanded: expandedProp, defaultExpanded, onExpandedChange } = props;
|
|
6
|
+
const [expanded, setExpanded] = useControllableState({
|
|
7
|
+
value: expandedProp,
|
|
8
|
+
defaultValue: defaultExpanded !== null && defaultExpanded !== void 0 ? defaultExpanded : false,
|
|
9
|
+
onChange: onExpandedChange,
|
|
10
|
+
});
|
|
11
|
+
const contextValue = useMemo(() => ({ variant }), [variant]);
|
|
12
|
+
return { expanded, setExpanded, contextValue };
|
|
13
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
@media (pointer: coarse) {
|
|
21
21
|
.switchRoot {
|
|
22
|
-
padding-inline:
|
|
22
|
+
padding-inline: var(--space-4);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
.switchRoot.disabled {
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
.label {
|
|
123
|
-
gap:
|
|
123
|
+
gap: var(--space-12);
|
|
124
124
|
align-items: center;
|
|
125
125
|
}
|
|
126
126
|
.label.labelLeft {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
align-items: center;
|
|
34
34
|
justify-content: center;
|
|
35
35
|
padding-block: var(--tab-padding);
|
|
36
|
-
margin-inline:
|
|
36
|
+
margin-inline: var(--space-8);
|
|
37
37
|
color: var(--lt-ui-tabs-color, var(--text-minor));
|
|
38
38
|
touch-action: manipulation;
|
|
39
39
|
background-color: transparent;
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
|
|
83
83
|
.variant-pills {
|
|
84
84
|
padding-inline: 14px;
|
|
85
|
-
margin-inline:
|
|
85
|
+
margin-inline: var(--space-2);
|
|
86
86
|
border-radius: var(--rounding-circular);
|
|
87
87
|
}
|
|
88
88
|
.variant-pills:not(.divider, .active) {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.variant-enclosed {
|
|
108
|
-
padding-inline:
|
|
108
|
+
padding-inline: var(--space-16);
|
|
109
109
|
margin-inline: 0 -1px;
|
|
110
110
|
background-color: var(--control-minor);
|
|
111
111
|
border: 1px solid var(--control-secondary);
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
.xl {
|
|
154
|
-
--tab-padding:
|
|
154
|
+
--tab-padding: var(--space-12);
|
|
155
155
|
--tab-icon-size: 28px;
|
|
156
156
|
--tab-badge-size: 28px;
|
|
157
157
|
font-size: 27px;
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
.tabIcon {
|
|
181
181
|
width: var(--tab-icon-size);
|
|
182
182
|
height: var(--tab-icon-size);
|
|
183
|
-
margin-inline:
|
|
183
|
+
margin-inline: var(--space-4);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
.tabBadge {
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
justify-content: center;
|
|
190
190
|
min-width: var(--tab-badge-size);
|
|
191
191
|
height: var(--tab-badge-size);
|
|
192
|
-
margin-inline:
|
|
192
|
+
margin-inline: var(--space-4);
|
|
193
193
|
}
|
|
194
194
|
.tabBadge [role=status] {
|
|
195
195
|
opacity: 0.5;
|