@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useNavigationPanelStages = useNavigationPanelStages;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
// Синхронизировано с CSS transition ширины в navigation.module.scss.
|
|
7
|
+
const WIDTH_MS = 220;
|
|
8
|
+
/** Согласует появление дерева пунктов с переходом ширины между рейкой и панелью. */
|
|
9
|
+
function useNavigationPanelStages(rail) {
|
|
10
|
+
const [railSettled, setRailSettled] = (0, react_1.useState)(rail);
|
|
11
|
+
const [branchesOpen, setBranchesOpen] = (0, react_1.useState)(!rail);
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
if (rail) {
|
|
14
|
+
setBranchesOpen(false);
|
|
15
|
+
const timer = setTimeout(() => setRailSettled(true), WIDTH_MS);
|
|
16
|
+
return () => clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
setRailSettled(false);
|
|
19
|
+
const timer = setTimeout(() => setBranchesOpen(true), WIDTH_MS);
|
|
20
|
+
return () => clearTimeout(timer);
|
|
21
|
+
}, [rail]);
|
|
22
|
+
return { showRail: rail && railSettled, branchesClosed: !branchesOpen };
|
|
23
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useNavigationRow = useNavigationRow;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_locale_1 = require("../locale/use-locale");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
const use_overflow_1 = require("./use-overflow");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
/** Подготавливает плоские пункты и состояние переполнения строки навигации. */
|
|
11
|
+
function useNavigationRow({ entries, variant }) {
|
|
12
|
+
const { t } = (0, use_locale_1.useLocale)();
|
|
13
|
+
const { value } = (0, context_1.useNavigationContext)('NavigationRow');
|
|
14
|
+
const listRef = (0, react_1.useRef)(null);
|
|
15
|
+
const flat = (0, utils_1.flattenGroups)(entries).filter(utils_1.isLinkItem);
|
|
16
|
+
// В шапке пункты `placement: 'end'` стоят у правого края; на нижней панели порядок не меняется
|
|
17
|
+
const links = variant === 'bar'
|
|
18
|
+
? [...flat.filter(link => link.placement !== 'end'), ...flat.filter(link => link.placement === 'end')]
|
|
19
|
+
: flat;
|
|
20
|
+
// На нижней панели помещается не больше 5 разделов: остальное сразу в «Ещё»
|
|
21
|
+
const limit = variant === 'bottom' ? 5 : Infinity;
|
|
22
|
+
const base = links.length > limit ? links.length - (limit - 1) : 0;
|
|
23
|
+
const hidden = (0, use_overflow_1.useOverflow)({ listRef, base, max: Math.max(links.length - 1, 0), total: links.length });
|
|
24
|
+
const visibleLinks = hidden > 0 ? links.slice(0, links.length - hidden) : links;
|
|
25
|
+
const hiddenLinks = hidden > 0 ? links.slice(links.length - hidden) : [];
|
|
26
|
+
const more = {
|
|
27
|
+
key: '__more',
|
|
28
|
+
label: t('navigation.more'),
|
|
29
|
+
children: hiddenLinks,
|
|
30
|
+
};
|
|
31
|
+
const moreSelected = hiddenLinks.some(link => link.key === value || hasKey(link, value));
|
|
32
|
+
return { listRef, visibleLinks, hiddenLinks, more, moreSelected };
|
|
33
|
+
}
|
|
34
|
+
function hasKey(item, key) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (key === null)
|
|
37
|
+
return false;
|
|
38
|
+
return ((_a = item.children) !== null && _a !== void 0 ? _a : []).some(child => (0, utils_1.isLinkItem)(child) && (child.key === key || hasKey(child, key)));
|
|
39
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.pagination {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-wrap: wrap;
|
|
4
|
-
gap:
|
|
4
|
+
gap: var(--space-12) var(--space-24);
|
|
5
5
|
align-items: center;
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
width: 100%;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
.pageSize {
|
|
76
76
|
--field-default-width: 96px;
|
|
77
77
|
display: flex;
|
|
78
|
-
gap:
|
|
78
|
+
gap: var(--space-8);
|
|
79
79
|
align-items: center;
|
|
80
80
|
min-width: 96px;
|
|
81
81
|
}
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
--input-transform-left: 7px;
|
|
32
32
|
}
|
|
33
33
|
.input.underline.s {
|
|
34
|
-
--input-left-padding:
|
|
35
|
-
--input-right-padding:
|
|
34
|
+
--input-left-padding: var(--space-4);
|
|
35
|
+
--input-right-padding: var(--space-4);
|
|
36
36
|
}
|
|
37
37
|
.input.underline.m {
|
|
38
38
|
--input-left-padding: 9px;
|
|
39
|
-
--input-right-padding:
|
|
39
|
+
--input-right-padding: var(--space-8);
|
|
40
40
|
}
|
|
41
41
|
.input.underline.l {
|
|
42
42
|
--input-left-padding: 10px;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
--outer-color: var(--lt-ui-radio-border-color, var(--control-secondary));
|
|
11
11
|
--inner-color: var(--lt-ui-radio-color, var(--control-primary));
|
|
12
12
|
--inner-width: 0px;
|
|
13
|
-
--transition-duration: 350ms;
|
|
14
13
|
}
|
|
15
14
|
.radioIcon.m {
|
|
16
15
|
--size: var(--lt-ui-radio-size-m, 20px);
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
content: "";
|
|
40
39
|
border-radius: var(--rounding-circular);
|
|
41
40
|
box-shadow: 0 0 0 var(--inner-width) var(--inner-color) inset;
|
|
42
|
-
transition: box-shadow
|
|
41
|
+
transition: box-shadow 350ms cubic-bezier(0.4, 0, 0.5, 2.6);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
.inputInner {
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
.radio {
|
|
105
104
|
display: flex;
|
|
106
105
|
align-items: flex-start;
|
|
107
|
-
padding:
|
|
106
|
+
padding: var(--space-8);
|
|
108
107
|
color: var(--text-primary);
|
|
109
108
|
cursor: pointer;
|
|
110
109
|
user-select: none;
|
|
@@ -137,7 +136,7 @@
|
|
|
137
136
|
}
|
|
138
137
|
@media (pointer: coarse) {
|
|
139
138
|
.radio {
|
|
140
|
-
padding:
|
|
139
|
+
padding: var(--space-12);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
.radio.block {
|
|
@@ -145,7 +144,7 @@
|
|
|
145
144
|
}
|
|
146
145
|
.radio .labelText {
|
|
147
146
|
display: block;
|
|
148
|
-
margin-inline-start:
|
|
147
|
+
margin-inline-start: var(--space-8);
|
|
149
148
|
font-size: inherit;
|
|
150
149
|
line-height: inherit;
|
|
151
150
|
color: var(--label-color, var(--text-primary));
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
align-items: center;
|
|
45
45
|
justify-content: center;
|
|
46
46
|
padding: var(--item-padding, 0);
|
|
47
|
-
margin:
|
|
47
|
+
margin: var(--space-4);
|
|
48
48
|
font-family: inherit;
|
|
49
49
|
font-size: 1rem;
|
|
50
50
|
font-weight: 600;
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
.segmentedControlItem.extraClickZone::before {
|
|
84
84
|
position: absolute;
|
|
85
|
-
inset:
|
|
85
|
+
inset: -8px -8px;
|
|
86
86
|
content: "";
|
|
87
87
|
}
|
|
88
88
|
.segmentedControlItem.splitted {
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
font-weight: 400;
|
|
124
124
|
line-height: 1.3333333333;
|
|
125
125
|
letter-spacing: 0.2px;
|
|
126
|
-
--item-padding: 5px
|
|
126
|
+
--item-padding: 5px var(--space-12);
|
|
127
127
|
--item-square: var(--control-height-s);
|
|
128
128
|
}
|
|
129
129
|
.segmentedControlItem.m {
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
font-weight: 400;
|
|
132
132
|
line-height: 1.3333333333;
|
|
133
133
|
letter-spacing: 0.2px;
|
|
134
|
-
--item-padding: 9px
|
|
134
|
+
--item-padding: 9px var(--space-20);
|
|
135
135
|
--item-square: var(--control-height-m);
|
|
136
136
|
}
|
|
137
137
|
.segmentedControlItem.l {
|
|
@@ -139,11 +139,11 @@
|
|
|
139
139
|
font-weight: 400;
|
|
140
140
|
line-height: 1.4117647059;
|
|
141
141
|
letter-spacing: 0.2px;
|
|
142
|
-
--item-padding: 11px
|
|
142
|
+
--item-padding: 11px var(--space-24);
|
|
143
143
|
--item-square: var(--control-height-l);
|
|
144
144
|
}
|
|
145
145
|
.segmentedControlItem.composite {
|
|
146
|
-
--item-padding:
|
|
146
|
+
--item-padding: var(--space-16);
|
|
147
147
|
--button-border-radius: var(--rounding-l);
|
|
148
148
|
}
|
|
149
149
|
.segmentedControlItem.composite .contentWrap {
|
|
@@ -167,14 +167,14 @@
|
|
|
167
167
|
line-height: 0;
|
|
168
168
|
}
|
|
169
169
|
.segmentedControlItem .iconLeft {
|
|
170
|
-
margin-inline-end:
|
|
170
|
+
margin-inline-end: var(--space-4);
|
|
171
171
|
}
|
|
172
172
|
.segmentedControlItem .iconRight {
|
|
173
|
-
margin-inline-start:
|
|
173
|
+
margin-inline-start: var(--space-4);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
.extraCheck {
|
|
177
|
-
margin-inline-end:
|
|
177
|
+
margin-inline-end: var(--space-8);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
.extraCheckItem {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
.segmentedControl {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-wrap: wrap;
|
|
4
|
-
margin: -
|
|
4
|
+
margin: calc(-1 * var(--space-4));
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.scrollable {
|
|
8
8
|
--segmented-control-fade: var(--lt-ui-segmented-control-fade-width, 24px);
|
|
9
9
|
flex-wrap: nowrap;
|
|
10
|
-
padding:
|
|
11
|
-
margin: -
|
|
10
|
+
padding: var(--space-4);
|
|
11
|
+
margin: calc(-1 * var(--space-4));
|
|
12
12
|
overflow-x: auto;
|
|
13
13
|
overscroll-behavior-x: contain;
|
|
14
|
-
scroll-padding-inline:
|
|
14
|
+
scroll-padding-inline: var(--space-4);
|
|
15
15
|
scrollbar-width: none;
|
|
16
16
|
}
|
|
17
17
|
.scrollable::-webkit-scrollbar {
|
|
@@ -45,10 +45,10 @@ const compat_1 = require("../../_internal/compat");
|
|
|
45
45
|
const typography_1 = require("../../typography");
|
|
46
46
|
const use_multiselect_collapsed_display_1 = require("../hooks/use-multiselect-collapsed-display");
|
|
47
47
|
const select_field_module_scss_1 = __importDefault(require("../styles/select-field.module.css"));
|
|
48
|
-
exports.SelectFieldMultiselectValue = (0, compat_1.withRef)(function SelectFieldMultiselectValue({ labels, size = 'l', overflowSelectedLabel, className, id, open = false, disabled, listboxId, labelledBy, activeDescendantId, onClick, onKeyDown, onFocus, onBlur, }, ref) {
|
|
48
|
+
exports.SelectFieldMultiselectValue = (0, compat_1.withRef)(function SelectFieldMultiselectValue({ labels, size = 'l', overflowSelectedLabel, className, id, open = false, disabled, listboxId, labelledBy, ariaLabel, activeDescendantId, onClick, onKeyDown, onFocus, onBlur, }, ref) {
|
|
49
49
|
const rowRef = (0, react_1.useRef)(null);
|
|
50
50
|
const { visibleText, hiddenCount, overflowLabel, setMeasureTarget, setSuffixMeasureTarget } = (0, use_multiselect_collapsed_display_1.useMultiselectCollapsedDisplay)(labels, rowRef, overflowSelectedLabel);
|
|
51
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, id: id, role: "combobox", tabIndex: disabled ? undefined : 0, "aria-expanded": open, "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-labelledby": labelledBy, "aria-activedescendant": open && activeDescendantId ? activeDescendantId : undefined, "aria-disabled": disabled || undefined, className: (0, clsx_1.default)(className, select_field_module_scss_1.default.multiselectValueOuter, {
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, id: id, role: "combobox", tabIndex: disabled ? undefined : 0, "aria-expanded": open, "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-labelledby": labelledBy, "aria-label": ariaLabel, "aria-activedescendant": open && activeDescendantId ? activeDescendantId : undefined, "aria-disabled": disabled || undefined, className: (0, clsx_1.default)(className, select_field_module_scss_1.default.multiselectValueOuter, {
|
|
52
52
|
[select_field_module_scss_1.default.selectValueDisabled]: disabled,
|
|
53
53
|
}), onClick: onClick, onKeyDown: onKeyDown, onFocus: onFocus, onBlur: onBlur, children: (0, jsx_runtime_1.jsxs)("div", { ref: rowRef, className: select_field_module_scss_1.default.multiselectValue, children: [(0, jsx_runtime_1.jsxs)(typography_1.Typography, { ref: setMeasureTarget, as: "span", variant: size === 'l' ? 'body-m' : 'body-s', className: (0, clsx_1.default)(select_field_module_scss_1.default.multiselectValueText, {
|
|
54
54
|
[select_field_module_scss_1.default.multiselectValueTextEllipsis]: hiddenCount === 0,
|
|
@@ -86,7 +86,7 @@ function useRestoreFocusAfterClose(open, focused, comboboxRef, inputRef) {
|
|
|
86
86
|
return () => cancelAnimationFrame(frame);
|
|
87
87
|
}, [open, comboboxRef, inputRef]);
|
|
88
88
|
}
|
|
89
|
-
exports.SelectField = (0, compat_1.withRef)(function SelectField({ label, placeholder, displayValue, mode = 'single', multiselectLabels = [], chipsVariant = 'none', open, disabled, status, theme, filled, size = 'l', variant = 'outline', fullWidth, allowClear, onClear, showSearch, searchValue = '', selectedValueText, onSearchChange, onOpen, onToggle, overflowSelectedLabel, caption, className, controlRef, activeDescendantId, onComboboxKeyDown, 'data-testid': testId = 'select-field', listboxId, }, ref) {
|
|
89
|
+
exports.SelectField = (0, compat_1.withRef)(function SelectField({ label, 'aria-label': ariaLabel, startAdornment, placeholder, displayValue, mode = 'single', multiselectLabels = [], chipsVariant = 'none', open, disabled, status, theme, filled, size = 'l', variant = 'outline', fullWidth, allowClear, onClear, showSearch, searchValue = '', selectedValueText, onSearchChange, onOpen, onToggle, overflowSelectedLabel, caption, className, controlRef, activeDescendantId, onComboboxKeyDown, 'data-testid': testId = 'select-field', listboxId, }, ref) {
|
|
90
90
|
const { t } = (0, use_locale_1.useLocale)();
|
|
91
91
|
// По умолчанию свёрнутый multiselect подписывает скрытые значения: «ещё 2»
|
|
92
92
|
const defaultOverflowLabel = (0, react_1.useCallback)((hiddenCount) => t('select.moreSelected', { count: hiddenCount }), [t]);
|
|
@@ -122,6 +122,7 @@ exports.SelectField = (0, compat_1.withRef)(function SelectField({ label, placeh
|
|
|
122
122
|
const openPlaceholderOverride = selectedValueText !== null && selectedValueText !== void 0 ? selectedValueText : multiselectPlaceholderText;
|
|
123
123
|
const mergedSearchInputRef = (0, react_1.useMemo)(() => (0, utils_1.mergeRefs)([mergedControlRef, setMultiselectPlaceholderMeasureTarget]), [mergedControlRef, setMultiselectPlaceholderMeasureTarget]);
|
|
124
124
|
const comboboxA11yProps = {
|
|
125
|
+
'aria-label': ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : (variant === 'trigger' ? label : undefined),
|
|
125
126
|
'aria-activedescendant': open && activeDescendantId ? activeDescendantId : undefined,
|
|
126
127
|
'aria-disabled': disabled || undefined,
|
|
127
128
|
};
|
|
@@ -191,14 +192,15 @@ exports.SelectField = (0, compat_1.withRef)(function SelectField({ label, placeh
|
|
|
191
192
|
const inactiveValueText = getInactiveValueText({
|
|
192
193
|
hasDisplayValue,
|
|
193
194
|
fieldActive,
|
|
194
|
-
hasLabel: !!label,
|
|
195
|
+
hasLabel: !!label && variant !== 'trigger',
|
|
195
196
|
placeholder,
|
|
196
197
|
displayValue,
|
|
197
198
|
});
|
|
198
|
-
const showPlaceholderStyle = !hasDisplayValue && (fieldActive || !label);
|
|
199
|
-
const labelledBy = label ? `${fieldId}-label` : undefined;
|
|
199
|
+
const showPlaceholderStyle = !hasDisplayValue && (fieldActive || !label || variant === 'trigger');
|
|
200
|
+
const labelledBy = label && variant !== 'trigger' ? `${fieldId}-label` : undefined;
|
|
200
201
|
const multiselectValueProps = {
|
|
201
202
|
labelledBy,
|
|
203
|
+
ariaLabel: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : (variant === 'trigger' ? label : undefined),
|
|
202
204
|
labels: multiselectLabels,
|
|
203
205
|
size,
|
|
204
206
|
overflowSelectedLabel: overflowLabel,
|
|
@@ -214,6 +216,6 @@ exports.SelectField = (0, compat_1.withRef)(function SelectField({ label, placeh
|
|
|
214
216
|
onBlur: onInputBlur,
|
|
215
217
|
ref: mergedComboboxRef,
|
|
216
218
|
};
|
|
217
|
-
const valueContent = ((0, jsx_runtime_1.jsx)(select_field_value_1.SelectFieldValue, { fieldId: fieldId, testId: testId, mode: mode, showSearch: showSearch, open: open, disabled: disabled, listboxId: listboxId, labelledBy: labelledBy, valueClassName: valueClassName, showPlaceholderStyle: showPlaceholderStyle, hasLabel: Boolean(label), hasDisplayValue: hasDisplayValue, displayValue: displayValue, inactiveValueText: inactiveValueText, searchValue: searchValue, placeholder: placeholder, openPlaceholderOverride: openPlaceholderOverride, collapsedMultiselect: showSearch ? showMultiselectCollapsedValue : showMultiselectCollapsedValueNonSearch, multiselectValueProps: multiselectValueProps, searchInputRef: mergedSearchInputRef, comboboxRef: mergedComboboxRef, comboboxA11yProps: comboboxA11yProps, onSearchChange: onSearchChange, onOpen: onOpen, onFieldClick: onFieldClick, onFieldKeyDown: onFieldKeyDown, onInputFocus: onInputFocus, onInputBlur: onInputBlur, onSearchInputMouseDown: onSearchInputMouseDown }));
|
|
218
|
-
return ((0, jsx_runtime_1.jsx)(field_1.FieldFrame, { ref: ref, size: size, label: label, controlId: fieldId, active: fieldActive, focused: focused || open, status: status, theme: theme, disabled: disabled, underline: variant === 'underline', fullWidth: fullWidth, withClear: showClear, caption: caption, className: (0, clsx_1.default)(select_field_module_scss_1.default.selectRoot, classNames.root, className), clear: showClear ? ((0, jsx_runtime_1.jsx)(field_1.FieldClearButton, { size: size, disabled: disabled, label: t('select.clearValue'), onClear: onClearClick, className: classNames.clear })) : undefined, endAdornment: (0, jsx_runtime_1.jsx)("button", { type: "button", tabIndex: -1, className: (0, clsx_1.default)(select_field_module_scss_1.default.arrowButton, disabled && select_field_module_scss_1.default.arrowButtonDisabled, classNames.arrow), disabled: disabled, "aria-disabled": disabled, "aria-label": open ? t('select.close') : t('select.open'), onMouseDown: onAdornmentMouseDown, onClick: onArrowClick, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { size: size === 's' ? 16 : 20, color: disabled ? 'text-minor' : 'text-primary', children: (0, jsx_runtime_1.jsx)(icons_1.ArrowIcon, { direction: open ? 'top' : 'bottom' }) }) }), children: valueContent }));
|
|
219
|
+
const valueContent = ((0, jsx_runtime_1.jsx)(select_field_value_1.SelectFieldValue, { fieldId: fieldId, testId: testId, mode: mode, showSearch: showSearch, open: open, disabled: disabled, listboxId: listboxId, labelledBy: labelledBy, valueClassName: valueClassName, showPlaceholderStyle: showPlaceholderStyle, hasLabel: Boolean(label) && variant !== 'trigger', hasDisplayValue: hasDisplayValue, displayValue: displayValue, inactiveValueText: inactiveValueText, searchValue: searchValue, placeholder: placeholder, openPlaceholderOverride: openPlaceholderOverride, collapsedMultiselect: showSearch ? showMultiselectCollapsedValue : showMultiselectCollapsedValueNonSearch, multiselectValueProps: multiselectValueProps, searchInputRef: mergedSearchInputRef, comboboxRef: mergedComboboxRef, comboboxA11yProps: comboboxA11yProps, onSearchChange: onSearchChange, onOpen: onOpen, onFieldClick: onFieldClick, onFieldKeyDown: onFieldKeyDown, onInputFocus: onInputFocus, onInputBlur: onInputBlur, onSearchInputMouseDown: onSearchInputMouseDown }));
|
|
220
|
+
return ((0, jsx_runtime_1.jsx)(field_1.FieldFrame, { ref: ref, size: size, label: variant === 'trigger' ? undefined : label, startAdornment: startAdornment, controlId: fieldId, active: fieldActive, focused: focused || open, status: status, theme: theme, disabled: disabled, underline: variant === 'underline', fullWidth: fullWidth, withClear: showClear, caption: caption, className: (0, clsx_1.default)(select_field_module_scss_1.default.selectRoot, variant === 'trigger' && select_field_module_scss_1.default.trigger, classNames.root, className), clear: showClear ? ((0, jsx_runtime_1.jsx)(field_1.FieldClearButton, { size: size, disabled: disabled, label: t('select.clearValue'), onClear: onClearClick, className: classNames.clear })) : undefined, endAdornment: (0, jsx_runtime_1.jsx)("button", { type: "button", tabIndex: -1, className: (0, clsx_1.default)(select_field_module_scss_1.default.arrowButton, disabled && select_field_module_scss_1.default.arrowButtonDisabled, classNames.arrow), disabled: disabled, "aria-disabled": disabled, "aria-label": open ? t('select.close') : t('select.open'), onMouseDown: onAdornmentMouseDown, onClick: onArrowClick, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { size: size === 's' ? 16 : 20, color: disabled ? 'text-minor' : 'text-primary', children: (0, jsx_runtime_1.jsx)(icons_1.ArrowIcon, { direction: open ? 'top' : 'bottom' }) }) }), children: valueContent }));
|
|
219
221
|
});
|
|
@@ -43,91 +43,33 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
43
43
|
const react_1 = __importStar(require("react"));
|
|
44
44
|
const hooks_1 = require("../../_internal/hooks");
|
|
45
45
|
const button_1 = require("../../button");
|
|
46
|
-
const use_isomorphic_layout_effect_1 = require("../../hooks/use-isomorphic-layout-effect");
|
|
47
46
|
const icon_1 = require("../../icon");
|
|
48
47
|
const icons_1 = require("../../icons");
|
|
49
48
|
const use_locale_1 = require("../../locale/use-locale");
|
|
49
|
+
const typography_1 = require("../../typography");
|
|
50
50
|
const use_auto_scroll_to_bottom_1 = require("../hooks/use-auto-scroll-to-bottom");
|
|
51
51
|
const use_chips_row_count_1 = require("../hooks/use-chips-row-count");
|
|
52
52
|
const use_select_virtual_1 = require("../hooks/use-select-virtual");
|
|
53
|
+
const use_select_multiselect_panel_layout_1 = require("../hooks/use-select-multiselect-panel-layout");
|
|
53
54
|
const select_module_scss_1 = __importDefault(require("../styles/select.module.css"));
|
|
54
55
|
const filter_options_1 = require("../utils/filter-options");
|
|
55
56
|
const get_status_content_1 = require("../utils/get-status-content");
|
|
56
57
|
const retain_combobox_focus_1 = require("../utils/retain-combobox-focus");
|
|
57
58
|
const select_option_list_1 = require("./select-option-list");
|
|
58
59
|
const select_panel_status_1 = require("./select-panel-status");
|
|
59
|
-
/**
|
|
60
|
-
* `chipsExpandedMode="auto"`: панель открывается развёрнутой, чтобы измерить реальное число строк
|
|
61
|
-
* (см. `useSelectMultiselectPanelState`), и здесь по факту overflow решает — оставить развёрнутой
|
|
62
|
-
* или свернуть. Решение принимается один раз за сессию открытия, дальше чипсы можно переключать вручную.
|
|
63
|
-
*/
|
|
64
|
-
function useAutoDecideChipsOverflow({ open, chipsExpandedMode, showChipsArea, chipsFullMode, chipsRowCount, chipsNumericMaxRows, onChipsOverflow, }) {
|
|
65
|
-
const autoDecidedRef = (0, react_1.useRef)(false);
|
|
66
|
-
(0, react_1.useEffect)(() => {
|
|
67
|
-
if (!open) {
|
|
68
|
-
autoDecidedRef.current = false;
|
|
69
|
-
}
|
|
70
|
-
}, [open]);
|
|
71
|
-
(0, use_isomorphic_layout_effect_1.useIsomorphicLayoutEffect)(() => {
|
|
72
|
-
if (!open || chipsExpandedMode !== 'auto' || autoDecidedRef.current || !showChipsArea) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (chipsFullMode) {
|
|
76
|
-
autoDecidedRef.current = true;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (chipsRowCount === 0) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
autoDecidedRef.current = true;
|
|
83
|
-
if (chipsNumericMaxRows !== undefined && chipsRowCount > chipsNumericMaxRows) {
|
|
84
|
-
onChipsOverflow === null || onChipsOverflow === void 0 ? void 0 : onChipsOverflow();
|
|
85
|
-
}
|
|
86
|
-
}, [
|
|
87
|
-
open,
|
|
88
|
-
chipsExpandedMode,
|
|
89
|
-
showChipsArea,
|
|
90
|
-
chipsFullMode,
|
|
91
|
-
chipsRowCount,
|
|
92
|
-
chipsNumericMaxRows,
|
|
93
|
-
onChipsOverflow,
|
|
94
|
-
]);
|
|
95
|
-
}
|
|
96
|
-
/** Высота области содержимого панели: нужна, чтобы блок чипсов в режиме `'full'` занял всё доступное место */
|
|
97
|
-
function useContentAreaHeight(ref, enabled, remeasureKey) {
|
|
98
|
-
const [height, setHeight] = (0, react_1.useState)(0);
|
|
99
|
-
(0, use_isomorphic_layout_effect_1.useIsomorphicLayoutEffect)(() => {
|
|
100
|
-
const contentArea = ref.current;
|
|
101
|
-
if (!enabled || !contentArea) {
|
|
102
|
-
setHeight(0);
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
const measure = () => {
|
|
106
|
-
setHeight(contentArea.clientHeight);
|
|
107
|
-
};
|
|
108
|
-
measure();
|
|
109
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
const observer = new ResizeObserver(measure);
|
|
113
|
-
observer.observe(contentArea);
|
|
114
|
-
return () => observer.disconnect();
|
|
115
|
-
}, [ref, enabled, remeasureKey]);
|
|
116
|
-
return height;
|
|
117
|
-
}
|
|
118
60
|
/** Какие части шапки панели показывать: заголовок с выбранным, блок чипсов или подпись «ничего не выбрано» */
|
|
119
|
-
function getHeaderVisibility(showPanelHeaderEnabled, hasSelection, chipsExpanded) {
|
|
61
|
+
function getHeaderVisibility(showPanelHeaderEnabled, hasSelection, chipsExpanded, chipsEnabled) {
|
|
120
62
|
const showSelectionHeader = showPanelHeaderEnabled && hasSelection;
|
|
121
63
|
return {
|
|
122
64
|
showPanelHeaderEnabled,
|
|
123
65
|
showSelectionHeader,
|
|
124
|
-
showChipsArea: showSelectionHeader && chipsExpanded,
|
|
66
|
+
showChipsArea: showSelectionHeader && chipsExpanded && chipsEnabled,
|
|
125
67
|
showEmptyLabel: showPanelHeaderEnabled && !hasSelection,
|
|
126
68
|
};
|
|
127
69
|
}
|
|
128
70
|
/** Padding-bottom `.chipsArea` (сверху паддинга нет — см. стили) — учитывается в max-height блока чипсов */
|
|
129
71
|
const CHIPS_AREA_VERTICAL_PADDING = 16;
|
|
130
|
-
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, }) {
|
|
72
|
+
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, }) {
|
|
131
73
|
const { t } = (0, use_locale_1.useLocale)();
|
|
132
74
|
const emptySelectionLabel = emptySelectionLabelProp !== null && emptySelectionLabelProp !== void 0 ? emptySelectionLabelProp : t('select.emptySelection');
|
|
133
75
|
const selectedCountLabel = selectedCountLabelProp !== null && selectedCountLabelProp !== void 0 ? selectedCountLabelProp : ((count) => t('select.selectedCount', { count }));
|
|
@@ -159,7 +101,7 @@ function SelectMultiselectPanel({ id, options, chipOptions, value: selectedValue
|
|
|
159
101
|
const onPanelMouseDownCapture = (event) => {
|
|
160
102
|
(0, retain_combobox_focus_1.retainComboboxFocusOnMouseDown)(event);
|
|
161
103
|
};
|
|
162
|
-
const { showPanelHeaderEnabled, showSelectionHeader, showChipsArea, showEmptyLabel } = getHeaderVisibility(showPanelHeader !== false, selectedOptions.length > 0, chipsExpanded);
|
|
104
|
+
const { showPanelHeaderEnabled, showSelectionHeader, showChipsArea, showEmptyLabel } = getHeaderVisibility(showPanelHeader !== false, selectedOptions.length > 0, chipsExpanded, chipsEnabled);
|
|
163
105
|
const showStatus = showLoader || showNotFound || showMinCharsHint;
|
|
164
106
|
const statusContent = (0, get_status_content_1.getStatusContent)({
|
|
165
107
|
loading: showLoader,
|
|
@@ -175,10 +117,10 @@ function SelectMultiselectPanel({ id, options, chipOptions, value: selectedValue
|
|
|
175
117
|
const chipsFixedMaxHeight = chipsFullMode
|
|
176
118
|
? undefined
|
|
177
119
|
: getHeightForRows(chipsNumericMaxRows) + CHIPS_AREA_VERTICAL_PADDING;
|
|
178
|
-
const contentAreaHeight = useContentAreaHeight(contentAreaRef, chipsFullMode && showChipsArea, `${chipsRowCount}:${selectedOptions.length}`);
|
|
120
|
+
const contentAreaHeight = (0, use_select_multiselect_panel_layout_1.useContentAreaHeight)(contentAreaRef, chipsFullMode && showChipsArea, `${chipsRowCount}:${selectedOptions.length}`);
|
|
179
121
|
const chipsAreaMaxHeight = chipsFullMode && contentAreaHeight > 0 ? contentAreaHeight : chipsFixedMaxHeight;
|
|
180
122
|
(0, use_auto_scroll_to_bottom_1.useAutoScrollToBottom)(chipsScrollRef, selectedOptions.length);
|
|
181
|
-
useAutoDecideChipsOverflow({
|
|
123
|
+
(0, use_select_multiselect_panel_layout_1.useAutoDecideChipsOverflow)({
|
|
182
124
|
open,
|
|
183
125
|
chipsExpandedMode,
|
|
184
126
|
showChipsArea,
|
|
@@ -198,5 +140,5 @@ function SelectMultiselectPanel({ id, options, chipOptions, value: selectedValue
|
|
|
198
140
|
return ((0, jsx_runtime_1.jsxs)("div", { id: id, ref: panelRef, className: (0, clsx_1.default)(select_module_scss_1.default.panel, mobile && select_module_scss_1.default.panelMobile, !showPanelHeaderEnabled && select_module_scss_1.default.panelFit, className),
|
|
199
141
|
// С шапкой и чипсами высота фиксирована: при сворачивании чипсов панель не должна прыгать. Без шапки
|
|
200
142
|
// (`chipsVariant="none"`) панель по высоте списка — без пустого места под вариантами
|
|
201
|
-
style: showPanelHeaderEnabled ? { height: maxHeight } : { maxHeight }, onKeyDown: onChipsKeyDown, onMouseDownCapture: onPanelMouseDownCapture, onClickCapture: onPanelClickCapture, children: [showSelectionHeader && ((0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)(select_module_scss_1.default.panelHeader, showHeaderDivider && select_module_scss_1.default.panelHeaderDivider), children: [(0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", size: "m", variant: "link-secondary", iconRight: (0, jsx_runtime_1.jsx)(icons_1.ArrowIcon, { direction: headerCollapsed ? 'bottom' : 'top' }), tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', onClick: onToggleChips, children: headerLabel }), (0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", size: "m", variant: "link-secondary", iconLeft: (0, jsx_runtime_1.jsx)(icons_1.DelIcon, {}), tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', onClick: onClear, children: clearLabel })] })), (0, jsx_runtime_1.jsxs)("div", { ref: contentAreaRef, className: select_module_scss_1.default.contentArea, children: [showChipsArea && ((0, jsx_runtime_1.jsx)("div", { ref: chipsScrollRef, className: (0, clsx_1.default)(select_module_scss_1.default.chipsArea, !chipsFullMode && select_module_scss_1.default.chipsAreaFixed, chipsFullMode && select_module_scss_1.default.chipsAreaFull, chipsOverflows && select_module_scss_1.default.chipsAreaScrollable, showChipsDivider && select_module_scss_1.default.chipsAreaDivider), style: chipsAreaMaxHeight !== undefined ? { maxHeight: chipsAreaMaxHeight } : undefined, children: (0, jsx_runtime_1.jsx)("div", { ref: chipsAreaRef, className: select_module_scss_1.default.chipsRow, children: selectedOptions.map(option => ((0, jsx_runtime_1.jsxs)("span", { className: select_module_scss_1.default.panelChip, children: [(0, jsx_runtime_1.jsx)("span", { className: select_module_scss_1.default.panelChipText, children: (0, filter_options_1.getOptionText)(option) }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: select_module_scss_1.default.panelChipRemove, tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', "aria-label": t('select.remove', { label: (0, filter_options_1.getOptionText)(option) }), onClick: () => onRemoveChip(option.value), children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { size: 16, color: "text-invert", children: (0, jsx_runtime_1.jsx)(icons_1.DelIcon, {}) }) })] }, String(option.value)))) }) })), showEmptyLabel && !showStatus && !searchActive && ((0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.emptySelection, children: emptySelectionLabel })), (0, jsx_runtime_1.jsxs)("div", { className: select_module_scss_1.default.listSection, children: [!showChipsArea && (0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.listPaddingTop }), (0, jsx_runtime_1.jsx)("div", { ref: virtual.enabled ? virtual.scrollRef : undefined, className: select_module_scss_1.default.listWrapFill, children: listContent }), (0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.listPaddingBottom })] })] })] }));
|
|
143
|
+
style: showPanelHeaderEnabled ? { height: maxHeight } : { maxHeight }, onKeyDown: onChipsKeyDown, onMouseDownCapture: onPanelMouseDownCapture, onClickCapture: onPanelClickCapture, children: [showSelectionHeader && ((0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)(select_module_scss_1.default.panelHeader, showHeaderDivider && select_module_scss_1.default.panelHeaderDivider), children: [chipsEnabled ? ((0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", size: "m", variant: "link-secondary", iconRight: (0, jsx_runtime_1.jsx)(icons_1.ArrowIcon, { direction: headerCollapsed ? 'bottom' : 'top' }), tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', onClick: onToggleChips, children: headerLabel })) : ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-s-compact", color: "text-secondary", children: selectedCountLabel(selectedOptions.length) })), (0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", size: "m", variant: "link-secondary", iconLeft: (0, jsx_runtime_1.jsx)(icons_1.DelIcon, {}), tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', onClick: onClear, children: clearLabel })] })), (0, jsx_runtime_1.jsxs)("div", { ref: contentAreaRef, className: select_module_scss_1.default.contentArea, children: [showChipsArea && ((0, jsx_runtime_1.jsx)("div", { ref: chipsScrollRef, className: (0, clsx_1.default)(select_module_scss_1.default.chipsArea, !chipsFullMode && select_module_scss_1.default.chipsAreaFixed, chipsFullMode && select_module_scss_1.default.chipsAreaFull, chipsOverflows && select_module_scss_1.default.chipsAreaScrollable, showChipsDivider && select_module_scss_1.default.chipsAreaDivider), style: chipsAreaMaxHeight !== undefined ? { maxHeight: chipsAreaMaxHeight } : undefined, children: (0, jsx_runtime_1.jsx)("div", { ref: chipsAreaRef, className: select_module_scss_1.default.chipsRow, children: selectedOptions.map(option => ((0, jsx_runtime_1.jsxs)("span", { className: select_module_scss_1.default.panelChip, children: [(0, jsx_runtime_1.jsx)("span", { className: select_module_scss_1.default.panelChipText, children: (0, filter_options_1.getOptionText)(option) }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: select_module_scss_1.default.panelChipRemove, tabIndex: -1, [hooks_1.CHIPS_NAV_ATTR]: '', "aria-label": t('select.remove', { label: (0, filter_options_1.getOptionText)(option) }), onClick: () => onRemoveChip(option.value), children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { size: 16, color: "text-invert", children: (0, jsx_runtime_1.jsx)(icons_1.DelIcon, {}) }) })] }, String(option.value)))) }) })), showEmptyLabel && !showStatus && !searchActive && ((0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.emptySelection, children: emptySelectionLabel })), (0, jsx_runtime_1.jsxs)("div", { className: select_module_scss_1.default.listSection, children: [!showChipsArea && (0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.listPaddingTop }), (0, jsx_runtime_1.jsx)("div", { ref: virtual.enabled ? virtual.scrollRef : undefined, className: select_module_scss_1.default.listWrapFill, children: listContent }), (0, jsx_runtime_1.jsx)("div", { className: select_module_scss_1.default.listPaddingBottom })] })] })] }));
|
|
202
144
|
}
|
|
@@ -1,38 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
5
|
};
|
|
@@ -40,37 +7,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
7
|
exports.SelectOptionRow = SelectOptionRow;
|
|
41
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
9
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
|
-
const react_1 =
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
44
11
|
const icon_1 = require("../../icon");
|
|
45
12
|
const list_icon_1 = require("../../list/list-item/list-icon");
|
|
46
13
|
const typography_1 = require("../../typography");
|
|
47
14
|
const class_names_context_1 = require("../class-names-context");
|
|
48
15
|
const select_module_scss_1 = __importDefault(require("../styles/select.module.css"));
|
|
49
16
|
const select_option_id_1 = require("../utils/select-option-id");
|
|
17
|
+
const use_select_option_row_1 = require("../hooks/use-select-option-row");
|
|
50
18
|
function SelectOptionRow({ value, text, description, selected = false, active = false, disabled = false, showSelectionIcon = true, size = 'l', setSize, posInSet, onSelect, onMouseMove, }) {
|
|
51
19
|
const classNames = (0, class_names_context_1.useSelectClassNames)();
|
|
52
20
|
const iconSize = size === 'm' ? 20 : 24;
|
|
53
21
|
const textVariant = size === 'l' ? 'body-m' : 'body-s';
|
|
54
22
|
const descriptionVariant = size === 'l' ? 'body-m-compact' : 'body-s-compact';
|
|
55
|
-
const onClick = (0,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const onKeyDown = (0, react_1.useCallback)((event) => {
|
|
61
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
62
|
-
event.preventDefault();
|
|
63
|
-
onClick();
|
|
64
|
-
}
|
|
65
|
-
}, [onClick]);
|
|
66
|
-
const onOptionMouseDown = (0, react_1.useCallback)((event) => {
|
|
67
|
-
event.preventDefault();
|
|
68
|
-
}, []);
|
|
69
|
-
const onOptionMouseMove = (0, react_1.useCallback)(() => {
|
|
70
|
-
if (!disabled) {
|
|
71
|
-
onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove();
|
|
72
|
-
}
|
|
73
|
-
}, [disabled, onMouseMove]);
|
|
23
|
+
const { onClick, onKeyDown, onOptionMouseDown, onOptionMouseMove } = (0, use_select_option_row_1.useSelectOptionRow)({
|
|
24
|
+
disabled,
|
|
25
|
+
onSelect,
|
|
26
|
+
onMouseMove,
|
|
27
|
+
});
|
|
74
28
|
return ((0, jsx_runtime_1.jsxs)("li", { "data-lt-ui": "select-option", id: (0, select_option_id_1.getSelectOptionElementId)(value), role: "option", tabIndex: -1, "aria-selected": selected, "aria-disabled": disabled, "aria-setsize": setSize, "aria-posinset": posInSet, className: (0, clsx_1.default)(select_module_scss_1.default.optionRow, select_module_scss_1.default[`optionRow_${size}`], {
|
|
75
29
|
[select_module_scss_1.default.optionRowDisabled]: disabled,
|
|
76
30
|
[select_module_scss_1.default.optionRowActive]: active,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useAutoDecideChipsOverflow = useAutoDecideChipsOverflow;
|
|
5
|
+
exports.useContentAreaHeight = useContentAreaHeight;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const use_isomorphic_layout_effect_1 = require("../../hooks/use-isomorphic-layout-effect");
|
|
8
|
+
function useAutoDecideChipsOverflow({ open, chipsExpandedMode, showChipsArea, chipsFullMode, chipsRowCount, chipsNumericMaxRows, onChipsOverflow, }) {
|
|
9
|
+
const autoDecidedRef = (0, react_1.useRef)(false);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!open)
|
|
12
|
+
autoDecidedRef.current = false;
|
|
13
|
+
}, [open]);
|
|
14
|
+
(0, use_isomorphic_layout_effect_1.useIsomorphicLayoutEffect)(() => {
|
|
15
|
+
if (!open || chipsExpandedMode !== 'auto' || autoDecidedRef.current || !showChipsArea)
|
|
16
|
+
return;
|
|
17
|
+
if (chipsFullMode) {
|
|
18
|
+
autoDecidedRef.current = true;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (chipsRowCount === 0)
|
|
22
|
+
return;
|
|
23
|
+
autoDecidedRef.current = true;
|
|
24
|
+
if (chipsNumericMaxRows !== undefined && chipsRowCount > chipsNumericMaxRows)
|
|
25
|
+
onChipsOverflow === null || onChipsOverflow === void 0 ? void 0 : onChipsOverflow();
|
|
26
|
+
}, [
|
|
27
|
+
open,
|
|
28
|
+
chipsExpandedMode,
|
|
29
|
+
showChipsArea,
|
|
30
|
+
chipsFullMode,
|
|
31
|
+
chipsRowCount,
|
|
32
|
+
chipsNumericMaxRows,
|
|
33
|
+
onChipsOverflow,
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
function useContentAreaHeight(ref, enabled, remeasureKey) {
|
|
37
|
+
const [height, setHeight] = (0, react_1.useState)(0);
|
|
38
|
+
(0, use_isomorphic_layout_effect_1.useIsomorphicLayoutEffect)(() => {
|
|
39
|
+
const contentArea = ref.current;
|
|
40
|
+
if (!enabled || !contentArea) {
|
|
41
|
+
setHeight(0);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const measure = () => setHeight(contentArea.clientHeight);
|
|
45
|
+
measure();
|
|
46
|
+
if (typeof ResizeObserver === 'undefined')
|
|
47
|
+
return undefined;
|
|
48
|
+
const observer = new ResizeObserver(measure);
|
|
49
|
+
observer.observe(contentArea);
|
|
50
|
+
return () => observer.disconnect();
|
|
51
|
+
}, [ref, enabled, remeasureKey]);
|
|
52
|
+
return height;
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useSelectOptionRow = useSelectOptionRow;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useSelectOptionRow({ disabled, onSelect, onMouseMove }) {
|
|
7
|
+
const onClick = (0, react_1.useCallback)(() => {
|
|
8
|
+
if (!disabled)
|
|
9
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
10
|
+
}, [disabled, onSelect]);
|
|
11
|
+
const onKeyDown = (0, react_1.useCallback)((event) => {
|
|
12
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
13
|
+
return;
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
onClick();
|
|
16
|
+
}, [onClick]);
|
|
17
|
+
const onOptionMouseDown = (0, react_1.useCallback)((event) => event.preventDefault(), []);
|
|
18
|
+
const onOptionMouseMove = (0, react_1.useCallback)(() => {
|
|
19
|
+
if (!disabled)
|
|
20
|
+
onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove();
|
|
21
|
+
}, [disabled, onMouseMove]);
|
|
22
|
+
return { onClick, onKeyDown, onOptionMouseDown, onOptionMouseMove };
|
|
23
|
+
}
|